Blocking Unwanted Connections with a Hosts File
You can use a HOSTS file to block ads, banners, 3rd party Cookies, 3rd party page counters, web bugs, and even most hijackers. This is accomplished by blocking the connection(s) that supplies these little gems. This is a simple script that downloads a new hosts file for your operating system and redirects all requests for unwanted connections to 127.0.0.1.
The new hosts file will reduce your bandwidth usage.
The following script will download the new hosts file, make a backup of your current file before the new hosts file is being used.
The new file will be used immediately after you have copied it. You can revert to your old hosts file by copying it back.
#!/bin/bash
wget -O /tmp/new-hostsfile.txt http://winhelp2002.mvps.org/hosts.txt
mv /etc/hosts /etc/hosts.backup
mv /tmp/new-hostsfile.txt /etc/hosts
A more detailed description of the script can be found on http://winhelp2002.mvps.org/hosts.htm.
This has been tested in Ubuntu 13.04 but will work on any operating system that uses a /etc/hosts file, like Windows and linux.