How to change /etc/hosts

It’s useful to change /etc/hosts, especially with protections requesting online keys. After editing /etc/hosts you need to refresh OS X NetInfo Database. Just run the following command:

$ sudo niload -v -m hosts . < /etc/hosts

And then flush cache with:

$ lookupd -flushcache

For Snow Leopard the command has changed. It is now:

$ dscacheutil -flushcache

And that’s it!