RaspberryPi LTE-Failover Router With DNS Caching
Apparently Windows has a problem resolving hosts when you tether from Mobile HotSpot.
The solution is to build a DNS-Caching router that tethers off the smartphone. This takes advantage of Android's ability so transparently fail-over to LTE when residential internet service goes down.
This solution also takes advantage of the RaspberryPi's incredibly low price, the fact that LineageOS will run on cheap old phones that are no longer supported by the mfgr, and the fact that GoogleFi will ship you a data-sim for free.
For instance, I just bought a brand-new, open-box Pixel phone for $85, and presumable the MotoX4 can also be had for next to nothing.
- RaspberryPi running Arch Linux Arm
- Old Android Phone Running LineageOS
- Free Data Sim Card From GoogleFi
Personally I would
- secure the ssh server
- generate and configure the locale
- remove the default root password, and default user
- write your preferred hostname in
- configure your preferred timezone:
ln -sf /usr/share/zoneinfo/<Zone>/<SubZone> /etc/localtime
Additionally, the router won't be accessible for administrative tasks when it is behind the Android Tether ; for this I would use a wireguard vpn.
Configure The Router.
The entire configuration of the router consists of two
interface definitions, as well as
systemd-resolved is no use to us because it only listens on localhost.
# disable systemd-resolved systemctl stop systemd-resolved systemctl disable systemd-resolved unlink /etc/resolv.conf
/etc/resolv.conf, write your nameservers and options in a real
# the default timeout of 5 seconds is too slow options timeout:1 # nameserver when connected to lan nameserver 192.168.1.1 # nameserver when connected to mobile network nameserver 22.214.171.124
Interface Definitions For
I believe the usb interfaces are numbered 1-4,
so either be careful which one you use, or maybe a wildcard name
will work, i.e.
# uplink # /etc/systemd/network/usb0.network [Match] Name=usb0 [Network] DHCP=yes DNSSEC=no IPForward=yes
# downlink, ethernet cable # /etc/systemd/network/eth0.network [Match] Name=eth0 [Network] Address=10.12.34.1/24 DHCPServer=yes IPForward=yes IPMasquerade=both
and enable it
systemctl enable dnsmasq.
# /etc/dnsmasq.conf resolv-file=/etc/resolv.conf interface=eth0 no-dhcp-interface=eth0
Plug in the Android Phone, reboot the RaspberryPi, and when it comes back up toggle on the USB tether on the Android Phone.
Plug ethernet cable into Windows Computer, open CMD prompt and type
ping google.com to test connectivity and name resolution. Or on a
Linux computer type
ping -c 3 google.com.
Alternate DHCP Service
You can use
dnsmasq for DHCP Service instead of
# downlink, ethernet cable # /etc/systemd/network/eth0.network [Match] Name=eth0 [Network] Address=10.12.34.1/24 # DHCPServer=yes IPForward=yes IPMasquerade=both
# /etc/dnsmasq.conf resolv-file=/etc/resolv.conf interface=eth0 # no-dhcp-interface=eth0 dhcp-range=10.12.34.50,10.12.34.150
- examples in
- Man Page
Use With Multiple Computers
Just add an unmanaged switch.
Wifi Instead of Ethernet
Use downlink definition for
wlan0 instead of
# /etc/hostapd/hostapd.conf interface=wlan0 hw_mode=g channel=7 wmm_enabled=0 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP ssid=NETWORK wpa_passphrase=PASSWORD