Raspberry Pi - Access Point configuration

Written By Marco Argiolas (Collaborator)

Updated at March 5th, 2025

References:


sudo apt-get install dnsmasq hostapd
sudo systemctl stop dnsmasq
sudo systemctl stop hostapd

Kill process /usr/sbin/named, it is the one using port 53  required by dhcpcd

sudo lsof -n -i :53 
sudo killall named
sudo lsof -n -i :53 # verify nothing is using port 53

Modify /lib/dhcpcd5/dhcpcd and in the 6th line replace "(dhcp|static)" with "(dhcp)"

Add on top of /etc/dhcpcd.conf :

# wlan0 will use static address as AP
denyinterfaces wlan0

append to /etc/network/interfaces :

allow-hotplug wlan0
iface wlan0 inet static address 192.168.20.1 netmask 255.255.255.0 network 192.168.20.0 broadcast 192.168.20.255 iface wlan0 inet6 static address 2001:db8::101/64 #iface wlan0 inet manual # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf #if required add eth0 config #auto eth0

Create /etc/hostapd/hostapd.conf :

interface=wlan0
driver=nl80211 ssid=RPi4 wpa_passphrase=012345678 hw_mode=g channel=6 macaddr_acl=0 ignore_broadcast_ssid=0 auth_algs=1 wpa=2 wpa_key_mgmt=WPA-PSK rsn_pairwise=CCMP ieee80211n=1 wmm_enabled=1 ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]

Modify file /etc/default/hostapd :

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

Backup dnsmasq config file:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.backup

Re-create file /etc/dnsmasq.conf :

interface=wlan0 # use interface wlan0
#listen-address=192.168.20.1 # address to listen on dhcp-range=192.168.20.50,192.168.20.150,12h # IPv4 range and lease time dhcp-range=2001:db8::102, 2001:db8::247,12h # IPv6 range and lease time #bind-interfaces # bind to the interface #server=8.8.8.8 # Google DNS server #enable-ra # Enable router advertisement

Modify /etc/sysctl.conf :

net.ipv4.ip_forward=1

Unmask hostapd

sudo systemctl unmask hostapd
sudo systemctl enable hostapd sudo systemctl start hostapd


Reboot the system

Check all services are happily running

sudo service otbr-agent status
sudo service dhcpcd status
# restart if required
sudo service dhcpcd restart
sudo service hostapd status
# you might need to kill 'named' process again
sudo service dnsmasq status

 

#################################################################

Without using Access Poing, RPi4 connected to office network via Ethernet
(WORK IN PROGRESS)

Rpi4 :

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.10.48.250  netmask 255.255.0.0  broadcast 10.10.255.255         inet6 fe80::dea6:32ff:fee9:f41e  prefixlen 64  scopeid 0x20<link>         ether dc:a6:32:e9:f4:1e  txqueuelen 1000  (Ethernet) wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.20.1  netmask 255.255.255.0  broadcast 192.168.20.255         inet6 fe80::d840:d907:f856:a4cc  prefixlen 64  scopeid 0x20<link>         inet6 fe80::dea6:32ff:fee9:f41f  prefixlen 64  scopeid 0x20<link>         inet6 2001:db8::101  prefixlen 64  scopeid 0x0<global>         ether dc:a6:32:e9:f4:1f  txqueuelen 1000  (Ethernet) wpan0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1280
        inet6 fe80::d840:d907:f856:a4cc  prefixlen 64  scopeid 0x20<link>         inet6 fdde:ad00:beef::ff:fe00:fc11  prefixlen 64  scopeid 0x0<global>         inet6 fdde:ad00:beef:0:8d9d:8fb5:f3c1:4e85  prefixlen 64  scopeid 0x0<global>         inet6 fddd:3357:51d7:290b:66cb:14d9:21:8d1  prefixlen 64  scopeid 0x0<global>         inet6 fdde:ad00:beef::ff:fe00:c800  prefixlen 64  scopeid 0x0<global>         inet6 fdde:ad00:beef::ff:fe00:fc10  prefixlen 64  scopeid 0x0<global>         inet6 fdde:ad00:beef::ff:fe00:fc38  prefixlen 64  scopeid 0x0<global>


Laptop :

en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=400<CHANNEL_IO>     ether 88:66:5a:32:ea:bb     inet6 fd16:abcd:ef01:0:49b:3c74:7e8d:9ece prefixlen 64     inet6 fe80::49b:3c74:7e8d:9ece%en0 prefixlen 64 secured scopeid 0x6     inet 10.10.32.92 netmask 0xffff0000 broadcast 10.10.255.255


# On laptop add route to RPi's 'wpan0' interface
sudo route add -inet6 fddd:3357:51d7:290b::/64 fe80::dea6:32ff:fee9:f41e%en0
# Ping wpan0 forcing source address to be the laptop's 'en0' IPv6 Link-Local address
ping6 -S fe80::49b:3c74:7e8d:9ece%en0  fddd:3357:51d7:290b:66cb:14d9:21:8d1
#