2

I turned on "USB tethering" on an Android phone with mobile service, and connected the phone to a Linux computer using a USB cable.

On the computer,

  • which network interface is used for connection to the network created by "USB tethering" of the phone?

  • Is it automatically connected to the network, or shall I run some command? If former, Why don't I have internet connection on the computer?

Note that I have turned down the wireless interface. Thanks.

$ sudo ifconfig wlp5s0 down  
$ sudo iwconfig
lo        no wireless extensions.

enp4s0    no wireless extensions.

wlp5s0    IEEE 802.11  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=22 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          
enp0s20f0u3  no wireless extensions.


$ sudo ifconfig
enp4s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 20:47:47:73:02:6e  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 31812  bytes 2845669 (2.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 31812  bytes 2845669 (2.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

1 Answer 1

3

At least with my Sony Xperia 5 III and Debian 11, the phone appears as network interface usb0, using the rndis_host driver.

The rndis_host driver module depends on other modules, named cdc_ether, usbnet and mii.

The network interface name usb0 may be caused by the fact that Debian by default adds a /lib/systemd/network/73-usb-net-by-mac.link file, which tells USB network interfaces to use a name based on MAC address (enx112233445566)... but at least some phones will not present a fixed MAC address through the RNDIS interface, but instead the driver will assign a random MAC. As a result, udev won't get the ID_NET_NAME_MAC attribute, and so the classic kernel-based name usb0 will remain.

Other distributions may use a device-path-based name like enp0s20f0u3 instead; this might be less than optimal, as the path may vary depending on which USB port was used to connect the phone tether and how many other USB devices are currently connected.

So, the answers to your questions:

which network interface is used for connection to the network created by "USB tethering" of the phone?

The name may vary by Linux distribution and phone model: it might be usb0, it might be a MAC-based name like enx112233445566, or it might be a path-based name like enp0s20f0u3.

Is it automatically connected to the network, or shall I run some command? If former, Why don't I have internet connection on the computer?

This cannot be answered definitively without knowing more about the Linux distribution you're using and the specific configuration of your computer. Is your system configured to attempt to autoconfigure hot-plugged network interfaces by DHCP? Will it autoconfigure unusual interface names like usb0?

Note that sudo ifconfig without any options will only show active and configured network interfaces; you'll need sudo ifconfig -a to see unconfigured ones too.

The output of sudo iwconfig indicates your system currently has an unconfigured USB-based network interface enp0s20f0u3. It might be your phone. If you are using NetworkManager, you might only need to configure a connection for it: set it to use DHCP and connect automatically, possibly even with the "All users may connect to this network" checked, so it becomes a system-wide network connection instead of one that's available only when your user account is logged in.

If you are using some other network configuration subsystem, you may need to likewise configure it to auto-connect. Connecting to a new network can be a security-sensitive action, so your system may default to not automatically connecting previously unknown hot-plugged network interfaces, in order to provide a degree of protection from Evil Maid-type attacks to systems that are supposed to stay air-gapped.


Also, different versions of the RNDIS USB network interface use somewhat different USB device class identifiers. Before about May 2018, the kernel knew about three possible ways to identify a RNDIS network interface on a USB device; in May 2018, a fourth way was added, and apparently newer Android devices prefer to use the newest way.

So if your kernel is older than that, the low-level usbnet and cdc_ether kernel modules might not include the code to detect USB interface class "miscellaneous", subclass 4, protocol 1 as a RNDIS USB network interface, resulting in a failure to load the correct rndis_host USB networking protocol module when plugging in the phone in tethering mode. In this case, the network interface may not be detected at all.

(I remember this because I had to backport a kernel patch that fixed this, to a system that needed to tether a new Android phone and could not accept a kernel upgrade until a particular application was updated... long story.)

3
  • Thanks. Does enp0s20f0u3 appear as a wired or wireless network interface to the Linux computer? if wired, why does sudo iwconfig, which only shows wireless network interfaces, show it?
    – Tim
    Commented May 26, 2022 at 2:48
  • I was also wondering if you could take a look at unix.stackexchange.com/questions/703502/…. Thanks.
    – Tim
    Commented May 26, 2022 at 2:58
  • sudo iwconfig shows all interfaces, including your enp4s0 and the loopback interface lo, so your theory that it shows only wireless interfaces is clearly not correct. If the interface is not wireless, it shows the text no wireless extensions. This suggests the wireless interfaces were initially developed as extensions to a regular wired interface API, and perhaps the developer wanted to list all interfaces to see if the presence/absence of wireless extensions can be correctly detected... and never felt the need to change that behavior.
    – telcoM
    Commented May 26, 2022 at 8:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .