We have moved to a new Sailfish OS Forum. Please start new discussions there.
2

Internet via ethernet/microusb

asked 2018-01-13 19:39:31 +0300

thoys gravatar image

Hello together,

i wanna make a feature request for as result of this Questions:

https://together.jolla.com/question/34747/does-jolla-support-ethernet-via-usb-to-ethernet-cable/

https://together.jolla.com/question/177658/internet-via-microusb/

It's a good feature if you can use internet on your mobilphone via LAN/Ethernet over microusb.

If you wanna use your phone in the basement, without good connection or in case u care about radiation and healthy, then you need this feature.

Thanks for makin it

Thoys

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
4

answered 2018-01-15 15:12:16 +0300

DrYak gravatar image

Using a laptop/PC/Raspberry Pi, it's possible to do it on any Sailfish powered device, including older devices like the Jolla 1 which lack actual OTG support. The name of this class of access is called Reverse Tethering.

There's currently NO nice user-friend interface to help automate the manipulations.

On the other hand, as Sailfish is basically a full blown GNU/Linux under the hood, any HOWTO explaining how to do it on the command-line should do (ArchLinux and Ubuntu Ask tend to have nice and clear one).

Basically, you want to do two things :

Networking on the phone

  • First you need to connect the phone in Developer Mode (it shows up as a USB Networking device to the PC).
  • Then, either by using a terminal on the phone, or using SSH ( <- if you have SSH keys, you can even automate this ) you need to add the PC as a default route :
  • For IPv4:

    ip -4 route add default via 192.168.2.1 dev rndis0 metric 10 protocol static
    

    replace 192.168.2.1 with IP address of the PC side of the connection, it might be a higher number if you use DHCP (e.g.: 192.168.2.13)

  • For IPv6, if your laptop actually support masquerading it:

    ip -6 route add default via fe80:: dev rndis0 metric 10 protocol static
    

    replace fe80:: with the actual link-local random IPv6 of the PC side of the connection that was randomly generated upon pluging up. (e.g.: fe80::15d8:83f2:8d62:d74b)

Masquareding on the PC

  • You need to enable IP forwarding and Masquerading
  • Usually, most distro will have user-friendly tools (e.g.: Suse has SuseFirewall, RedHat/CentOS have firewalld, Ubuntu has Uncomplicated Firewall, other might use Shorewall, etc.)
  • Generally, in a user friendly firewall, you can simply assign the ethernet port to some 'external' group, assign the USB Networking to 'internal' group, and enable masquerading between the two.
  • The not user friendly solution :

    echo "1" > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -o rndi0 -j MASQUERADE
    

    Where rndis0 is the name of the USB Network device as seen on the PC. (Modern distro might assign instead static names like enp0s29u1u6i7

  • It is also possible to assign an actual internet-routable IPv6 address to an internal network (if you treat it as a subnetwork with a "longer-than-64bits prefix", with a statically assigned "less than 64bits" suffix, and play around with ndpproxy :

    ip -6 neigh add proxy 2001:: dev rndis0
    

    Where 2001::should be the actual static address that you assign to the smartphone, and rndis0 is the name of the USB interface on the PC.

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
3 followers

Stats

Asked: 2018-01-13 19:39:31 +0300

Seen: 898 times

Last updated: Jan 15 '18