I'm trying to set up a DHCP server using dnsmasq on Mac OS (Ventura) so that it can serve IP addresses to virtual machines that I am running.
I have included this line into my /opt/homebrew/etc/dnsmasq.conf:
dhcp-range=192.168.1.2,192.168.1.100,255.255.255.0,12h
and restarted the service using
sudo brew services restart dnsmasq
I have also disabled the built-in Mac OS DHCP server so that it does not interfere with dnsmasq:
sudo /bin/launchctl unload -w /System/Library/LaunchDaemons/bootps.plist
I'm running a Linux VM using QEMU, with the following network configuration:
-nic vmnet-shared,start-address=192.168.1.1,end-address=192.168.1.254,subnet-mask=255.255.255.0,mac=52:52:52:00:00:00
Unfortunately, the DHCP server is silent when I try to contact it from the VM:
$ sudo dhclient -v
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/enp0s1/52:52:52:00:00:00
Sending on LPF/enp0s1/52:52:52:00:00:00
Sending on Socket/fallback
DHCPREQUEST for 192.168.1.4 on enp0s1 to 255.255.255.255 port 67 (xid=0x74f39476)
DHCPREQUEST for 192.168.1.4 on enp0s1 to 255.255.255.255 port 67 (xid=0x74f39476)
It seems like there's nothing listening on the DHCP port (67) - the sudo lsof -i4UDP:67 lists nothing.
If I use the built-in Mac OS DHCP server, everything works fine. The VM is getting an IP address and the system shows that something is listening on DHCP port:
$ sudo lsof -i4UDP:67
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
launchd 1 root 14u IPv4 0x6ff053dbd93d2625 0t0 UDP *:bootps
launchd 1 root 22u IPv4 0x6ff053dbd93d2625 0t0 UDP *:bootps
How to make dnsmasq work as a DHCP server?