nss-resolve
systemd
nss-resolve
8
nss-resolve
libnss_resolve.so.2
Hostname resolution via systemd-resolved.service
libnss_resolve.so.2
Description
nss-resolve is a plug-in module for the GNU Name Service Switch (NSS) functionality of the
GNU C Library (glibc) enabling it to resolve hostnames via the
systemd-resolved8 local network
name resolution service. It replaces the nss-dns plug-in module that traditionally resolves
hostnames via DNS.
To activate the NSS module, add resolveĀ [!UNAVAIL=return] to the line starting
with hosts: in /etc/nsswitch.conf. Specifically, it is
recommended to place resolve early in /etc/nsswitch.conf's
hosts: line. It should be before the files entry, since
systemd-resolved supports /etc/hosts internally, but with
caching. To the contrary, it should be after mymachines, to give hostnames given to
local VMs and containers precedence over names received over DNS. Finally, we recommend placing
dns somewhere after resolve, to fall back to
nss-dns if systemd-resolved.service is not available.
Note that systemd-resolved will synthesize DNS resource
records in a few cases, for example for localhost and the
current hostname, see
systemd-resolved8
for the full list. This duplicates the functionality of
nss-myhostname8,
but it is still recommended (see examples below) to keep
nss-myhostname configured in
/etc/nsswitch.conf, to keep those names resolveable if
systemd-resolved is not running.
Example
Here is an example /etc/nsswitch.conf file that enables nss-resolve
correctly:
passwd: compat systemd
group: compat systemd
shadow: compat
hosts: mymachines resolve [!UNAVAIL=return] myhostname files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
See Also
systemd1,
systemd-resolved8,
nss-systemd8,
nss-myhostname8,
nss-mymachines8,
nsswitch.conf5