I want to configure my RasPi zero 2 W as access point so that I can:
- connect to it from another device (over WiFi)
- to retrieve a camera feed and check
- a webpage running on a webserver.
I’ve got all the major components (1-3) working fine but I can’t seem to get the DHCP serverdhcpcd
to work the way it should. I want to assign a dynamic IP to the device that connects tothe AP, so that it can retrieve the feed and the website from a static IP (that being the IP ofthe Pi). I have tried the following:
/etc/dnsmasq.conf
:
interface=wlan0 # Use interface wlan0
dhcp-range=192.168.50.20,192.168.50.50,255.255.255.0,24h
and
/etc/dhcpcd.conf
:
interface wlan0
static ip_address=192.168.50.10/24
noipv6
nohook wpa_supplicant
dnsmasq:
$ 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 Sat 2024-08-10 03:15:24 PDT; 2s ago
Process: 26875 ExecStartPre=/etc/init.d/dnsmasq checkconfig (code=exited, status=0/SUCCESS)
Process: 26883 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
Process: 26892 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
Main PID: 26891 (dnsmasq)
Tasks: 1 (limit: 368)
CPU: 211ms
CGroup: /system.slice/dnsmasq.service
└─26891 /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,e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d
Aug 10 03:15:23 raspberrypi systemd[1]: Starting dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server...
Aug 10 03:15:24 raspberrypi dnsmasq[26891]: started, version 2.89 cachesize 150
Aug 10 03:15:24 raspberrypi dnsmasq[26891]: 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
Aug 10 03:15:24 raspberrypi dnsmasq[26891]: warning: interface wlan0 does not currently exist
Aug 10 03:15:24 raspberrypi dnsmasq-dhcp[26891]: DHCP, IP range 192.168.50.20 -- 192.168.50.50, lease time 1d
Aug 10 03:15:24 raspberrypi dnsmasq[26891]: no servers found in /etc/resolv.conf, will retry
Aug 10 03:15:24 raspberrypi dnsmasq[26891]: read /etc/hosts - 7 names
Aug 10 03:15:24 raspberrypi systemd[1]: Started dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server.
dhcpcd:
sudo systemctl status dhcpcd
● dhcpcd.service - DHCP Client Daemon on all interfaces
Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; preset: enabled)
Active: deactivating (stop-sigterm) (Result: signal) since Sat 2024-08-10 03:23:06 PDT; 6s ago
Docs: man:dhcpcd(8)
Process: 27236 ExecStart=/usr/sbin/dhcpcd -q -b (code=exited, status=0/SUCCESS)
Main PID: 27238 (code=killed, signal=SYS)
Tasks: 2 (limit: 368)
CPU: 247ms
CGroup: /system.slice/dhcpcd.service
├─27239 "dhcpcd: [privileged proxy]"
└─27240 "dhcpcd: [network proxy]"
Aug 10 03:23:06 raspberrypi dhcpcd[27239]: DUID 00:01:00:01:2e:48:97:f1:d8:3a:dd:80:85:e8
Aug 10 03:23:06 raspberrypi systemd[1]: Started dhcpcd.service - DHCP Client Daemon on all interfaces.
Aug 10 03:23:06 raspberrypi dhcpcd[27239]: eth0: IAID 1b:dc:c4:06
Aug 10 03:23:06 raspberrypi dhcpcd[27239]: ps_ctl_listen: read: Success
Aug 10 03:23:06 raspberrypi dhcpcd[27239]: ps_ctl_recv: read: Success
Aug 10 03:23:06 raspberrypi systemd[1]: dhcpcd.service: Main process exited, code=killed, status=31/SYS
Aug 10 03:23:06 raspberrypi dhcpcd[27239]: ps_sendcmdmsg: Connection refused
Aug 10 03:23:06 raspberrypi dhcpcd[27239]: ps_inet_recvra: Connection refused
Aug 10 03:23:09 raspberrypi dhcpcd[27239]: ps_sendcmdmsg: Transport endpoint is not connected
Aug 10 03:23:09 raspberrypi dhcpcd[27239]: ps_inet_recvra: Transport endpoint is not connected
I have also stopped & disabled NetworkManager:
sudo systemctl stop NetworkManager
sudo systemctl disable NetworkManager
I’m on:
cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 12 (bookworm)"
NAME="Raspbian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
How can I configure my dhcpcd to work correctly and assign an IP when a client connects?