[Dnsmasq-discuss] What I thought was a clever idea
with --dhcp-optsfile didn't work out.
simon at thekelleys.org.uk
Sat Jan 3 20:21:23 GMT 2009
John R. Graham wrote:
> I had what I thought was a clever idea to get dnsmasq to re-read it's whole
> dnsmasq.conf file when it received a SIGHUP signal. I invoked dnsmasq with
> the following command line options:
> -i eth0 --conf-file=/etc/dnsmasq.once.conf
> The dnsmasq.once.conf file was basically empty except for the single line
> My hope was that this would cause the dnsmasq.conf file to be read at
> startup but this doesn't appear to be the case. Nor does it appear to be
> read when a SIGHUP is sent to dnsmasq. So, I tried a variation. I added
> to the dnsmasq.once.conf file. However, this created its own problems.
> Whenever dnsmasq was restarted, I started getting error messages of the form
> bad dhcp-option at line xx of /etc/dnsmasq.conf
> So, my question is, is what I'm trying to do a *bad* idea or am I just doing
> it wrong?
You can't get dnsmasq to re-read its configuration when it gets SIGHUP:
there is stuff in there that can only be changed if the program is still
running as root, and once started, dnsmasq drops root privs for security
reasons. There is a limited amount that can be done using dhcp-hostsfile
and dhcp-optsfile, these can contain stuff that would otherwise be in
the main config file as dhcp-host or dhcp-option, and are re-read on SIGHUP.
so, instead of having
in /etc/dnsmasq.conf, put
in /etc/dnsmasq-hosts and
Now you can re-write /etc/dnsmasq-hosts and have it re-read. The same
goes for dhcp-option and dhcp-optsfile.
/etc/hosts and /etc/ethers are also re-read on SIGHUP. Often they are
Finally, dnsmasq doesn't keep much state, there's not much to be lost in
re-starting it, if needed.
More information about the Dnsmasq-discuss