Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to change /etc/hosts to change a local DNS entry, so I can map any website name to any IP, but it isn't working. How can I debug it?

share|improve this question
The file name you need to edit is /etc/hosts (not host). You need root permission to edit the file. – Manula Waidyanatha Sep 24 '12 at 9:34
Can you better explain what it is that you're trying to do with websites? – Karlson Sep 24 '12 at 12:40
@Karlson I am trying to change local dns at my computer so that i can open facebook.com by entering www.google.com in browser and mapping google.com with the ip of facebook.com in hosts file. – Rahul Kumar Dubey Sep 25 '12 at 15:06
@RahulKumarDubey So you are doing this on the workstation accessing the internet? – Karlson Sep 25 '12 at 15:22

Check /etc/nsswitch.conf and make sure on the hosts line, files is the first option and not dns

share|improve this answer
please explain in detail about /etc/nsswitch.conf and how it is related to /etc/hosts file ?? – Rahul Kumar Dubey Sep 25 '12 at 15:10
@RahulKumarDubey man nsswitch.conf – Karlson Sep 25 '12 at 15:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.