s6-dns
Software
skarnet.org
The s6-dns-hosts-compile program
s6-dns-hosts-compile compiles the system's /etc/hosts file into a
CDB file for more efficient later use by s6-dns programs that may use the
data contained in the hosts file.
Interface
s6-dns-hosts-compile [ -i ifile ] [ -o ofile ]
- s6-dns-hosts-compile reads the /etc/hosts file, which must follow the
traditional hosts format.
- It outputs a CDB database in the /etc/hosts.cdb file.
- It exits 0.
Options
- -i ifile : read from ifile instead of /etc/hosts.
- -o ofile : write to ofile instead of /etc/hosts.cdb.
Notes
- The /etc/hosts file is an old way of specifying IP from/to domain
name correspondences. It's convenient in a pinch when a user needs to locally
override DNS data - for instance, to redirect common advertising sites to 127.0.0.1 -
but it does not map exactly to the DNS view of domain names.
- Due to this, and to its line-by-line text syntax, lookups using this file
are terribly inefficient and rely on approximate qualification heuristics.
- To avoid that, s6-dns tools prefer having the /etc/hosts data in
a format that's both more DNS-like and more efficient; the file output by
s6-dns-hosts-compile is the result.
- When asked to take /etc/hosts data into account, s6-dns tools will
first look for a /etc/hosts.cdb file and use the data from it. If
absent, they will read the /etc/hosts file and compile its contents
into a temporary cdb file under /tmp (which they immediately unlink),
and use that cdb to query hosts data.
- As a consequence, lookups are always efficient, but there's an initial
compilation step. Using s6-dns-hosts-compile to produce a /etc/hosts.cdb
file in advance saves the cost of that compilation step in subsequent
invocations of s6-dns tools.
- If s6-dns tools detect that /etc/hosts has been modified more recently
than /etc/hosts.cdb, they will not use /etc/hosts.cdb and will
perform the compilation step into a temporary file. So, remember to run
s6-dns-hosts-compile after modifying your /etc/hosts if you want to keep
the tiny performance improvement.
- Some tools write link-local addresses in /etc/hosts i.e. IPv6 addresses
followed by a % (percent) and a network interface name. This is nonstandard
and unusable with the DNS protocol, which does not take interface names into
account. s6-dns-hosts-compile will ignore such lines if they appear in
your hosts file.