dnsmasq - make it send new static ip to client
I needed to set a new static IP address on a client host that already had got one assigned by DHCP in dnsmasq, and the IP address I wanted to use was recently used by another client host that had been taken down. Just restarting dhclient on the client did not work, not even re-requesting a release - dnsmasq just returned the old DHCP IP.
Server - clear the lease file from any reference
On the server running dnsmasq: Ensure the MAC is assigned to the correct IP it is not assigned to the wrong client # shutdown dnsmasq service dnsmasq stop # edit the lease file and remove these lines: # the lines with the MAC address and IP address currently assigned to the client # the target static IP address vi /tmp/var/lib/misc/dnsmasq.leases
Client - request release and ip again
On the client: # request lease release, shutdown the interface, sleep for a while bring up the interface, run the client dhclient -r <interface>; ifconfig <interface> down; sleep 10; ifconfig <interface> up; dhclient <interface> # maybe it works with just dhclient -r <interface>; dhclient <interface>
Server - check the dnsmasq log to find out what is happening.
tail -n200 /var/log/dnsmasq.log
Log discoveries
This worked for me, but I noted some things from the dnsmasq log: The client requests a release DHCPRELEASE(<dnsmasq interface>) X.X.X.X AA:BB:CC:DD:EE unknown lease But then it re-asks for the same IP again DHCPREQUEST(<dnsmasq interface>) X.X.X.X AA:BB:CC:DD:EE The server however however is not fooled: DHCPNAK(<dnsmasq interface>) X.X.X.X AA:BB:CC:DD:EE static lease available The client asks for a new IP: DHCPDISCOVER(<dnsmasq interface>) AA:BB:CC:DD:EE The server responds with an offer from the static table: DHCPOFFER(<dnsmasq interface>) Y.Y.Y.Y AA:BB:CC:DD:EE Which the client accepts: DHCPREQUEST(<dnsmasq interface>) Y.Y.Y.Y AA:BB:CC:DD:EE And the server acknowledges: DHCPACK(<dnsmasq interface>) Y.Y.Y.Y AA:BB:CC:DD:EE <client hostname>
This is a personal note. Last updated: 2019-07-05 18:30:07.