Stevey.com

Stevey.com header image 1

Local HOSTS file

February 1st, 2008 · No Comments

Terminal

Ran into this tip this morning that might be very useful for some web people out there; How to edit your 10.5 HOSTS files to redirect/change how your computer sees the net and itself.

A typical scenario would be something like;
You are changing the hosting company for a website; you need to be able to see the new site with it’s domain name on the new server before you actually change the real DNS records.

Step by step for adding a HOST entry on Mac OS X 10.5 Leopard with DSCL

1. Open terminal
2. sudo dscl localhost -create /Local/Default/Hosts/ridiculous.nonsense.monkeys IPAddress 192.168.0.1
3. Enter your password when asked, and you can now ping 192.168.0.1 with the name ridiculous.nonsense.monkeys
4. You can see/verify the results of your work with: dscl localhost -readall /Local/Default/Hosts
5. http://ridiculous.nonsense.monkeys will now show you localhost

You can remove…

1. Open terminal
2. sudo dscl localhost -delete /Local/Default/Hosts/ridiculous.nonsense.monkeys
3. Enter your password when asked,
4. You can see/verify the entry has been deleted with: dscl localhost -readall /Local/Default/Hosts

Warning : I’m by far no expert on this, this worked for me but I can’t guarantee anything. Use at your own risk!

Tags: hacks + do it yourself · tech + the internet