With the rise of smart devices and home networks, control over your internet configuration is everything in the modern age. How about transforming your Raspberry Pi into a full-fledged router? Good news — you can definitely do that, and it’s easier than you’d think.
In this step by step guide we show you how to set up a Raspberry Pi as a wireless router, with just a few tools, some configuration and a little bit of Linux magic. This project is ideal whether you’re a DIY tech wizard, a student or just someone looking to repurpose an old Pi.

💡 Why Use Raspberry Pi to Build WiFi Router?
There are several advantages to using your Raspberry Pi as a router:
- ✅ Savings: You do not need to purchase routers that are quite dear.
- ✅ Absolute control: Manage DHCP, firewall, bandwidth, and everything else.
📦 What You’ll Need
- Raspberry Pi 3, 4 or newer (with onboard WiFi)
- Raspberry Pi OS Bookworm
- MicroSD Card 8GB or larger
- Ethernet RJ 45 Internet connection
Update your Raspberry Pi OS:
sudo apt update && sudo apt upgrade -y
Install Packages:
sudo apt install -y hostapd dnsmasq iptables-persistent
Enable required services:
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl enable dnsmasq
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd
Configure hostapd (Wi-Fi access point):
sudo tee /etc/hostapd/hostapd.conf > /dev/null <<EOF
interface=wlan0
driver=nl80211
ssid=Pi_Router
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=raspberry123
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
EOF
Tell hostapd where the config is:
sudo sed -i 's|#DAEMON_CONF=""|DAEMON_CONF="/etc/hostapd/hostapd.conf"|' /etc/default/hostapd
Configure dnsmasq (DHCP server):
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Now Create new config:
sudo tee /etc/dnsmasq.conf > /dev/null <<EOF
interface=wlan0
dhcp-range=192.168.4.10,192.168.4.50,255.255.255.0,24h
EOF
Configure static IP for wlan0:
sudo mkdir -p /etc/systemd/network
sudo tee /etc/systemd/network/12-wlan0.network > /dev/null <<EOF
[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
DHCPServer=no
EOF
Enable IP forwarding:
sudo sed -i 's|#net.ipv4.ip_forward=1|net.ipv4.ip_forward=1|' /etc/sysctl.conf
sudo sysctl -p
Configure NAT for internet sharing (via eth0):
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables/rules.v4"
Unblock and bring up Wi-Fi:
sudo rfkill unblock wifi
sudo ip link set wlan0 up
Restart all necessary services:
sudo systemctl restart systemd-networkd
sudo systemctl restart dnsmasq
sudo systemctl restart hostapd