1

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?!

Ralf Viellieber
  • 31
  • 1
  • 2
  • 5

2 Answers2

0

I forgot to stop dnsmasq service before editing dnsmasq.leases.

From https://wiki.gentoo.org/wiki/Dnsmasq

Clients that had a network interface update which results in a different MAC address might not get the intended IP address immediately. This is because the dnsmasq service has provided this IP address to the old MAC address, and will wait until the lease of this address has expired before re-assigning it.

The dnsmasq service stores its leases in /var/lib/misc/dnsmasq.leases. If the lease needs to be removed faster, shut down the dnsmasq service, remove the lease from the dnsmasq.leases file and start the service again.

Ralf Viellieber
  • 31
  • 1
  • 2
  • 5
0

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.

Manuel Florian
  • 261
  • 1
  • 5