Build a router with mobile connectivity using Raspberry Pi

Use OpenWRT to get more control over your network's router.
98 readers like this.
Mesh networking connected dots

The Raspberry Pi is a small, single-board computer that, despite being the size of a credit card, is capable of doing a lot of things. In reality, this little computer can be almost anything you want to be. You just need to open up your imagination.

Raspberry Pi enthusiasts have made many different projects, from simple programs to complex automation projects and solutions like weather stations or even smart-home devices. This article will show how to turn your Raspberry Pi into a router with LTE mobile connectivity using the OpenWRT project.

About OpenWRT and LTE

OpenWRT is an open source project that uses Linux to target embedded devices. It's been around for more than 15 years and has a large and active community.

There are many ways to use OpenWRT, but its main purpose is in routers. It provides a fully writable filesystem with package management, and because it is open source, you can see and modify the code and contribute to the ecosystem. If you would like to have more control over your router, this is the system you want to use.

Long-term evolution (LTE) is a standard for wireless broadband communication based on the GSM/EDGE and UMTS/HSPA technologies. The LTE modem I'm using is a USB device that can add 3G or 4G (LTE) cellular connectivity to a Raspberry Pi computer.


For this project, you will need:

  • A Raspberry Pi with a power cable
  • A computer, preferably running Linux
  • A microSD card with at least 16GB
  • An Ethernet cable
  • An LTE modem (I am using a Teltonika TRM240)
  • A SIM card for mobile connectivity

Install OpenWRT

To get started, download the latest Raspberry Pi-compatible release of OpenWRT. On the OpenWRT site, you see four images: two with ext4 and two with squashfs filesystems. I use the ext4 filesystem. You can download either the factory or sysupgrade image; both work great.

Once you download the image, you need to extract it and install it on the SD card by following these instructions. It can take some time to install the firmware, so be patient. Once it's finished, there will be two partitions on your microSD card. One is used for the bootloader and the other one for the OpenWRT system.

Boot up the system

To boot up your new system, insert the microSD card into the Raspberry Pi, connect the Pi to your router (or a switch) with an Ethernet cable, and power it on.

If you're experienced with the Raspberry Pi, you may be used to accessing it through a terminal over SSH, or just by connecting it to a monitor and keyboard. OpenWRT works a little differently. You interact with this software through a web browser, so you must be able to access your Pi over your network.

By default, the Raspberry Pi uses this IP address: The computer you use to configure the Pi must be on the same subnet as the Pi. If your network doesn't use 192.168.1.x addresses, or if you're unsure, open Settings in GNOME, navigate to network settings, select Manual, and enter the following IP address and Netmask:

  • IP address:
  • Netmask:

Open a web browser on your computer and navigate to This opens an authentication page so you can log in to your Pi.

No password is required yet, so just click the Login button to continue.

Configure network connection

The Raspberry Pi has only one Ethernet port, while normal routers have a couple of them: one for WAN (wired area network) and the other for LAN (local area network). You have two options:

  1. Use your Ethernet port for network connectivity
  2. Use WiFi for network connectivity

To use Ethernet:

Should you decide to use Ethernet, navigate to Network → Interfaces. On the configuration page, press the blue Edit button that is associated with the LAN interface.

A pop-up window should appear. In that window, you need to enter the IP address to match the subnet of the router to which you will connect the Raspberry Pi. Change the Netmask, if needed, and enter the IP address of the router the Raspberry Pi will connect to.

Save this configuration and connect your Pi to the router over Ethernet. You can now reach the Raspberry Pi with this new IP address.

Be sure to set a password for your OpenWRT router before you put it into production use!

To use WiFi

If you would like to connect the Raspberry Pi to the internet through WiFi, navigate to Network → Wireless. In the Wireless menu, press the blue Scan button to locate your home network.

In the pop-up window, find your WiFi network and connect to it. Don't forget to Save and Apply the configuration.

In the Network → Interfaces section, you should see a new interface.

Be sure to set a password for your OpenWRT router before you put it into production use!

Install the necessary packages

By default, the router doesn't have a lot of packages. OpenWRT offers a package manager with a selection of packages you need to install. Navigate to System → Software and update your package manager by pressing the button labeled "Update lists…".

You will see a lot of packages; you need to install these:

  • usb-modeswitch
  • kmod-mii
  • kmod-usb-net
  • kmod-usb-wdm
  • kmod-usb-serial
  • kmod-usb-serial-option
  • kmod-usb-serial-wwan (if it's not installed)

Additionally, download this modemmanager package and install it by pressing the button labeled Upload Package… in the pop-up window. Reboot the Raspberry Pi for the packages to take effect.

Set up the mobile interface

After all those packages are installed, you can set up the mobile interface. Before connecting the modem to the Raspberry Pi read, the modem instructions to set it up. Then connect your mobile modem to the Raspberry Pi and wait a little until the modem boots up.

Navigate to Network → Interface. At the bottom of the page, press the Add new interface… button. In the pop-up window, give your interface a name (e.g., mobile) and select ModemManager from the drop-down list.

Press the button labeled Create Interface. You should see a new pop-up window. This is the main window for configuring the interface. In this window, select your modem and enter any other information like an Access Point Name (APN) or a PIN.

Note: If no modem devices appear in the list, try rebooting your Raspberry Pi or installing the kmod-usb-net-qmi-wwan package.

When you are done configuring your interface, press Save and then Save and Apply. Give some time for the system to take effect. If everything went well, you should see something like this.

If you want to check your internet connection over this interface, you can use ssh to connect to your Raspberry Pi shell. In the terminal, enter:

ssh root@

The default IP address is; if you changed it, then use that IP address to connect. When connected, execute this command in the terminal:

ping -I ppp0

If everything is working, then you should receive pings back from Google's servers.

ppp0 is the default interface name for the mobile interface you created. You can check your interfaces using ifconfig. It shows active interfaces only.

Set up the firewall

To get the mobile interface working, you need to configure a firewall for the mobile interface and the lan interface to direct traffic to the correct interface.

Navigate to Network → Firewall. At the bottom of the page, you should see a section called Zones.

The simplest way to configure the firewall is to adjust the wan zone. Press the Edit button and in the Covered networks option, select your mobile interface, and Save and Apply your configuration. If you don't want to use WiFi to connect to the internet, you can remove wwan from the Covered networks or disable the WiFi connection.

If you want to set up individual zones for each interface, just create a new zone and assign the necessary interfaces. For example, you may want to have a mobile zone that covers the mobile interface and is used to forward LAN interface traffic through it. Press the Add button, then Name your zone, check the Masquerading check box, select Covered Networks, and choose which zones can forward their traffic.

Then Save and Apply the changes. Now you have a new zone.

Set up an Access Point

The last step is to configure a network with an Access Point for your devices to connect to the internet. To set up an Access Point, navigate to Network → Wireless. You will see a WiFi device interface, a disabled Access Point named OpenWRT, and a connection that is used to connect to the internet over WiFi (if you didn't disable or delete it earlier). On the Disable interface, press the Edit button, then Enable the interface.

If you want, you can change the interface name by editing the ESSID option. You can also select which network it will be associated with. By default, it with be associated with the lan interface.

To add a password for this interface, select the Wireless Security tab. In the tab, select the encryption WPA2-PSK and enter the password for the interface in the Key option field.

Then Save and Apply the configuration. If the configuration was set correctly, when scanning available Access Points with your device, you should see a new Access Point with the name you assigned.

Additional packages

If you want, you can download additional packages for your router through the web interface. Just go to System → Software and install the package you want from the list or download it from the internet and upload it. If you don't see any packages in the list, press the Update lists… button.

You can also add other repositories that have packages that are good to use with OpenWRT. Packages and their web interfaces are installed separately. The packages that start with the prefix luci- are web interface packages.

Give it a try

This is what my Raspberry Pi router setup looks like.

It not difficult to build a router from a Raspberry Pi. The downside is that a Raspberry Pi has only one Ethernet port. You can add more ports with a USB-to-Ethernet adapter. Don't forget to configure the port on the interface's website.

OpenWRT supports a large number of mobile modems, and you can configure the mobile interface for any of them with the modemmanager, which is a universal tool to manage modems.

Have you used your Raspberry Pi as a router? Let us know how it went in the comments.

What to read next
User profile image.
I'm a programmer/administrator from Lithuania. My fields of interest are: Linux Embedded Linux Networking Programming Other embedded systems like Arduino and many other


If I use an RPi4, which has a better Ethernet port, can I use a USB - Ethernet adaptor instead of Wifi for the second port? The native Ethernet port would be connected to the internal network and the USB one connected to the Internet.modem.

It is possible to connect the Ethernet USB adapter for a second Ethernet port. You also will need to install the correct drivers for the adapter to work. If everything is fine, you should see a new interface in the Interfaces section

In reply to by dgoadby

Thanks a lot for your clear instructions.

What connection speed can I expect with the TRM240 modem? I only get about 850 KB/s, although my connection should give more. The TRM240 has LTE Cat-1 and should support up to 10MB/s download and 5MB/s upload. But what can I expect in this constellation?

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.