Using Internet over rndis USB computer (reverse tethering)

Hello,
I have my sony xperia 10 II flashed with sailfish 4.3 and I am so happy with it, but I have one issue, I need to make the system understand that an Internet connection exists without mobile data nor wifi (using in an environment without EMF).
I connect the USB cable to my computer, using the dev mode, I have an IP on the computer and on the phone.
I configured the computer to act as gateway (firewall/nat), and on the phone I added the default gateway to the ip of the computer.
Everything works perfectly, from the cli on the phone, i can ping hosts and ssh them without issues.
But when I launch any application (browser, jolla store … etc) they say that no internet connections.
Is there a way to solve this please?
Thank you and best regards

1 Like

Have you set a DNS in /etc/resolv.conf?

1 Like

Thank you @kan_ibal for your reply, yes i did, that’s why i can ssh hosts and ping them (hosts directly without using their ips).
But it seems that the connection manager is still telling all the applications that there is no connection :frowning:

Yes. I remember playing around with connman a while ago to circumvent this issue or fake a connection but did not succeed.
For completeness, there were also two topics on this issue on the old plattform:

1 Like

Hello @sebix , thank you very much for your reply, indeed these 2 issues are related but the first one stopped at where I am now and the 2nd was about forward tethering I think not reverse.
Do you remember the steps you did with connman please? so at least I will start from where you stopped.
Thank you again

I can just share how I do it in Linux.

On the PC

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -P FORWARD ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.2.0/24
iptables -I INPUT 1 -s 192.168.2.15 -j ACCEPT

to clean up after you finish execute

iptables -t nat -F POSTROUTING
iptables -F INPUT
echo 0 > /proc/sys/net/ipv4/ip_forwardindent preformatted text by 4 spaces

ssh to the phone
on the phone add route to your home network (192.168.4.0/24)

ip route add default via 192.168.2.11
ip route add 192.168.4.0/24 via 192.168.2.11

add search and nameserver to /etc/resolv.conf

echo "search s-und-s.home" >> /etc/resolv.conf
echo "nameserver 192.168.4.1" >> /etc/resolv.conf
1 Like

Thank you @deloptes this is indeed what I did and it works perfectly on the CLI, but how to let the applications know that an internet connection exists? as launching the browser or jolla store or backup or anything gives an error : wlan is off, no internet connection :frowning:

well - Jolla knows better how this was written. Some work and some don’t, because it depends how these applications are developed

I think we just need to tell the connman daemon to consider the rndis as valid connection as it does with wlan.
I just hope someone who knows how this daemon works helps us :crossed_fingers:

Conman is so complicated as are so many services on modern Linux-systems. I request a modern *bsd (preferably netbsd/openbsd)-based mobile operating system in order to be able to understand what’s going on;)

Yeah, that was it what I tried. The same issue occurs when using an USB-Ethernet dongle.

Here are some more links:

The first link has good advice, but still it required fiddling with connman (compiling).
Here are some of my notes from back then (<=2021, not sure about the exact date):

devel-su
pkcon install gcc gcc-c++ make automake autoconf libtool glib2-devel dbus-devel iptables-devel gnutls-devel readline-devel 
cd /home/nemo/Downloads
CONNMAN_VER=$(connmand -v|cut -d'+' -f1)
curl -O https://git.kernel.org/pub/scm/network/connman/connman.git/snapshot/connman-${CONNMAN_VER}.tar.gz
tar xf connman-${CONNMAN_VER}.tar.gz
cd connman-${CONNMAN_VER}
./bootstrap
./configure
make
cp client/connmanctl /usr/local/bin/
# 2. Remove dependencies and files not needed after build (still as root)
pkcon remove kernel-headers glibc-headers binutils gcc gcc-c++ make automake autoconf  glibc-devel pcre-devel glib2-devel gnutls-devel libgcrypt-devel libgpg-error-devel libtasn1-devel zlib-devel ncurses-devel readline-devel iptables-devel dbus-devel
rm -rf /home/nemo/Downloads/connman-*

# Then connecting it:

ctl=connmanctl
gadget=`$ctl services | grep gadget | cut -b 26- | tail -1`
$ctl config $gadget --ipv4 manual 192.168.2.11 255.255.255.0 192.168.2.12 --nameservers 208.67.222.222 208.67.220.220
$ctl connect $gadget

I guess I copied all that stuff together from other sources

The day we’ll have a *BSD mobile system, life will indeed change :slight_smile: we can keep dreaming …

Did you manage to make any usb-ethernet dongle work ? here none is detected :frowning: the reason I am trying with the usb rndis …

Thank you again @sebix I appreciate it, I will play with connmanctl and tell you if I manage to make it work with SFOS 4.3.
But meanwhile I found a hack that may be helpfull meanwhile, I share it. I connect to any wlan, then on the cli I just ifconfig wlan0 down, then i’m good, all the applications think that the wlan is on, and as the default gw is through my rndis, everything is working … it’s just a dirty hack till finding a more stable solution.

Any particular reason, why you should build connman from source instead of just installing the connman-tools package?

I don’t have a 10II, but on my XA2 the kernel does not ship with any of the vendor specific USB ethernet drivers. However it does include the cdc-ether module for devices which are implementing the CDC Ethernet protocol as specified in the USB standard.

Ethernet adapters based on the RTL8153 chip seem to be compatible (I tested with a TP-Link UE300).
In a quick test connman worked out of the box and native apps seems to work fine, android apps however did not (possibly fixable, but I did not do any further investigation).

I don’t remember the reasons any more. And they may not be valid any more as well.

Trying the package connman-ctl no success, the gadget usb is not shown, recompiling is still needed it seems.

Thank you very much @sigurg I ordered an RTL8153 adapter, will update here after receiving it.