Fun with Hosts
April 6th, 2009 by Shawn Powers in
How to edit your hosts file to redirect urls, which is a fun way to play pranks at work or keep your kids off myspace!
Download in .ogv format
__________________________
Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter
Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer
Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.
Subscribe now!
The Latest
Newsletter
Tech Tip Videos
- Apr-08-09
- Apr-07-09
- Apr-06-09
- Apr-02-09
Recently Popular
From the Magazine

May 2009, #181
We don't own the desktop yet but we do own the first ever Nobel Prize in Cool. Cool Projects that is, we've got a Linux powered rocket and a Linux powered submarine. Plus we show you how to use the iRobot Create with Linux, how to convert those old 8mm movies to DVD with Linux, and how to control your house with Linux and Mi Casa Verde.
After checking out the cool projects don't miss the rest of this cool issue and read how to run Rails under Apache using Phusion Passenger, how to build a secure Squid Web Proxy, how to use OpenFiler to create an open-source network storage appliance, and if just typed "rm -rf /" find out what to do and what not to do in our continuing series of "When Disaster Strikes" articles. And don't miss our interview with Neuros CEO Joe Born or Doc's monthly words of wisdom.
microsoft doesn't exist!
On April 6th, 2009 Anonymous (not verified) says:
awesome. Now I can block websites on Linux without squid!
Oh, and I can make microsoft.com = youareanidiot.org.
w00t...
RE: Better ways...
On April 6th, 2009 Joe Tole (not verified) says:
Oh and djbdns keeps logs of all requests if you are really concerned about your kids going to microsoft.com. I know I would be. :O
Better ways...
On April 6th, 2009 Joe Tole (not verified) says:
When looking up a host name, you can use the command host or dig instead of ping. Ping sends extra data to the host when all you need is an IP address.
host -t a google.com
google.com has address 209.85.171.100
google.com has address 74.125.67.100
google.com has address 74.125.45.100
Also, DNS can be even more effective then a host file since DNS can do wildcards and afaik a host file cannot. djbdns is easy to setup for a cache (using dnscache) and tinydns as a resolver. You can tell dnscache to use a host of your choosing to resolve a domain name by creating a file named /etc/dnscache/root/servers/domain.tld with the IP. In this case you can run dnscache on your external IP and tinydns on your loopback. Create a file named /etc/dnscache/root/servers/microsoft.com which contains the IP address "127.0.0.1" where tinydns is listening and then create these entries in /etc/tinydns/root/data:
.microsoft.com:127.0.0.1:a
+microsoft.com:74.125.67.100
+*.microsoft.com:74.125.67.100
This will redirect all requests to anything.microsoft.com to the google IP address including www.microsoft.com, download.microsoft.com and even abc.def.ghi.jkl.microsoft.com. Wildcards FTW! ;)
Post new comment