In an article on parental control of OS X, namely blocking children from accessing myspace.com, Dave Taylor proposes using the /etc/hosts file to accomplish the task. While experimenting with the method I found that I was unable to control the process, no matter what the contents of /etc/hosts.
After much trial and error I discovered that it is the lookupd process that needs to be restarted in order to respect changes to the /etc/hosts file. A reboot will accomplish the same thing, but twiddling my thumbs for several minutes through a shutdown and startup routine was not an acceptable solution.
In case anyone else has the same problem, here is the breakdown of this two-step process:
The default /etc/hosts file looks like this:
To block both http://myspace.com and http://www.myspace.com add a line such as 127.0.0.1 myspace.com www.myspace.com. Fire up Terminal.app and enter these commands:
Now you need to fire up Activity Monitor (Located in OS X's /Utilities folder) and force quit the process named lookupd. You will need to enter your administrator password.
Fire up a web browser and enter http://www.myspace.com. You should now find that the browser is redirected to the localhost at 127.0.0.1. This will be the contents of OS X's /Library/Webserver/Documents/ folder.
Reversing the procedure
First you need to remove the myspace line from /etc/hosts. Head back to Terminal and reissue the pico command you used earlier:
You now need to again launch the Activity Monitor and force quit the process named lookupd. You will need to enter your administrator password again.
Open up a new web browser window and enter http://www.myspace.com. The browser should once again connect as usual.
http://thoughton.co.uk/cgi-bin/mt-tb-dlosx.cgi/202