I want to configure my Raspberry Pi Zero 2W so that it is an AP and a device (phone) can connect to it.
I installed hostap
and dnsmasq
and configured it like:
$ cat /etc/hostapd/hostapd.conf
interface=wlan0
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=MYSSID
wpa_passphrase=password
$ cat /etc/dhcpd.conf
interface wlan0
static ip_address=192.168.1.10/24
$ cat /etc/dnsmasq.conf
interface=wlan0
dhcp-range=192.168.1.11,192.168.1.30,255.255.255.0,24h
$ cat /etc/default/hostapd
# Defaults for hostapd initscript
#
# WARNING: The DAEMON_CONF setting has been deprecated and will be removed
# in future package releases.
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
DAEMON_CONF="/etc/hostapd/hostapd.conf"
# Additional daemon options to be appended to hostapd command:-
# -d show more debug messages (-dd for even more)
# -K include key data in debug messages
# -t include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""
and I have both dnsmasq & hostapd services running:
$ sudo systemctl status hostapd.service
● hostapd.service - Access point and authentication server for Wi-Fi and Ethernet
Loaded: loaded (/lib/systemd/system/hostapd.service; enabled; preset: enabled)
Active: active (running) since Fri 2024-05-17 19:02:37 PDT; 10min ago
Docs: man:hostapd(8)
Process: 1270 ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid $DAEMON_OPTS ${DAEMON_CONF} (code=exited, status=0/SUCCESS)
Main PID: 1271 (hostapd)
Tasks: 1 (limit: 167)
CPU: 89ms
CGroup: /system.slice/hostapd.service
└─1271 /usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd/hostapd.conf
May 17 19:02:37 cykelcam-ron systemd[1]: Starting hostapd.service - Access point and authentication server for Wi-Fi and Ethernet...
May 17 19:02:37 cykelcam-ron hostapd[1270]: wlan0: interface state UNINITIALIZED->ENABLED
May 17 19:02:37 cykelcam-ron hostapd[1270]: wlan0: AP-ENABLED
May 17 19:02:37 cykelcam-ron systemd[1]: Started hostapd.service - Access point and authentication server for Wi-Fi and Ethernet.
$ sudo systemctl status dnsmasq.service
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; preset: enabled)
Active: active (running) since Fri 2024-05-17 19:12:58 PDT; 1s ago
Process: 1513 ExecStartPre=/etc/init.d/dnsmasq checkconfig (code=exited, status=0/SUCCESS)
Process: 1521 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
Process: 1530 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
Main PID: 1529 (dnsmasq)
Tasks: 1 (limit: 167)
CPU: 204ms
CGroup: /system.slice/dnsmasq.service
└─1529 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458e8804>
May 17 19:12:58 cykelcam-ron systemd[1]: Starting dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server...
May 17 19:12:58 cykelcam-ron dnsmasq[1529]: started, version 2.89 cachesize 150
May 17 19:12:58 cykelcam-ron dnsmasq[1529]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset nftset auth cryptohash DNSSEC loop-detect inotify dumpfile
May 17 19:12:58 cykelcam-ron dnsmasq-dhcp[1529]: DHCP, IP range 192.168.1.11 -- 192.168.1.30, lease time 1d
May 17 19:12:58 cykelcam-ron dnsmasq[1529]: reading /etc/resolv.conf
May 17 19:12:58 cykelcam-ron dnsmasq[1529]: using nameserver 8.8.8.8#53
May 17 19:12:58 cykelcam-ron dnsmasq[1529]: using nameserver 8.8.4.4#53
May 17 19:12:58 cykelcam-ron dnsmasq[1529]: read /etc/hosts - 7 names
May 17 19:12:58 cykelcam-ron systemd[1]: Started dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server.
yet, no SSID MYSSID
is visible when I scan for SSIDs with my phone.
I'm obviously missing something, what is it?
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
UPDATE
Okay, so I downgraded to the legacy bullseye
32-bit version now and the system seems to be a lot more responsive and nicer to work with!
So the above configuration gives my a ssid MYSSID
to which i can connect but I'm not able to lease an IP address even though dhcpcd.service
is running.
The pi gets the IP 192.168.1.10/24
as expected and in systemctl status dhcpcd.service
I see:
elsn0:connected to Access Point `'
DUID [SOME 14 Byte number : separated starting with] 00:01:.....
wlan0: IAID 67:23:37:47
wlan0: probing address 192.168.1.10/24
wlan0: soliciting an IPv6 router
wlan0: using static address 192.168.1.10/24
wlan0: adding route to 192.168.1.0/24
wlan0: noIPv6 Routers available
I'm not sure why it tries to look for a route, I don't want a route, I just want an AP that I can connect to to retrieve a website that is served using apache2
. Not sure how I can get this resolved.
$ cat /etc/os-release
above