supervacuo.com

c v t

DIY LTE Router

11 May 2020

If you have a portable LTE hotspot, a computer (old laptop, media PC, single-board system) and a WiFi router or access point of any kind, then let's set up a DIY network that's:

Fast:

  • Even on a cheap LTE hotspot indoors, I get 20-50 Mbit download, 10-30 Mbit upload

  • That's faster than any ADSL available here, and comparable to cheaper fibre services

  • Also faster than using a WiFi repeater from the hotspot (or equivalent "internet WiFi" mode on some routers)

Reliable:

  • Longer range and more connections than the hotspot alone

  • So, shared with more people! ✊

Cheap:

  • A portable LTE hotspot is about half the cost of the cheapest LTE-modem router. A router which supports external LTE modems (most only support 3G, if any) is about the same price as a router with integrated LTE

  • If you already have a spare computer and a WiFi access point or WiFi router you can get solid LTE for about half the cost of a new router, or for free if you already have a personal hotspot

This guide will also help you if you have a 3G/3.5G portable hotspot and a WiFi access point, or a WiFi router which doesn't support your hotspot via USB.

Step 0: Gather equipment

You will need:

  • [ ] A portable LTE (4G) hotspot. Try to check that it's supported as a USB modem on Linux
  • [ ] 4G SIM card and service
  • [ ] A WiFi device -- an old router or combined router / ADSL modem, a WiFi extender that also functions as an access point
  • [ ] Computer with Ethernet port and USB port(s) which you can install Linux on
  • [ ] Portable device with WiFi to test LTE coverage
  • [ ] Network cable

Step 1: Set up LTE hotspot

  1. Follow whatever lovely quick-start guide comes with your device to set up the portable hotspot. If you want to use the hotspot itself as a second access point, configure the WiFi name (SSID) and password as you like, otherwise just leave them as their defaults.

  2. Note the hotspot IP address ($HOTSPOT_IP), and check the DNS server settings to find a safe static address for your computer ($COMPUTER_IP) and WiFi access point ($WIFI_IP)

  3. Connect to the hotspot with your portable device (phone / laptop / tablet), then run a speed test (I like https://speedof.me ). Try to have the device fairly close to the hotspot during the test.

  4. Move the hotspot to another location then test again. Repeat until you find the location with the fastest speed. You can check Opensignal to try to find the location of the closest cell tower to try and narrow down where to look. You might have to choose a spot with worse coverage for practical reasons (I get fantastic service standing on the roof of the next-door building..)

Step 2: Set up router-computer

  1. Install Linux. I used Linux Mint because I had an ISO sitting around. You may want to install SSH and / or Cockpit to make managing it easier.

  2. Plug in the portable hotspot via USB. With luck, it'll show up as a connection in NetworkManager and connect automatically. If it doesn't, check lsusb and consult the internet. Turn off this connection, and your Ethernet connection if it's active, in the NetworkManager GUI or with nmcli con down.

Then, choose your network architecture.

If you don't need devices connected to the hotspot to be able to talk to devices connected to the WiFi access point, the simplest configuration is Network Address Translation: all devices connected via the router show up as a single IP address to the LTE modem, and the router handles forwarding between the two networks.

If you want all devices on the same network, you might instead want to set up a bridge, where all local IP addresses, including the modem's, are assigned by the router (the DHCP server on my hotspot seems unreliable, and the DHCP server on my AP is hard-coded to set itself as the default gateway).

Option 1: Network Address Translation

To set up NAT, just open nm-connection-editor, edit the default "Auto ethernet", go to the "IPv4 settings" tab and set "Method" to "Shared to other computers". This will automatically run a DHCP server on the ethernet interface, and set up forwarding rules to send traffic from there to the LTE modem.

You can also do this by editing /etc/NetworkManager/system-connections/Auto ethernet and setting method to shared.

If you want to edit the DHCP settings (for instance to change your subnet), also set address1=$COMPUTER_IP/24,$COMPUTER_IP (I don't think this is possible via the user interface).

Option 2: Bridge

  1. Use either nmcli or nm-connection-editor to create a new bridge ($BRIDGE) adding your USB and Ethernet interfaces both as "slave" (🤮) interfaces. Tick "All users may connect to this network".

  2. Edit /etc/NetworkManager/system-connections/$BRIDGE, set type=bridge and address1=$COMPUTER_IP/24,$BRIDGE_IP to enable the dnsmasq DHCP server

  3. Connect to your hotspot management page and disable its DHCP server

  4. sudo service NetworkManager restart

Step 3: Set up WiFi access point

  1. Reset the access point (AP) to factory defaults, connect to it (WiFi from your portable device is easiest, otherwise for Ethernet disable $BRIDGE on your computer, re-enable the auto DHCP Ethernet connection, and plug the AP in).

  2. Set the access point to have a static address of $WIFI_IP, and disable the AP's DHCP server if there is one.

  3. If you connected to the AP via Ethernet, change your settings back (re-enable $BRIDGE and disable the auto Ethernet connection). If you connected via WiFi, plug the AP into the computer via Ethernet

If you're using an older Netgear device, you might find that devices (weirdly, only non-Apple devices) connected to the AP can't get an IP address through DHCP. You can either use Netgear's hopeless workaround of setting static IP addresses for all wireless clients, or connect via Telnet and enable stp mode on the Netgear's bridge interface. Netgear, don't even worry about me fixing your 5-year-old bug for you, you're welcome 🙃.

Endnote

This set-up is working reasonably well, giving about the same speed when connected to the WiFi access point as to the hotspot itself. The added range means I don't have to keep moving the hotspot, and makes it easier to share the (not-bad) connection with others.

Having a general-purpose computer as the router means it's been easy to share files, media and printers over the network, and opens up options run a streaming server, and potentially even play media itself (depending on the hardware).

It's nice to find a use for an old ADSL WiFi router; even relatively-recent Wifi-N routers can pile up quickly, with inflexible default firmware and no open-source alternatives.