/etc/hosts handling plugin for unbound
Paul Wouters
paul at nohats.ca
Mon Dec 19 16:39:40 UTC 2022
On Mon, 19 Dec 2022, Petr Menšík via Unbound-users wrote:
> Is there some plugin for automatically watching /etc/hosts file for changes
> and loading them as a local data?
>
> I am thinking about supporting unbound as a default localhost cache. But I
> think many people rely on /etc/hosts changes are propagated automatically to
> the cache. Dnsmasq and systemd-resolved both try to watch this file and
> re-read it after changes.
>
> Is there any existing way to populate local data automatically from it? Is it
> already possible to synchronize local data in unbound with legacy text file?
Any real software uses /etc/nsswitch.conf which states something like:
hosts: files myhostname mdns4_minimal [NOTFOUND=return] dns
The "files" directory (see man nsswitch.conf) reads in /etc/hosts first.
This happens before the "dns" entry, so before unbound is used. So for
apps on localhost this should work fine? It is always read (and not
cached)
But I guess you want to make it systemd-resolved+glibc hack compatible,
where calls to gethostbyname() are intercepted outside of nsswitch by a
linux glibc hack, then fed to systemd-resolved, which I guess might do the
wrong thing by using dns before files ?
Or are you trying to work with the libunbound call of:
/* lookup from /etc/hosts before DNS lookups as people expect that */
ugh = ub_ctx_hosts(dns_ctx, "/etc/hosts");
and are afraid changes in /etc/hosts are not picked up without an
unbound restart?
I guess I feel /etc/hosts is there only for localhost apps in case of
broken DNS. The days you could leave something out of DNS by putting in
the /etc/hosts file are kinda long gone.
Perphaps you can detail a bit more of what you are looking for and what
you are afraid of ?
Paul
More information about the Unbound-users
mailing list