Fun with Hosts

FAIL (the browser should render some flash content, not this).

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


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I am getting a

Anonymous's picture

I am getting a su:authentication failure , and how to do it using a sudo cmd. ty for the article :)

hackers know....

hoizonE's picture

hackers know that subverting the hosts file and dns's is as simple as using the ``host'' command and/or typing the url as
[http[s]?://] ip1.ip2.ip3.ip4 [:<80|8080|443>]

and when i say "hackers," what i mean is "kids trying their damnedest to access myspace"

they also happen to know that googling for will take them to a site that allows the finding of any dns/registrant info from a remote machine (ie. one that is not affected by the /etc/hosts or local dns changes). many other sites share this site ability (including most search tools, themselves).

and why not introduce this specific ability (changing expected hosts) from, say, iptables? that way, not only can you change the destination of, but you can also log access attempts and log successful bypasses of the rule...

linux is not the only OS that has this nice little trick (M$, Sol, HPUX, BSD, et al., also have a hosts file to abide to).

microsoft doesn't exist!

Anonymous's picture

awesome. Now I can block websites on Linux without squid!

Oh, and I can make =


RE: Better ways...

Joe Tole's picture

Oh and djbdns keeps logs of all requests if you are really concerned about your kids going to I know I would be. :O

Better ways...

Joe Tole's picture

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 has address has address has address

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/ which contains the IP address "" where tinydns is listening and then create these entries in /etc/tinydns/root/data:

This will redirect all requests to to the google IP address including, and even Wildcards FTW! ;)

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState