2009-07-14

Editing the Hosts file on a MacBook Pro

For someone in my line of work the Hosts file on a windows system has been essential in some cases. In short the file works as a DNS just for my computer. This means that I can use file to change the destination ip of a certain address. As an example I can change http://www.google.com to point to 127.0.0.1 or whatever if I want. All I have to do is add the ip and url in my host file and then clear the cache by opening a command promt and typing "ipconfig /flushdns".

I have now set out to do the same thing on a Mac and this is how it is done:
  • Open a terminal window
  • Type "sudo nano /private/etc/hosts"
  • Enter administrator password
  • Do the changes you want to the hosts
  • Press ctrl-X to save and confirm this and then ENTER to confirm saving
To try this out you can type "ping www.google.com" and check what ip the answer to the request comes from.

1 comment:

gaby marcos said...

thanks for sharing!! very useful info :)