You were never here, you didn't see anything..

Gentoo & Android USB Tethering


Today I had a lot of time to kill and a netbook and Android phone on hand. Mainly due to having taken the kid to an anime convention… After working for a long while on getting OpenVPN working on my Ubiquiti Edgerouter Lite (link coming soon) I needed something new to work on. Enter USB tethering.

Until today I had little interest in it. I used WiFi tethering regularly as I figured it was sure to be far easier that USB tethering. Today I was a bit more inspired to look in to this as I fired up kismet and say over 1000 stations active and at least two guys running similar tools. Nothing like exposing your phone (and other devices) to hackers. Upon digging it started to look rather straight forward so I gave it a shot. Success on the first go, I even already had the kernel modules laying around.

First the required kernel modules:

CONFIG_USB_USBNET=m
CONFIG_USB_NET_CDCETHER=m
CONFIG_USB_NET_RNDIS_HOST=m

You can either build them in or as modules. I prefer modules, I don’t favor things I don’t need hanging around waiting to be used.

Next plug in your phone and activate USB Tethering. For my device that was under “Settings” -> “More” -> “Tethering & portable hotspot” -> “USB tethering”. Simple little check box. Upon turning this on check for the device using dmesg, you should see something similar to:

[ 3760.324670] usbcore: registered new interface driver cdc_ether
[ 3760.332303] rndis_host 1-3:1.0 usb0: register 'rndis_host' at usb-0000:00:1d.7-3, RNDIS device, 72:fc:a3:db:0a:21
[ 3760.334443] usbcore: registered new interface driver rndis_host
[ 3543.858466] systemd-udevd[3131]: renamed network interface usb0 to enp0s29f7u3
[ 3760.349295] systemd-udevd[3433]: renamed network interface usb0 to enp0s29f7u3

As one can see in the above, I have a new network device with the name “enp0s29f7u3”. Doesn’t one love the new “consistent network device names”?

This device can be configured like any other network interfaces. Add the appropriate lines to /etc/conf.d/net :

config_enp0s29f7u3="dhcp"
dhcpcd_enp0s29f7u3="-L"

Create a symlink to the service file:

ln -s /etc/init.d/net.lo /etc/init.d/net.enp0s29f7u3

Then you can start the service:

rc-service net.enp0s29f7u3 start

If all goes well you will be rocking on-line:

net.enp0s29f7u3 | * Caching service dependencies ... [ ok ]
net.enp0s29f7u3 | * Bringing up interface enp0s29f7u3
net.enp0s29f7u3 | * dhcp ...
net.enp0s29f7u3 | * Running dhcpcd ...
net.enp0s29f7u3 |dhcpcd[3755]: version 6.2.0 starting
net.enp0s29f7u3 |dhcpcd[3755]: all: IPv6 kernel autoconf disabled
net.enp0s29f7u3 |dhcpcd[3755]: enp0s29f7u3: IPv6 kernel autoconf disabled
net.enp0s29f7u3 |dhcpcd[3755]: DUID xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
net.enp0s29f7u3 |dhcpcd[3755]: enp0s29f7u3: IAID xx:xx:xx:xx
net.enp0s29f7u3 |dhcpcd[3755]: enp0s29f7u3: soliciting a DHCP lease
net.enp0s29f7u3 |dhcpcd[3755]: enp0s29f7u3: offered 192.168.42.165 from 192.168.42.129
net.enp0s29f7u3 |dhcpcd[3755]: enp0s29f7u3: leased 192.168.42.165 for 3600 seconds
net.enp0s29f7u3 |dhcpcd[3755]: enp0s29f7u3: adding route to 192.168.42.0/24
net.enp0s29f7u3 |dhcpcd[3755]: enp0s29f7u3: adding default route via 192.168.42.129
net.enp0s29f7u3 |dhcpcd[3755]: forked to background, child pid 3810 [ ok ]
net.enp0s29f7u3 | * received address 192.168.42.165/24 [ ok ]
net.enp0s29f7u3 | * Running postup ...

The main reason this came to mind for security reasons, USB is non-RF. So instead of exposing the link to hackers it is tucked away in the USB cable. Yes, there are ways to hack this and your cell signal, but most people and even most hackers carry the gear required for that!

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This blog is kept spam free by WP-SpamFree.

Most who fail…

Most who fail have yet to really try!