"Refresh dnsmasq" button under Settings > System

Hey there,

what about adding another button directing to

killall -s SIGHUP dnsmasq

to the Settings>Systems folder in order to reload stuff as stated in the manpage of dnsmasq, i.e.

When it receives a SIGHUP, dnsmasq clears its cache and then re-loads /etc/hosts and /etc/ethers and any file given by --dhcp-hostsfile, --dhcp-optsfile or --addn-hosts. The dhcp lease change script is called for all existing DHCP leases. If --no-poll is set SIGHUP also re-reads /etc/resolv.conf. SIGHUP does NOT re-read the configuration file.

@DL6ER This shouldn't be all that much to implement. SIGHUP should just reload the configs and not affect DNS resolution so there shouldn't need to be an additional DNS check, should there?

From my point of view changing the config can always affect the resolution. Think about adding/removing nameservers or modifying the add-hosts lists. But for some modification there is no need for restarting dnsmasq "completely", i.e. changing some entries in /etc/host or the other file mentioned in the options man, explicitly for changing /etc/pihole/gravity.list,/etc/pihole/black.list and
/etc/pihole/local.list as done for updating the list, as they are integrated with addn-hosts. If the update of lists is already propageted via SIGHUP, this function might also made visible for users.

By "affecting DNS resolution" I was meaning to refer to the lack of dnsmasq being able to resolve names. I wanted to make sure that we didn't have to account for the possibility of the name services being offline and requiring tests to make sure that resolution worked before the function exited.

I think it's less critial for the "refresh" than it is for "restarting" the dnsmasq, as restarting includes the reloading of the files. This is the way iI understand the mentioned option.

I just tried reloading with sending SIGHUP:

Jan 24 21:35:45 dnsmasq[11735]: read /etc/hosts - 13 addresses
Jan 24 21:35:45 dnsmasq[11735]: read /etc/pihole/local.list - 9 addresses
Jan 24 21:35:45 dnsmasq[11735]: read /etc/pihole/black.list - 24 addresses
Jan 24 21:35:47 dnsmasq[11735]: read /etc/pihole/gravity.list - 206772 addresses
Jan 24 21:35:47 dnsmasq-dhcp[11735]: read /etc/openvpn/ipp.txt

Then I also tried service dnsmasq restart:

Jan 24 21:39:41 dnsmasq[12549]: started, version 2.76 cachesize 500000
Jan 24 21:39:41 dnsmasq[12549]: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth DNSSEC loop-detect inotify
Jan 24 21:39:41 dnsmasq[12549]: warning: ignoring resolv-file flag because no-resolv is set
Jan 24 21:39:41 dnsmasq-dhcp[12549]: DHCP, IP range 192.168.2.100 -- 192.168.2.251, lease time 1d
Jan 24 21:39:41 dnsmasq[12549]: using nameserver 2620:fe::fe#53
Jan 24 21:39:41 dnsmasq[12549]: using nameserver 2001:1608:10:25::9249:d69b#53
Jan 24 21:39:41 dnsmasq[12549]: using nameserver 2001:1608:10:25::1c04:b12f#53
Jan 24 21:39:41 dnsmasq[12549]: using standard nameservers for domain st.de
Jan 24 21:39:41 dnsmasq[12549]: read /etc/hosts - 13 addresses
Jan 24 21:39:41 dnsmasq[12549]: read /etc/pihole/local.list - 9 addresses
Jan 24 21:39:41 dnsmasq[12549]: read /etc/pihole/black.list - 24 addresses
Jan 24 21:39:44 dnsmasq[12549]: read /etc/pihole/gravity.list - 206772 addresses
Jan 24 21:39:44 dnsmasq-dhcp[12549]: read /etc/openvpn/ipp.txt

I don't see a real difference (else than that the restart is much more verbose)

So, I see at least a new pid at restart, with all it's implications, e.g. a longer off-time, reallocating resources etc.pp. But, nevertheless I am a fan of the minimal-priciple: why to restart a service, if a refreshing is faster and does the same. I would recommend a refresh for updateing the lists instead of restarting the service, when there is not need to do so. Just my 2 ct.

Edit: Refresh is implemented for update of lists.

What use case would this support? If a user is modifying files such as /etc/hosts, they are already on the command line and can run the command (or pihole restartdns if not the SIGHUP one). All the list commands (and other relevant commands) already send the correct signal to refresh the lists.

I always have to google for those commands :face_with_raised_eyebrow: wouldn't it be nice to have an editor in the frontend to modify the mentioned files, too (Feature Requests).

Note that there is also

pihole restartdns reload

:slight_smile:

But the point is taken, we don't really document the commands all that well. I'm working on man page and help docs in the commands so that you don't need to dig through a web search or read the code to get a proper command reference.

1 Like

you've got me there.

Does the Restart dnsmasq button satisfy this Feature Request?

Implemented.