Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 1.16 KB

README.md

File metadata and controls

57 lines (41 loc) · 1.16 KB

libnss_homehosts

Linux NSS library supporting per-user hosts resolution using ${XDG_CONFIG_HOME}/hosts or ~/.hosts

Install

  • Compile the code:
$ make
  • Install the resulting library:
$ sudo make install
  • Preprend the NSS module to the hosts line of /etc/nsswitch.conf:
hosts: homehosts files dns

Uninstall

  • Uninstall the library:
$ sudo make uninstall
  • Remove the added module from /etc/nsswitch.conf.

Usage

  • Create ~/.hosts file and put some host names in it like /etc/hosts:
127.0.0.1  myhost.example.net
  • Check it
$ getent hosts myhost.example.net
$ ping myhost.example.net

Note that looking up the using host or nslookup will not work as these tools query DNS directly, sidestepping NSS.

Performance

It is better to have FQDN as in /etc/hosts, as well in ~/.hosts files, eg.

  198.18.1.1 frodo.baggins.theshire

instead of

  198.18.1.1 frodo

in order to avoid dns suffix-list expansion by libresolv when unneccessary.

Refer to ndots option at resolv.conf(5).

issues

Please submit issues via PR to some file <TITLE>.txt or <TITLE>.md on issues branch.