[Dnsmasq-discuss] Copying dnsmasq.leases, any issues to be aware of?
Simon Kelley
simon at thekelleys.org.uk
Fri Feb 4 21:28:42 UTC 2022
On 04/02/2022 18:16, Chris Green wrote:
> I'm looking at ways to provide backup DHCP/DNS with dnsmasq. This is
> on a small, fairly 'quiet' home LAN so there aren't dozens of clients
> connecting and disconnecting every second. Also if DHCP/DNS is not
> available for a few minutes the world won't end! :-)
>
> So, I'm proposing to have dnsmasq installed on two systems, one (say
> dns1, 192.168.1.2) is the live DHCP/DNS server, the other (say dns2,
> 192.168.1.3), both with static IP.
>
> If dns1 dies or needs to be turned off I just copy the dnsmasq
> configuration (stored elsewhere as well of course) to dns2 and also
> copy the dnsmasq.leases file and [re]start dnsmasq on dns2. Will this
> work reasonably OK? I.e. if/when a system on the LAN broadcasts a
> DHCP request will it get the same IP again?
>
> It's not a disaster if a system gets a different IP anyway, if
> something *really* needs a fixed IP I can add a dhcp-host in the
> dnsmasq configuration.
>
> I can even have dnsmasq running on dns2 all the time with it
> configured to provide only local DNS and no DHCP, then it's just 'copy
> dnsmasq configuration, copy dnsmasq.leases, restart dnsmasq.
>
> (All my systems run syncthing so it's very easy to have pretty much
> live copies of files synchronised across systems)
>
To be honest, even if you didn't bother copying the leases file, most
systems would get the same address. The clients try to renew the lease
on the exiting DHCP server and when they get no response they broadcast
the renewal to try and find a new server. As long as there's no reason
not to, the new server will accept the client's request for the address
it already had.
Cheers,
Simon.
More information about the Dnsmasq-discuss
mailing list