Using a Raspberry Pi as a Home Router

Published: (December 25, 2025 at 09:59 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Prerequisites

  • Raspberry Pi OS based on Debian Bookworm (or later)
  • Working Internet connection via the Ethernet port (eth0)
  • NetworkManager handling network connections
  • eth0 correctly configured

Verify Ethernet Connection

sudo nmcli device

Confirm that eth0 is in the connected state.

Create Wi‑Fi Access Point

Note: Replace wlan0 with the name of your wireless interface.

# Add a new Wi‑Fi connection
sudo nmcli connection add type wifi \
  ifname wlan0 \
  con-name ap0 \
  ssid "" \
  autoconnect yes

# Set the interface to access‑point mode
sudo nmcli connection modify ap0 \
  802-11-wireless.mode ap

# Use the 2.4 GHz band
sudo nmcli connection modify ap0 \
  802-11-wireless.band bg

# Configure WPA2/WPA3 pre‑shared key
sudo nmcli connection modify ap0 \
  wifi-sec.key-mgmt wpa-psk \
  wifi-sec.psk ""

Enable NetworkManager Shared Mode

NetworkManager’s shared mode will:

  • Start a DHCP server on the Wi‑Fi interface
  • Enable IP forwarding
  • Apply IP masquerading (NAT)
# Enable shared mode (IPv4)
sudo nmcli connection modify ap0 \
  ipv4.method shared

# Specify the IPv4 subnet for the AP
sudo nmcli connection modify ap0 \
  ipv4.addresses 172.18.0.1/24

# (Optional) Disable IPv6
sudo nmcli connection modify ap0 \
  ipv6.method ignore

# Bring the access point up
sudo nmcli connection up ap0

Verify the Setup

# Show the IP address assigned to the Wi‑Fi interface
ip -4 addr show wlan0

# Display routing table
# Expected:
# - 172.18.0.0/24 via wlan0
# - default route via eth0
ip -4 route

# List connected stations (Layer 2)
sudo iw dev wlan0 station dump

# List connected devices at the IP layer (Layer 3)
ip neigh show dev wlan0

References

Back to Blog

Related posts

Read more »