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.
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.confand/etc/network/interfaces, which Bookworm no longer uses. - Cellular connection in ECM modeThe steps name the cellular interface
usb0. If yours has another name, replaceusb0in every file and command.
Install hostapd and dnsmasq
-
Update packages
sudo apt update && sudo apt upgrade -y -
Restart Raspberry Pi
sudo reboot -
Install hostapd and dnsmasq
sudo apt install hostapd dnsmasq -y -
Stop both services
The services stay stopped while you configure them:
sudo systemctl stop hostapd dnsmasq
Configure addresses
-
Set static address of wlan0
Open the DHCP client configuration:
sudo nano /etc/dhcpcd.confAdd these lines at the end of the file and save it:
interface wlan0 static ip_address=192.168.0.10/24 denyinterfaces wlan0 usb0 -
Configure DHCP server
Keep the original
dnsmasqconfiguration under another name and open a new file:sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo nano /etc/dnsmasq.confAdd 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
-
Create hostapd configuration
The access point is protected with a password. Create its configuration file:
sudo nano /etc/hostapd/hostapd.confAdd 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] -
Point hostapd to its configuration
sudo nano /etc/default/hostapdFind the line
#DAEMON_CONF="", change it to the line below and save the file:DAEMON_CONF="/etc/hostapd/hostapd.conf"
Bridge cellular interface
-
Install bridge-utils
sudo apt-get install bridge-utils -y -
Create bridge and add cellular interface
sudo brctl addbr br0 sudo brctl addif br0 usb0 -
Make bridge permanent
sudo nano /etc/network/interfacesAdd these lines at the end of the file and save it:
auto br0 iface br0 inet manual bridge_ports usb0 wlan0
Start access point
-
Unmask and enable hostapd
A masked
hostapdservice does not start. Unmask it and enable it:sudo systemctl unmask hostapd sudo systemctl enable hostapd -
Restart Raspberry Pi
sudo reboot
Verify
-
Join network from another device
On a phone or a computer, join the Wi-Fi network you named in
hostapd.confwith its password.Result: the device connects and gets an address from192.168.0.11to192.168.0.30. -
Open web page
On the same device, open a web page.
Result: the page loads over the cellular connection.