Authors: Mohsen Banan — Date: <2022-02-19 Sat 19:51> — Last Updated: <2022-02-22 Tue 10:53>
Given:
- A Mobile Phone
- A USB Cable
- A Laptop or a Raspberry Pi (OurRouter)
- A plain Debian Linux distro (Debian-11)
- An ethernet switch
we create a Wide-Area-Wireless Mobile LAN.
- Scope
- Uses
- Do It Yourself (DIY) And As A BISOS General Purpose Server Appliance (BISOS-GPSA)
- Main Steps
- Tethering To Mobile Phone
- Ethernet/Network interface naming — SNPA-Ids (Subnetwork Point-Of-Attachement Identifiers)
- Create a minimal LAN
- Install, configure and test dhcpd on OurRouter
- Enable IPForwarding On OurRouter
- Setup NAT On OurRouter
- Keep Alive Traffic On The phoneSnpa
- End-to-End testing
- Making It All persistent
- IPForwarding General Purpose Server Appliance — IPForwarding-BISOS-GSPA
- Add-Ons Considerations
We also create a LAN. This is about providing access to the phone’s data connectivity by all hosts on a LAN.
Here we create our own router from scratch. We don’t add a phone to an existing router. The scope of this document includes creation of a router on top of Debian Linux.
There are manu uses for USB tethered mobile phone linux router, including:
- A secondary WAN router to be used as a spare
- A Failover router
- A Mobile LAN. Say inside of an RV or a Boat.
The information in here is provided as DIY instructions. We are assuming that you are hip with Linux/Unix and that you can run with basic instructions and hints.
In parallel with these DIY instructions, the equivalent of these capbilities are also available as a plug and play BISOS Appliance. But this document is primarily geared towards the DIY model.
As of 2022, tethering to mobile phones is quite reliable with Linux. We used an Android phone provisioned over T-Mobile in the US. To tether to mobile phone:
- Plug USB cable into platform hardware
- On Mobile Phone: Settings->Tehtering->USB Tethering
- On Mobile Phone: Follow prompts
- On our router: “ip a” should show you the link — something like “/dev/usb0”
- Local side of the usb phone link would be something like 192.168.42.102 — the 102 is phone’s dhcp assignment.
- Remote side of the usb phone link would be something like 192.168.42.129
- Verify end-to-end connectivity by pinging say 8.8.8.8
If that wroks, tethering to mobile phone is in place.
Through out the rest of this document we will be reffering to device interfaces in a generic fashion. The phone USB device – typically /dev/usb0 – will be called “phoneSnpa”. The LAN device – typically something like /dev/enp3s0 – will be called “lanSnpa”.
Setup a minmal LAN with two hosts. Let’s call it “OurLan” with OurRouter and a “TestingHost” on the lanSnpa.
To install the dhcp server
sudo apt-get install isc-dhcp-serverThen configure a minimal dhcpd server.
Relevant BISOS ICMs (Interactive Command Modules) at https://github.com/bisos/bsip4/tree/master/bin are:
lcaDhcpServerBinsPrep.sh
svcDhcpSysdAdmin.shPlug the testing-host on our-lan, verify that it got the right values from our-router.
echo 1 > /proc/sys/net/ipv4/ip_forwardOn OurRouter we are now going to setup a traditional NAT (Network Address Translation).
phoneSnpa="/dev/usb0"
lanSnpa="/dev/enp3s0"
/sbin/iptables -t nat -A POSTROUTING -o ${phoneSnpa} -j MASQUERADE
/sbin/iptables -A FORWARD -i ${phoneSnpa} -o ${lanSnpa} -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i ${lanSnpa} -o ${phoneSnpa} -j ACCEPTWhen there has been no traffic on the phoneSnpa link, the phone drops the usb connection.
To maintain the link, periodically we generate small amounts of traffic on the phoneSnpa. A simple ping seems to be sufficient.
With these in place, you can now ping a remote host from the testing-host. So, on testing-host try “ping 8.8.8.8”.
You now have yourself a usb Tethered Mobile Phone Linux Router.
These DIY instructions do not include information about making it all be persistent. You can do that on your own, or better yet use the IPForwarding-BISOS-GSPA.
To setup your BISOS IPForwarding General Purpose Server Appliance:
- Decide on whether you want a physical or a virtual appliance.
- Bootstrap a generic BISOS platform.
- Obtain the IPForwarding-BISOS-GSPA-BPO (ByStar Portable Object) and enhance the BISOS platform to a IPForwarding-BISOS-GSPA platform.
- Configure your IPForwarding-BISOS-GSPA platform using supplied Blee-Panels
- Save your specific configuration platform in your own BPO.
- You can then reproduce your pre-configured IPForwarding-BISOS-GSPA with your own BPO.
A usb Tethered Mobile Phone Linux Router, can be more than just that. Here are some additions to consider.
OurRouter’s hardware platform usually includes WiFi capabilities. And when it does not, it can easily be added. So, we can turn OurRouter into a WiFi access point as well. At that point we have have the equivalent of Wifi-tethering plus wired LAN access plus full control.
Here are some relevant links for doing that:
https://github.com/morrownr/USB-WiFi http://www.linuxintro.org/wiki/Set_up_a_hotspot_with_Linux https://www.how2shout.com/how-to/2-ways-to-create-wifi-hotspot-in-ubuntu-20-04-lts-focal-fossa.html https://developer.toradex.com/knowledge-base/wi-fi-access-point-mode https://www.cyberciti.biz/faq/debian-ubuntu-linux-setting-wireless-access-point/ https://wiki.lm-technologies.com/linux-wifi-access-point-wireless-ap/
The usb tethered mobile phone can be considered an additional WAN link for an existing router.