NSS-Userhosts

NSS-Userhosts is a plugin for Name Service Switch (NSS) that allows to define user specific hosts in ~/.hosts using /etc/hosts syntax.

Installation for Ubuntu 64bit

wget http://www.trueoffice.org/raw-attachment/wiki/nss-userhosts/nss-userhosts_0.1-1_amd64.deb
dpkg -i nss-userhosts_0.1-1_amd64.deb

Installation from source

wget http://www.trueoffice.org/raw-attachment/wiki/nss-userhosts/nss-userhosts-0.1.tar.gz
tar -xvf nss-userhosts-0.1.tar.gz
cd nss-userhosts-0.1
./bootstrap.sh
make
make install

To activate the NSS-Userhosts plugin you have to edit /etc/nsswitch.conf and add 'userhosts' to the line starting with "hosts:". It looks like this:

# /etc/nsswitch.conf
passwd:         compat
group:          compat
shadow:         compat

hosts:          files userhosts mdns4_minimal [NOTFOUND=return] dns mdns4
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

Now, you can add some hosts to your user's ~/.hosts:

127.0.0.1 localexample localexample2

Then:

$ ping -c 1 localexample2
PING localexample2 (127.0.0.1) 56(84) bytes of data.
64 bytes from hostname (127.0.0.1): icmp_req=1 ttl=64 time=0.089 ms

--- localexample2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.089/0.089/0.089/0.000 ms

TODO: Add "site.sh"

Attachments