userhosts - Redirects accesses to /etc/hosts to another file.
The need is to customise hostname (reverse )resolution for a single process (and potentially its children), potentially resolving conflicting domain names to different addresses and vice-versa.
libnss' HOSTALIASES feature only allows mapping between domain names, not between names and addresses, so it is not powerful enough.
This library relies on LD_PRELOAD mechanism, so it inherits its limitations (it will not work on suid binaries, ...).
- a C compiler
- glibc (source uses RTLD_NEXT)
Just run "make".
$ HOSTS=/path/to/custom/hosts LD_PRELOAD=/path/to/userhosts <command>
userhosts is also an executable wrapper that appends itself to LD_PRELOAD:
$ HOSTS=/path/to/custom/hosts userhosts <command>