[Dnsmasq-discuss] What I thought was a clever idea
with --dhcp-optsfile didn't work out.
Simon Kelley
simon at thekelleys.org.uk
Sat Jan 3 20:21:23 GMT 2009
John R. Graham wrote:
> Hi.
>
> 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
>
> dhcp-optsfile=/etc/dnsmasq.conf
>
> 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
>
> conf-file=/etc/dnsmasq.conf
>
> 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
dhcp-host=mymachine,192.168.0.1
in /etc/dnsmasq.conf, put
mymachine,192.168.0.1
in /etc/dnsmasq-hosts and
dhcp-hostsfile=/etc/dnsmasq-hosts
in /etc/dnsmasq.conf.
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
enough.
Finally, dnsmasq doesn't keep much state, there's not much to be lost in
re-starting it, if needed.
HTH
Simon.
More information about the Dnsmasq-discuss
mailing list