I am working on passing through the internet from my computer to my phone (running Android) over USB. I'm not sure how to achieve this, but I know I will need a usb network interface, such as usb0. This interface is not automatically created when plugging in the phone.

How do I create this USB network interface? Can this be done within Linux or must it be done from the Android phone?

Note: If I enable USB tethering on the phone, then a corresponding USB interface is created in Linux. However this is automatically configured to use the phone as a network device (or a gateway?) and pass the internet from my phone to my computer, which is the opposite of what I'm trying to do.

  • Are you done with this thing? Please, I was eagerly waiting for something like this in Linux/Unix! Please respond. – Am_I_Helpful Feb 19 '15 at 19:19
  • 1
    @shekharsuman Unfortunately, I was never able to get this to work and have given up on it. – drs Feb 19 '15 at 19:21
  • @drs-Nevertheless, you tried at least such an awesome concept. You've provided me a very good project to work on. Really thanks. I'll start working on this coming June. THANKS A LOT. – Am_I_Helpful Feb 19 '15 at 19:23

Actually USB tethering creates a symmetric connection between your phone and PC. The direction your traffic can go is only defined by the network interface configuration and the services running on each side.

In order to let the traffic go from the phone to the PC, you could (for example):

  • configure your PC to run DHCP and share its internet connection
  • activate USB tethering on your android phone:
  • run a dhcp client on your android phone (as root):

netcfg usb0 dhcp


dhclient usb0

Different phones may have different names for the interface, including rndis0, rmnet0 etc. Those can be discovered via ifconfig.

In case of problems, it may also be worth a try to load the g_ether kernel module on your phone manually.


Well, I can share with you my experience:

On the phone (Samsung J1 (Android 5.1.1) rooted): Active Developer Options >> Active USB Debugging >> I am going to Anchorage to network and Portable and active zone Anchorage (sorry for the translation, I'm from Cuba) to USB network >> When I do this I open the Virtual Terminal emulator (an apk) and I access as root (su) and I check the network interfaces with ifconfig , which returns a "new" interface called rndis0 and with IP

On the PC with Debian: I open the terminal and I access as root (only to not have to be putting sudo every time) >> ifconfig and it returns a "new" interface called usb0 with IP

If you ping from the phone to the PC and vice versa and everything should be ok (I get answers in the two sides), now it's time to give the phone a gateway, so in the terminal emulator from the phone: route add default gw dev rndis0 >> putting here the IP of the PC At this point you should be able to ping the Google DNS (both by IP and by name) from the terminal emulator and if your internet connection doesn't need a proxy server configuration you have internet in your phone via USB cable...

PS: If your PC and phone don't take IP automatically use this:

On PC:

ifconfig usb0 netmask
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -j MASQUERADE  

On phone:

ifconfig rndis0 netmask
busybox route add default gw dev rndis0

And configure the DNS (still phone):

mount -o remount, rw /system
echo 'nameserver' > /system/etc/resolv.conf
mount -o remount, ro /system
iptables -t nat -I OUTPUT 1 -p udp --dport 53 -j DNAT --to-destination 

Android 8.0

ifconfig usb0 netmask
ndc network create 9792
ndc network interface add 9792 usb0
ndc network route add 9792 usb0
ndc resolver setnetdns 9792
ndc network default set 9792

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.