I have a pair of Raspberry Pi Zero W connecting to each other through WiFi. They have their hostnames configured as “server.example.com” and “client.example.com”. I run hostapd and dnsmasq on the server. I have the following in its /etc/hosts:
192.168.4.1 server.example.com 192.168.4.2 client.example.com
I’d like dnsmasq to give dynamic IPs to all clients, except the one that pretends to be client.example.com in its DHCP request. I’ve got the following config:
interface=ap0 dhcp-range=192.168.4.100,192.168.4.250,255.255.255.0,24h domain=example.com dhcp-leasefile=/var/run/dnsmasq.leases dhcp-host=client.example.com,192.168.4.2,infinite
This seems to work, but I’d like not to have to keep a copy of the static IP address in the dnsmasq.conf file. I feel from the wording of the man page like the IP address there is optional, but if I remove it, it allocates 192.168.4.200 to the client, and logs the following:
Sep 06 21:13:12 server.example.com dnsmasq-dhcp: not giving name client.example.com to the DHCP lease of 192.168.4.200 because the name exists in /etc/hosts with address 192.168.4.2
Is there some variant of that dhcp-host= line that would allow me to fix that? Or is there any other way to have dnsmasq’s DHCP server to take name/ip pairs from /etc/hosts?