Update: I’m recommending that you use 0.0.0.0 instead of 127.0.0.1. Please check the link to see the reasons and how to modify your hosts file. Also, if you do the changes, the ping command at the end of this article won’t work (it will say something to the effect of “Destination specified is invalid.”, but this is the expected behavior).
There is a very nice hosts file over at WinHelp2002’s page. If you don’t know what a hosts file is, check out the Wikipedia entry on it . It is basically a way to override the DNS lookup process and make sure that some domains resolve to a predefined IP address.
What the above mentioned hosts file contains is a list of known advertisement sites and associates it with localhost (127.0.0.1). That is, whenever your browser tries to connect to one of these servers (to fetch ads most probably), it will connect to your local machine and will return an error. You will find that this speeds up page loading considerably (for example it block around 70% of the advertisement in the new Yahoo mail which has the annoying tendency to refresh them every couple of seconds which can be killer on a slow connection).
The above page contains instructions for the different flavors of Windows, so here is the Ubuntu version of the instructions:
- Download the hosts file (if you downloaded the zipped version, extract it)
- Open hosts.txt in an editor
- Open a console and type
sudo gedit /etc/hosts. Provide your password.
- Copy from the first editor to the second editor the list of hosts
- Save and close the
One interesting sidenote:
nslookup bypasses the hosts file and it goes directly to the DNS server, so you can’t use it to check if the changes were correct. Use a tool like
ping instead. When doing
ping [a domain from the list] it should tell you something like
PING cc.webpower.com (127.0.0.1) 56(84) bytes of data
. If it says 127.0.0.1 then it worked.