3

Connect your Samsung S7 via usb to your favorite linux machine. Goto 'Settings -> Connections -> mobile hotspot and Tethering' and enable "USB tethering".

Android will now enable tethering with the Linux host and Linux should consequently acquire an IP address from the phone. This is where it is broken. The proper network setup is never done to allow any IP connection with the phone itself.

The problem is that Samsung S7 send an invalid/broken Mac address: 00:00:00:00:00:00. And the Linux network stack does not operate with a 'zero' mac address at all.

It seems that this issue was introduced with with Samsung S7 (android 6.x and 7.x). My previous phones Samsung S4 and S5 are tethering without a problem.

I am running Fedora 24/25 with NetworkManager but any Linux will most likely expose the same issue.

PS: tethering with Win7-64 works


ifconfig -a
enp0s20u4: flags=4098<BROADCAST,MULTICAST>  mtu 1500
    ether 00:00:00:00:00:00  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

Mar  7 08:56:02 m3800 kernel: usb 1-4: New USB device found, idVendor=04e8, idProduct=6863
Mar  7 08:56:02 m3800 kernel: usb 1-4: New USB device strings: Mfr=3, Product=4, SerialNumber=5
Mar  7 08:56:02 m3800 kernel: usb 1-4: Product: SAMSUNG_Android
Mar  7 08:56:02 m3800 kernel: usb 1-4: Manufacturer: SAMSUNG
Mar  7 08:56:02 m3800 kernel: usb 1-4: SerialNumber: cexxxxxxxxxxxxxxxx
Mar  7 08:56:02 m3800 mtp-probe: checking bus 1, device 6: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-4"
Mar  7 08:56:02 m3800 mtp-probe: bus: 1, device: 6 was not an MTP device
Mar  7 08:56:02 m3800 kernel: [  127.774244] usbcore: registered new     interface driver cdc_ether
Mar  7 08:56:02 m3800 kernel: usbcore: registered new interface driver cdc_ether
Mar  7 08:56:02 m3800 kernel: [  127.777443] rndis_host 1-4:1.0 eth0: register 'rndis_host' at usb-0000:00:14.0-4, RNDIS device, 00:00:00:00:00:00
Mar  7 08:56:02 m3800 kernel: [  127.777466] usbcore: registered new interface driver rndis_host
Mar  7 08:56:02 m3800 kernel: rndis_host 1-4:1.0 eth0: register 'rndis_host' at usb-0000:00:14.0-4, RNDIS device, 00:00:00:00:00:00
Mar  7 08:56:02 m3800 kernel: usbcore: registered new interface driver rndis_host
Mar  7 08:56:02 m3800 kernel: [  127.781049] rndis_host 1-4:1.0 enp0s20u4: renamed from eth0
Mar  7 08:56:02 m3800 kernel: rndis_host 1-4:1.0 enp0s20u4: renamed from eth0
Mar  7 08:56:02 m3800 NetworkManager[876]: <info>  (enp0s20u4): carrier is OFF                                                      
Mar  7 08:56:02 m3800 NetworkManager[876]: <info>  (enp0s20u4): new Ethernet device (driver: 'rndis_host' ifindex: 3)               
Mar  7 08:56:02 m3800 NetworkManager[876]: <info>  (enp0s20u4): exported as /org/freedesktop/NetworkManager/Devices/2               
Mar  7 08:56:02 m3800 NetworkManager[876]: <info>  (enp0s20u4): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]                                                                                                                              
Mar  7 08:56:02 m3800 NetworkManager[876]: <error> [1488905762.697751] [platform/nm-linux-platform.c:2278] link_change(): Netlink error changing link 3:  <UP> mtu 0 (1) driver 'rndis_host' udi '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/net/enp0s20u4': Invalid address for specified address family
Mar  7 08:56:02 m3800 NetworkManager[876]: <info>  (enp0s20u4): preparing device
Mar  7 08:56:02 m3800 NetworkManager[876]: <info>      read connection 'Wired connection 1'
Mar  7 08:56:02 m3800 NetworkManager[876]: <info>  (enp0s20u4): created default wired connection 'Wired connection 1'
5
  • 2
    I'm voting to close this question as off-topic because this question belongs on Android Enthusiasts. Commented Apr 4, 2017 at 18:46
  • 2
    @SatoKatsura I'm not convinced this is an Android question (particularly given that tethering works with a Win10 endpoint). Commented Apr 4, 2017 at 20:17
  • @SatoKatsura This question is about interoperability between Linux and Android, so it's on-topic both here and on Android Enthusiasts. Commented Apr 4, 2017 at 23:37
  • @Gilles As far as I can tell the solution would involve leaving the Linux system alone, and editing some XML files on the phone to make it use a valid MAC, and / or upgrading some system component. I'd say that's 100% about Android, and 0% about Linux (or Windows, for that matter). shrug Commented Apr 5, 2017 at 6:00
  • Fixing the mac address bug on the Android is a PITA. I am sure it is possible. But you need most likely to 'root' the phone (another PITA). This here provides a solution easy managable. Best would be to get the fix upstream into rndis_host as this already fixes other 'broken' phones.
    – mattes
    Commented Apr 5, 2017 at 22:47

2 Answers 2

2

The Linux network stack does not work with interfaces that have a 'zero' MAC address. The tethering setup with the android phone just simply comes to a halt on the Linux side, when attempting to setup the network configuration.

The following works for me at this point, by setting up the interface and routes manually. I wrapped this up in a shell script:

# cat tetherS7_nwsetup.sh 

IFNAME=enp0s20u4
ip a add 192.168.42.2/24 brd + dev $IFNAME
ip link set dev enp0s20u3 address e8:2a:ea:01:02:03
ip link set dev $IFNAME up
route add default gw 192.168.42.129
echo "nameserver 8.8.8.8" >>/etc/resolv.conf

change IFNAME and enter your interface name. then excute:

# chmod +x tetherS7_nwsetup.sh 
# sudo ./tetherS7_nwsetup.sh 

For DNS I am currently using Google's DNS server. Feel free to change. Hope these steps work you.

1
  • It does not work. Galaxy S7 (Android 8.0)
    – gvd
    Commented Mar 25, 2020 at 21:12
1

For those that are familiar with building Linux or Linux modules in particular, here is another possible fix.

This adds a fix to the rndis_host linux module to correct the corrupted mac address and makes it again a plug and play solution for tethering.

Interestingly some one already added a workaround for 'messed up' mac address in rndis_host.c. Unfortunately it does not cover the case with the Samsung S7. I added the following lines:

   int
   generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
   {
      ...
      if (bp[0] & 0x02)
         eth_hw_addr_random(net);
      else
         ether_addr_copy(net->dev_addr, bp);

    // correct Samsung S7 'zero' mac address
    if ( (bp[0]==0) && (bp[1]==0) && (bp[2]==0) /*&& (bp[3]==0) && (bp[4]==0) && (bp[5]==0)*/ ) {
       // invalid mac address ==> generate one
       eth_hw_addr_random(net);
    }      
    // end of my fix

Now re-build the kernel module and replace it with the original 'rndis_host.ko.xz' and run 'depmod -a'. I suggest to reboot or at least remove the old module: 'rmmod rndis_host'

Hope this works for you. Now just plug in your Smamsung S7 and enable tethering. It should now load the new build rndis_host module and create the correct interface setup and the required routes automatically.

   # ifconfig enp0s20u3
   enp0s20u3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 192.168.42.253  netmask 255.255.255.0  broadcast 192.168.42.255
       inet6 fe80::f970:b67b:661f:254c  prefixlen 64  scopeid 0x20<link>
       ether 92:06:fe:75:9e:43  txqueuelen 1000  (Ethernet)
       RX packets 100  bytes 35951 (35.1 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 135  bytes 31911 (31.1 KiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

   # netstat -nr
   Kernel IP routing table
   Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
   0.0.0.0         192.168.42.129  0.0.0.0         UG        0 0          0 enp0s20u3
   192.168.42.0    0.0.0.0         255.255.255.0   U         0 0          0 enp0s20u3

Here a diff from what I patched:

   # diff -u rndis_host.c.ORIG rndis_host.c
   --- rndis_host.c.ORIG   2017-04-05 15:19:01.353765062 -0700
   +++ rndis_host.c        2017-04-05 15:18:37.327765272 -0700
   @@ -434,6 +434,13 @@
       else
            ether_addr_copy(net->dev_addr, bp);

   +//--------- correct Samsung S7 'zero' mac address -------------------------------------------------//
   +    if ( (bp[0]==0) && (bp[1]==0) && (bp[2]==0) /*&& (bp[3]==0) && (bp[4]==0) && (bp[5]==0)*/ ) {
   +        // invalid mac address ==> generate one
   +               eth_hw_addr_random(net);
   +    }      
   +//----- end of correction--------------------------------------------------------------------------//
   +
      /* set a nonzero filter to enable data transfers */
      memset(u.set, 0, sizeof *u.set);
      u.set->msg_type = cpu_to_le32(RNDIS_MSG_SET);

You must log in to answer this question.

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