Is it possible to configure user specific hosts file instead of a common /etc/hosts.
For example if user "user1" tries to get the name for the IP: "127.0.0.1", he gets "dev.user1" and if user "user2" tries to get the name for the same IP, he gets "dev.user2".
What problem are you trying to solve?
You certainly can't have two different entries in a hosts file, that are somehow toggled depending on which user you are.
If you tell us what you're trying to do, rather than ask us about your specific implementation, we may be able to help more.
No, you cannot have a per-user /etc/hosts file, or anything like /home/user1/.hosts , etc.
You are using gethostbyaddr which is hardcoded to follow the instructions in nsswitch.conf, which itself tells gethostbyaddr to look in /etc/hosts .
You might be able to do something like add additional loopback IPs on the 127.0.0.0/8 network, like 127.0.0.2 , 127.0.0.3, 127.1.2.3, and then assign a local hostname to one of these local IPs. We did this at one job, but I remember that this really confused our engineers.
Also, if I remember right some loadbalancers actually do this internally.
Here's an example /etc/hosts to illustrate my point:
As @blacklotus suggested earlier, the more common way to do this is to designate part of your local network as a "Developer LAN".
Why don't you assign some virtual ips to your own server instead at eth0:0, eth0:1 etc?
Say assign 192.168.2.10 to dev.user1, and 192.168.2.11 to dev.user2. When you access the projects via different ips, would gethostbyaddr() return the hostname accordingly?