Looking for tethering HOW-TO

All Linux talk goes here. Technical talk. No Distro politics, please use the "General" forum for that
Post Reply
Tony0945
Pornography Historian
Posts: 79
Joined: Tue Mar 23, 2021 9:01 pm

Looking for tethering HOW-TO

Post by Tony0945 »

My ISP went down yesterday when I needed e-mail badly for a house sale.
This is why I don't opt for "paperless" billing.

I do have a Samsung S2 Android smartphone that has LAN access (permanently assigned to 198.168.0.185, I use it for photo transfer).

I'm looking for a guide to tethering to a Gentoo OpenRC netifrc system. Can anyone help?
User avatar
Henry Crunn
Site Admin
Posts: 395
Joined: Fri Dec 18, 2020 2:04 pm
Location: 56N 3W

Re: Looking for tethering HOW-TO

Post by Henry Crunn »

You need

Code: Select all

CONFIG_USB_USBNET=m
and some or all of

Code: Select all

CONFIG_IPV6_NDISC_NODETYPE=y
CONFIG_USB_NET_RNDIS_HOST=m
# CONFIG_USB_NET_RNDIS_WLAN is not set
CONFIG_USB_F_RNDIS=m
CONFIG_USB_ETH_RNDIS=y
The NDIS prompts mention Windows but Android expects to connect to Windows.
This will get you a new interface called usb0 unless udev trashes the name. Check dmesg if it does.

Check the data and time in

Code: Select all

uname -a
if you had to rebuild your kernel.

Stop all your other network interfaces or you are going to get too many default routes.

Point dhcpcd to whatever your new USB interface is called

Code: Select all

dhcpcd usb0
Busybox has udhcpcd, if you don't have dhcpcd installed already.

That should get you an IP address and a default route over usb0.

-- Edit --

Carriers can and do detect tethering. A few block it completely, others want you to pay extra. Read the fine print if it won't work.
The phone may need you to set the USB port to tethering, or whatever its called in your Android version.
--
You can't get the wood.
You can't get the 'shiver me timbers' wood' you know.
Tony0945
Pornography Historian
Posts: 79
Joined: Tue Mar 23, 2021 9:01 pm

Re: Looking for tethering HOW-TO

Post by Tony0945 »

Rebuilt the kernel as prescribed. Created /etc/init.d/net.usb0 as a symlink to /etc/init.d/net.lo.
Removed net.eth0 from the boot level.

Code: Select all

~ $ uname -a
Linux Casti 5.10.27-gentoo #3 SMP PREEMPT Sun May 2 12:25:48 CDT 2021 x86_64 AMD Phenom(tm) II X6 1090T Processor AuthenticAMD GNU/Linux

rebooted and ran my "loadall-modules" script to try and load every module. I'm running old open-rc where you have to list all modules.
Result:

Code: Select all

~ # service net.usb0 start
net.usb0         | * Bringing up interface usb0
net.usb0         | *   ERROR: interface usb0 does not exist
net.usb0         | *   Ensure that you have loaded the correct kernel module for your hardware
net.usb0         | * ERROR: net.usb0 failed to start
I had booted with the phone plugged into a usb3 port. Stupid question: Should the phone be connected to the internet before running "service net.usb0 start"?
Pastebin of config is here: https://dpaste.com/5RR28QVCM
User avatar
Henry Crunn
Site Admin
Posts: 395
Joined: Fri Dec 18, 2020 2:04 pm
Location: 56N 3W

Re: Looking for tethering HOW-TO

Post by Henry Crunn »

The phone needs to be in tethering mode is all.

Unlock the phone, connect it to the PC and it should pop up a "what do you want to do with the USB link" dialogue.
I get
File Trasfer
USB Tethering
MIDI
PTP
No Data Transfer, which is the default.

Choose USB Tethering and bring up usb0 on the PC. Let me compare our kernel .config files and confirm that mine still works.

-- edit --

My tethering is broken now. It looks like the kernel config has changed since I used it last, a few years ago.
--
You can't get the wood.
You can't get the 'shiver me timbers' wood' you know.
User avatar
Henry Crunn
Site Admin
Posts: 395
Joined: Fri Dec 18, 2020 2:04 pm
Location: 56N 3W

Re: Looking for tethering HOW-TO

Post by Henry Crunn »

The following modules ore required

Code: Select all

rndis_host             16384  0
cdc_ether              16384  1 rndis_host
usbnet                 28672  2 rndis_host,cdc_ether
That gets usb0. Then usb0 behaves like a normal interface. Well it used do.
Wiresdark shows me packets going out but my phone no longer responds.

Without the phone responding to dhcpcd requests, its game over.
I'll try on another system but probably not tonight.

-- edit --

OK, I lied. On a 64 bit Pi,

Code: Select all

[860396.928955] rndis_host 1-1.3:1.0 enp1s0u1u3: renamed from usb0
udev rips udev0 head off.

Then dhcpcd works.

Code: Select all

# dhcpcd enp1s0u1u3
dhcpcd-9.4.0 starting
DUID 00:01:00:01:1e:90:5c:60:ca:5f:b8:ee:c0:6b
enp1s0u1u3: waiting for carrier
enp1s0u1u3: carrier acquired
enp1s0u1u3: IAID 27:1e:27:51
enp1s0u1u3: adding address fe80::8db9:58a9:8d6c:21ab
enp1s0u1u3: soliciting an IPv6 router
enp1s0u1u3: soliciting a DHCP lease
enp1s0u1u3: offered 192.168.42.100 from 192.168.42.129
enp1s0u1u3: probing address 192.168.42.100/24
enp1s0u1u3: leased 192.168.42.100 for 3599 seconds
enp1s0u1u3: adding route to 192.168.42.0/24
enp1s0u1u3: adding default route via 192.168.42.129
forked to background, child pid 14676

The routing table is in a mess

Code: Select all

route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.100.253 0.0.0.0         UG    2      0        0 eth0
default         192.168.42.129  0.0.0.0         UG    1004   0        0 enp1s0u1u3
192.168.42.0    0.0.0.0         255.255.255.0   U     1004   0        0 enp1s0u1u3
192.168.100.0   0.0.0.0         255.255.255.0   U     2      0        0 eth0
as I'm testing using ssh over eth0.

But now I know the settinigs for a static setup on the PC. Which works too.

-- edit --

Code: Select all

Static_Dev /etc/init.d # ifconfig usb0 192.168.42.42
Static_Dev /etc/init.d # ping 192.168.42.129
PING 192.168.42.129 (192.168.42.129) 56(84) bytes of data.
64 bytes from 192.168.42.129: icmp_seq=1 ttl=64 time=6.48 ms
64 bytes from 192.168.42.129: icmp_seq=2 ttl=64 time=3.54 ms
64 bytes from 192.168.42.129: icmp_seq=3 ttl=64 time=1.04 ms
^C
--- 192.168.42.129 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.038/3.685/6.475/2.221 ms
Oh, I'm a twit or was having a senior moment.
My main PC has a static setup for IPv4 and uses dhcpcd only for IPv6, so it was doomed to fail.
I already knew that the phone is IPv4 only over tethering and WiFi hotspot.
--
You can't get the wood.
You can't get the 'shiver me timbers' wood' you know.
Tony0945
Pornography Historian
Posts: 79
Joined: Tue Mar 23, 2021 9:01 pm

Re: Looking for tethering HOW-TO

Post by Tony0945 »

Code: Select all

asti ~ # zgrep rndis_host /proc/config.gz
Casti ~ # zgrep cdc_ether /proc/config.gz
Casti ~ # zgrep usbnet /proc/config.gz
Casti ~ # 
The actual CONFIG_ 's must have a different name.

When I plugged the S2 in lsub showed a GOOGLE device. When I plugged my flip-phone in I got a ZTE device on the same port.

I'll have to research those modules to find the config.

Duh! or learn to pass -i

Code: Select all

Casti ~ # zgrep -i usbnet /proc/config.gz
CONFIG_USB_USBNET=m
Casti ~ # zgrep -i rndis_host /proc/config.gz
# CONFIG_USB_NET_RNDIS_HOST is not set
Casti ~ # zgrep -i cdc_ether /proc/config.gz
Casti ~ # zgrep -i usbnet /proc/config.gz
CONFIG_USB_USBNET=m
Tony0945
Pornography Historian
Posts: 79
Joined: Tue Mar 23, 2021 9:01 pm

Re: Looking for tethering HOW-TO

Post by Tony0945 »

Code: Select all

Casti ~ # locate cdc_ether |grep modules
/lib64/modules/5.10.27-gentoo/kernel/drivers/net/usb/cdc_ether.ko
Well, whatever CONFIG did it, it's built!
Now to test.
Tony0945
Pornography Historian
Posts: 79
Joined: Tue Mar 23, 2021 9:01 pm

Re: Looking for tethering HOW-TO

Post by Tony0945 »

Added ro /etc/conf.d/modules:

Code: Select all

#modules for tethering
modules+=" rndis_host cdc_ether usbnet "
looks good. excerpt from lsmod:

Code: Select all

Casti ~ # lsmod |grep rndis
rndis_host             16384  0
cdc_ether              16384  1 rndis_host
usbnet                 36864  2 rndis_host,cdc_ether
Full lsmod: https://dpaste.com/3QVCX8ETA
lsusb: https://dpaste.com/D94X5HFFG
ifconfig: https://dpaste.com/3LK7R78HH
dmesg : https://dpaste.com/CLL5FRVET
Booted with the S2 attached and connected to the internet
I think some udev magic is needed.
Tony0945
Pornography Historian
Posts: 79
Joined: Tue Mar 23, 2021 9:01 pm

Re: Looking for tethering HOW-TO

Post by Tony0945 »

All the on-line guides to put the S2 into tethering mode call out prompts that aren't on my S2.
Android 4.0.4 should do this. Maybe I have to talk with my provider.

Does the computer seem set up anyway?
User avatar
Henry Crunn
Site Admin
Posts: 395
Joined: Fri Dec 18, 2020 2:04 pm
Location: 56N 3W

Re: Looking for tethering HOW-TO

Post by Henry Crunn »

When the phone sees the PC on the USB port, it will default to charging only.
For other things, you need to set what you want it to do.

If you ale logged into the phone when you plug it in, my phone pops up an alert. Tapping on the alert takes me directly to the USB menu.
--
You can't get the wood.
You can't get the 'shiver me timbers' wood' you know.
Post Reply