[Dnsmasq-discuss] Details of the --dhcp-optsdir=<path> option

Michael michael at kmaclub.com
Fri Sep 3 21:32:06 UTC 2021

On 9/3/21 1:23 PM, Chris Green wrote:
> If I have set dhcp-optsdir in /etc/dnsmasq.conf and add a file to the
> directory it points to I assume any extra configuration in the added
> file will 'just happen' without any restart or signalling of dnsmasq.
> However (like the description for dhcp-hostsdir I presume that an
> option I have added as above will not be removed if I delete the added
> file.  Specifically if I put a dhcp-range option in the added file
> (when there wasn't one in /etc/dnsmasq.conf) the DHCP server in
> dnsmasq will be turned on, but removing the file won't turn the DHCP
> server off again.  I'd need to restart dnsmasq to turn the DHCP server
> off (or would one of the signals suffice?).
I believe this is correct.
> I'm thinking of running dnsmasq on two systems on my LAN to provide
> some resilience.  One will be configured to run DHCP as well as DNS,
> the other will be DNS only.  Apart from DHCP the configurations
> will be identical and the IPs of both systems will be given by the
> DHCP server as DNS IPs.

This works if your DHCP server only hands out static addressing so the 
host names are all listed in the /etc/hosts or addn hosts location on 
both machines.   If the DHCP server is handing out addresses from a 
pool, then only the DHCP dnsmasq instance will know about those hosts by 

You could try to add a referral from the second host to the DHCP host 
for any local domain lookup

server=/mydomain.com/ # IP of DHCP dnsmasq server
server=/101.168.192.in-addr.arpa/ # handle reverse lookups

This should allow both machines to respond with the same data but it 
requires both to be up.

> So the normal 'everything working' situation will be system A (say on
> is a DNS and DHCP server.  System B (say on
> provides only DNS.  System A's DHCP server will give out both
> and as DNS servers.
> If fails or is off line everything continues to work OK
> except maybe some slowing down of DNS because of requests to
> having to timeout before retrying on
> If fails I will add the DHCP configuration to it
> 'manually' and then I'll have a working system while I fix

I think it is important to understand the DNS doesn't really have the 
concept of primary and secondary nameservers.    They are all expected 
to be equal and the client can choose which one it wants to try.   So, 
your servers have to have the ability to give the same responses or you 
will go crazy trying to figure out why somethings aren't working right.

In your scenario, you could sync the leases file over regularly as a 
backup.   Then when the failure occurs, you would update the secondary 
box to add the dhcp options, stop the redirection above, and begin 
owning/managing the DHCP leases file.   When the primary comes back 
online, you have to reverse the whole process or leave it this way until 
the next failure, but sync the files the other way.


More information about the Dnsmasq-discuss mailing list