Is it possible to add a list of hosts that are only specific to a certain user? Perhaps a user-specific hosts file?
This mechanism should also complement the entries in the
As far as I know there isn't. The easiest way to do what I think you want is to write an LD_PRELOAD library that overrides gethostbyname() and related functions.
The functionality you are looking for seems to be implemented in glibc. You can define a custom hosts file using the
Here is a modified example from http://blog.tremily.us/posts/HOSTALIASES/ that works on my system (Ubuntu 13.10):
The linked blog post also mentions some limitations:
Beside the LD_PRELOAD tricks. A simple alternative that may work on a few systems would be to binary-edit a copy of the system library that handles hostname resolution to replace
For instance, on Linux:
If you're not using
Binary-edit the copy to replace
For instance which would allow different commands to use different
AFAIK, There is nothing like that, and there is no reason to have something like that. There is a design problem if an admin think that he need a hosts file per user. Think about it: You can't hide a host just because you don't have it in /etc/hosts, you're reading more files when the system is initialized and maybe the difference between 2 users will be up to 5 hosts.
The right question is: Is there a good reason to want something like that?
Maybe the answer will say what kind of utility you really want
EDIT - Maybe this is a good conclusion: if you use your own domain as a domain name server (in DNS), you have just 1 table to map domains in the server. DNS does not work at user-level.
Not sure if this would help you, but I came here looking for a way to add saved "hosts" somewhere that was easily accessible to only my user.
I basically needed to be able to ssh into certain boxes on our work network, which only has one entry point.
What I did was add alias's to my .bashrc file.
For example, if you added:
at the bottom of the ~/.bashrc (~ is your home directory), then after you logout and login again, you can type "jrfbox" hit enter, and it will connect.
One solution is to have each user in a separate