Internet connection on Ubuntu is by Ethernet cable.
I want to connect two devices and share internet from Ubuntu to Samsung Galaxy Note Edge [SM-N915FY; android: 6.0.1] and Samsung Galaxy Note 9 [SM-N960F; android 10] by USB cable. I have read all previous topics about sharing internet, tired all but I have failed to share data.

In Connections - System Settings Module -> tab IPv4 changed method to Shared to other computers, but still not working.

Of course I've accepted permission to access by PC on phone.
There is no reverse tethering option on both Samsung Notes. Also tired to enable USB debugging.

  • It is probably quite a bit easier to check your router for DHCP options, and setting it up to provide "Internet" to the phones via wlan. – Hannu Aug 10 '20 at 16:32
  • as i mentioned before, i want to share internet via USB, not wireless. I know how to share internet wireless, but not via USB. – UMR Aug 21 '20 at 20:13
  • I have not heard of a single instance of sharing internet via USB. This probably requires a driver that supports such a connection, something that is unlikely to exist. Possibly available in the Android SDK as e.g. a debugging tool. – Hannu Aug 24 '20 at 12:16
  • @Hannu please try to be a bit more constructive. I just search for the same thing and this is the first post to come up. It's called USB OTG or GEther. It literally is ethernet over usb. If you can have a wifi dongle that plugs into the usb port, its only logical a usb cable can transfer information the same way. You can SSH into a raspberry pi zero using this technique as well. – shamelessApathy Sep 24 '20 at 9:56
  • Right, now the big question is; is there a driver that works for Ubuntu or any other linux? Please be more specific. – Hannu Sep 26 '20 at 7:41

I have a way but a little bit tricky. You are going to need:

  • Android with the "USB-PC internet share" option (not the classic USB tethering)
  • iptables or nftables (for masquerade/SNAT)
  • tcpdump
  • iproute2
  • a dns server on your linux (dnsmasq is quick to set up)

1/ On you android device: got to Settings >> Network connection >> Tethering and portable hotspot >> USB-PC internet share . Say ok or choose any OS suggested (usually different Windows versions), it does not matter as long as the functionnality is enabled. => now your smartphone is going to immediately try to connect to internet, but your Linux system is not yet ready. You will need to retrieve the folling information: the subnet and the default gateway you smartphone is going to use. This can be done with tcpdump

2/ On your Linux: use tcpdump to capture traffic from the USB network interface (enabled when USB PC internet share is activated from android). You are going to see a lot of whohas XXXX. This ip address is the default gateway you android is trying to reach. add this ip address and the correct subnetmask to the tethering interface (sudo ip address add XXXXX dev XXXX) or use network manager

3/ enable masquerading with iptables:

sudo iptables -A POSTROUTING -o usb_thethering_interface -j MASQUERADE

4/ make sure you dns server is working on the Linux.

Should work fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.