Setting up DNS to block Ad Sites
From LinuxServerTech
The Problem
Many sites have ads on them to generate revenue. This is not bad in and of itself (they need to support themselves somehow), but when the page is filled with ads, all of which are using rich content, the speed of your download (and of the Internet in general) goes down. In many cases, information is gathered about you every time you visit these sites so the Ad agencies can gather statistics to help them sell you things better. The down side of these ads follows:
- Lack of Privacy:
Tracking Cookies on many of the ad sites will track your travels as you surf the 'net, learning from what you have done before to determine what ads to put up for you. Not bad, in and of itself, but this is similar to someone following you around throughout your day, taking notes on everything you do. - Waste of Bandwidth:
In many cases, over 50% of the total size of a web page is taken up in ads. Even if there is only one small ad, many of these ads use flash, animated gif's, and even javascript to add much more download than an entire page of information and pictures. You are paying for this bandwidth (directly or indirectly), and it is being used to and sell things to you. - Viruses and Spyware:
As stated above, in some cases scripts and tracking cookies are placed into these ads. It is definitely feasible to attack your computer through these. In many cases, innocent visitation to web sites that turn out to be pornographic can result in an infection on your computer. - Common Decency
The Solution
There is a list of sites available http://www.ssmedia.com/utilities/hosts/ that can be quite easily blocked from any computer; not just a DNS server. The documentation on the link above will show you how to do this. It is actually very easy for all OS's.
What you are basically doing is "spoofing" the DNS; you are telling the DNS that the IP addresses to the servers that deliver these ads are located somewhere other than where they really are. The standard way of doing this is to use an address of 0.0.0.0 (which is reserved and doesn't exist) or 127.0.0.1, which is reserved and means your local machine.
Most computers (workstations and servers) are set up to look in a special hosts file before looking in DNS to resolve a name into an IP address. You can see the order on Linux machines by looking for a line that says order hosts,bind in the file /etc/hosts.conf. If this is in there, or if the line doesn't exist, it will most likely look in the /etc/hosts file before asking DNS to resolve a name into an IP address.
We can spoof the DNS by putting entries for all ad sites in there. The standard that ssmedia has is to spoof all ad sites to point to your local computer. When you click on the link to create/update Hosts file, you will get a list that looks similar to this (the 127.0.0.1's will be replaced with 0.0.0.0 if you select that option).
127.0.0.1 000freexxx.com 127.0.0.1 039068a.dialer-select.com 127.0.0.1 1.httpads.com 127.0.0.1 1000stars.ru
Simply take that entire page (Select All, then Copy to clipboard) and open your /etc/hosts file and paste those values into it at the bottom of the file. That last part is very important; do not past this at the beginning or middle of the file.
Note: this is a very large entry, and definitely not normal. However, the speed-up of visiting web sites is enormous.
Result
When you visit a site that has ads on it, you will either see nothing, or you will see some error messages where the ads used to be. You will also find these web sites download very, very fast.
