I am struggling for a few days to configure dnsmasq to automatically reload or take into knowledge the new hosts added to /etc/hosts or to another configured file /etc/hosts.dnsmasq
.
Is this even possible?
dnsmasq
I am struggling for a few days to configure dnsmasq to automatically reload or take into knowledge the new hosts added to /etc/hosts or to another configured file /etc/hosts.dnsmasq
.
Is this even possible?
Best Answer
There are two ways to cause dnsmasq to reload a hosts file:
As Aaron Copley noted in his comment, send
SIGHUP
to dnsmasq. From the man page:Note that dnsmasq doesn't restart in this case, but it does re-read a number of other files (and calls the dhcp lease change script for all existing DHCP leases). If triggering reloads too quickly is a concern, you can debounce the signal.
Use the
--hostsdir
option. Again from the man page:For reference, here is the documentation for
--dhcp-hostsdir
:This has a few advantages compared to the first option: dnsmasq will re-read the host file(s) automatically, no
SIGHUP
required, and; only the host files are reloaded, no other actions are taken.One potential disadvantage is that, as the documentation for
--dhcp-hostsdir
points out, new host entries are dynamically added but deleted or changed entries are not updated. Simon Kelley, the author of dnsmasq, has confirmed that this is by design.