Create LTE Wi-Fi hotspot on Raspberry Pi

Share the LTE connection of a Raspberry Pi with the 4G/LTE Cellular Modem Kit over Wi-Fi, with hostapd and dnsmasq, on Raspberry Pi OS releases before Bookworm.

The Raspberry Pi becomes a Wi-Fi access point: hostapd runs the access point on wlan0, dnsmasq gives its clients addresses, and a bridge joins wlan0 to the cellular interface usb0. On Raspberry Pi OS Bookworm and later, NetworkManager replaces this method: see Raspberry Pi’s Host a Wi-Fi hotspot with a Raspberry Pi.

Requirements

Finish these pages first, in order: Get started with 4G/LTE Cellular Modem Kit, then Connect cellular module to internet in ECM mode.

Required

Hardware

  • Raspberry Pi with the 4G/LTE Cellular Modem KitA Raspberry Pi with Wi-Fi: the access point runs on wlan0.

Software

  • Raspberry Pi OS before BookwormThe steps edit /etc/dhcpcd.conf and /etc/network/interfaces, which Bookworm no longer uses.
  • Cellular connection in ECM modeThe steps name the cellular interface usb0. If yours has another name, replace usb0 in every file and command.

Install hostapd and dnsmasq

  1. Update packages

    sudo apt update && sudo apt upgrade -y
  2. Restart Raspberry Pi

    sudo reboot
  3. Install hostapd and dnsmasq

    sudo apt install hostapd dnsmasq -y
  4. Stop both services

    The services stay stopped while you configure them:

    sudo systemctl stop hostapd dnsmasq

Configure addresses

  1. Set static address of wlan0

    Open the DHCP client configuration:

    sudo nano /etc/dhcpcd.conf

    Add these lines at the end of the file and save it:

    interface wlan0
    static ip_address=192.168.0.10/24
    denyinterfaces wlan0 usb0
  2. Configure DHCP server

    Keep the original dnsmasq configuration under another name and open a new file:

    sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
    sudo nano /etc/dnsmasq.conf

    Add these lines and save the file:

    interface=wlan0
    dhcp-range=192.168.0.11,192.168.0.30,255.255.255.0,24h

Configure access point

  1. Create hostapd configuration

    The access point is protected with a password. Create its configuration file:

    sudo nano /etc/hostapd/hostapd.conf

    Add these lines and save the file. Replace [NETWORK] with the name of the Wi-Fi network and [PASSWORD] with its password. No line may start or end with a space or a tab.

    interface=wlan0
    bridge=br0
    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]
  2. Point hostapd to its configuration

    sudo nano /etc/default/hostapd

    Find the line #DAEMON_CONF="", change it to the line below and save the file:

    DAEMON_CONF="/etc/hostapd/hostapd.conf"

Bridge cellular interface

  1. Install bridge-utils

    sudo apt-get install bridge-utils -y
  2. Create bridge and add cellular interface

    sudo brctl addbr br0
    sudo brctl addif br0 usb0
  3. Make bridge permanent

    sudo nano /etc/network/interfaces

    Add these lines at the end of the file and save it:

    auto br0
    iface br0 inet manual
    bridge_ports usb0 wlan0

Start access point

  1. Unmask and enable hostapd

    A masked hostapd service does not start. Unmask it and enable it:

    sudo systemctl unmask hostapd
    sudo systemctl enable hostapd
  2. Restart Raspberry Pi

    sudo reboot

Verify

  1. Join network from another device

    On a phone or a computer, join the Wi-Fi network you named in hostapd.conf with its password.

    Result: the device connects and gets an address from 192.168.0.11 to 192.168.0.30.
  2. Open web page

    On the same device, open a web page.

    Result: the page loads over the cellular connection.

Next steps