Post

Cellular Failover with Android and a Raspberry Pi

The great CenturyLink outage of late 2018 is under way. At the time of this writing, we’re 16.5 hours in, and I’m tired of using my Android phone as a Wi-Fi hotspot. I want my network back up.

Fortunately, I have some tools to work with. I have a spare Android phone complete with an unlimited data plan (T-mobile ran a 3rd line for free promo a couple years ago) and a spare Raspberry Pi (seriously who doesn’t have several of those kicking around). The idea here is that we can use the Raspberry Pi to turn that USB cell phone tether into ethernet, so our router can treat it basically like a modem.

In my setup, I have a WAN2 port on my Ubiquiti UniFi Secure Gateway. If WAN1 goes down, the USG will automatically flop over to WAN2.

Guide

Infosec is a huge blind spot of mine. I’m nowhere close to competent with Linux. Exposing a Pi to the internet is scary to me. Proceed with caution.

Set up Rasbian

  1. Download Raspbian Lite.
  2. Write it to an SD card with a tool like Etcher.
  3. Once it’s done, eject and reattach the SD card so your OS will mount /boot.
  4. Grab this zip, and unzip the two files.
  5. From the .zip, drop ssh into /boot, which wil enable SSH on the Raspberry Pi.
  6. Optionally, you can also drop wpa_supplicant.conf into /boot, and edit the file with your WPA2 SSID and passphrase (you can skip this step if you are just gunna configure it with Ethernet).

Configure the Bridge

  1. Plug everything in.
  2. Enable USB tethering on your Android phone.
  3. SSH into your Raspberry Pi.
  4. Change the password:
    1
    
    passwd
    
  5. If you want to check and ensure that the Raspberry Pi sees your phone, run:
    1
    
    dmesg | tail
    
  6. If you want to be sure that usb0 shows up, run:
    1
    
    ifconfig
    
  7. Install brctl (hilariously, this should work because you have WAN via usb0):
    1
    
    sudo apt-get install bridge-utils
    
  8. Create the bridge:
    1
    
    sudo brctl addbr bridge0
    
  9. Add usb0 and eth0 to the bridge:
    1
    2
    
    sudo brctl addif bridge0 eth0
    sudo brctl addif bridge0 usb0
    
  10. Enable the bridge:
    1
    
    sudo brctl stp bridge0 on
    
  11. Configure the WAN2 interface on your router or firewall to DHCP. You may also want to set DHCP to use Google or Cloudflare.
This post is licensed under CC BY 4.0 by the author.