DHCP dnsmasq for infinite lease

dhcpdnsmasq

I am using dnsmasq to serve IPs for about 200 vservers.
Leasetime is infinite:
dhcp-range=10.0.1.2,10.0.1.254,infinite

I don't know why, but 1 vserver changed IP. Let's say MAC address changed.

I wanted the vserver to get back his old IP, so i shut down the interface and edited /var/lib/misc/dnsmasq.leases (changed new/old IP)

After reboot vserver had wrong new IP again. So i think /var/lib/misc/dnsmasq.leases is just a log-file?!

I fixed the problem with changing vserver IP on console – after reboot vserver had old IP.

But i want to understand – how does dnsmasq save the information "i want to give this IP to this MAC" and how can i change this?!

Best Answer

The dnsmasq.leases file is like a database for dnsmasq to know what address has assigned along with some other info.

According to sites here and here you cand assign static ip to a host as follows:

--dhcp-host=servername,192.168.0.199
--dhcp-host=00:20:e0:3b:13:af,servername,infinite
--dhcp-host=aa:bb:cc:dd:ee:ff,192.168.0.199

Note: if you use the first option, you have to make sure the hostname of the client machine match with the entry --dhcp-host=servername in your dnsmasq.conf file.

I hope this helps.