| Author |
Message |
linuxcbon
Joined: 09 Aug 2007 Posts: 693
|
Posted: Sat 14 Apr 2012, 02:00 Post subject:
How to manually block advertisements with /etc/hosts |
|
How to manually block advertisements with /etc/hosts
Start a fresh Seamonkey (no cookies, empty cache).
Open a web site for example : news.com.au
Then open in another tab : about:cache?device=memory
You will see many entries.
Note which are advertisements.
Open /etc/hosts
Add the entries to be blocked.
For instance add the line :
0.0.0.0 pagead2.googlesyndication.com
Save.
Do this for all your favorite websites.
You will see cleaner and faster pages.
|
|
Back to top
|
|
 |
Dave_G

Joined: 21 Jul 2011 Posts: 459
|
Posted: Sat 14 Apr 2012, 09:48 Post subject:
|
|
Nice tips linuxcbon.
It can however be applied to pretty much any browser and O.S.
I generally detest adverts when browsing for two reasons:
1) Wastes my time
2) Wastes my bandwidth/cap.
I do make one or two exceptions and one being the advert shown on this forum.
It takes money to maintain and host a site like this one and since it helps me,
I don't block ads here.
Once you know which ads you want to block, simply edit your hosts file
and presto, no more annoying adverts.
The location of your hosts file will differ depending on your O.S.
A few examples:
For NT, Win2K & XP, it's located in "C:\windows\system32\drivers\etc\hosts"
or "C:\winnt\system32\drivers\etc\hosts"
For Windows 7 & Vista, it's in "C:\windows\system32\drivers\etc\hosts"
or "%systemroot%\system32\drivers\etc\hosts"
Keep in mind that if you have anti-virus software running (M$ Security Essentials included),
you will have to either temporarily disable the anti-virus software or allow the change.
For Linux, simply search for /etc/hosts
Remember that for non-root distros such as Ubuntu, you will first have to run as root.
For Mac, I have no idea.
When editing the hosts file, always use the top level domain name
such as:
0.0.0.0 www.google-analytics.com
and not:
0.0.0.0 http://www.google-analytics.com/ga.js
Depending on your setup, you may also have to replace 0.0.0.0 with 127.0.0.1
Of course this method is not limited to blocking just adverts and can be
used to protect other members of your household from "nasty" sites.
There are plenty of lists on the net for all sorts of unsavoury websites
which you can add to your hosts file.
Happy surfing.
|
|
Back to top
|
|
 |
Dave_G

Joined: 21 Jul 2011 Posts: 459
|
Posted: Tue 17 Apr 2012, 05:01 Post subject:
|
|
If you use Yahoo and don't want all the pics and flash ads all over the place,
add the following entries to your hosts file:
0.0.0.0 l1.yimg.com
0.0.0.0 l.yimg.com
0.0.0.0 row.bc.yahoo.com
You may have to add a few more that Yahoo uses for it's localisation
depending on which country you're in.
It now loads in a quarter of the time, admittedly it does not look as pretty but
saves a lot of bandwidth by not loading all that "eye-candy".
To "tame" Google:
0.0.0.0 googleads.g.doubleclick.net
0.0.0.0 pagead2.googlesyndication.com
This is not an exhaustive list and I'm sure they use plenty of others.
Great for mobile devices.
Apparently the hosts file is located at /system/etc/hosts for the Android OS.
Anyone know where it is for other devices such as the iPad/phone, blackberries, etc etc?
EDIT:
Whilst searching around for the location of the hosts file for the iPad,
I went to stackoverflow and found something, not good news:
http://stackoverflow.com/questions/4783923/can-i-edit-an-ipads-host-file
Also got pretty fed up with the ads there so here are some more entries:
0.0.0.0 engine.adzerk.net
0.0.0.0 static.adzerk.net
EDIT 2:
If you want to watch a YouTube video without the big advert on the top
right hand side, add:
0.0.0.0 googleads.g.doubleclick.net
If you don't want to see the icons of the other clips (on the RHS), add:
0.0.0.0 i1.ytimg.com
0.0.0.0 i2.ytimg.com
0.0.0.0 i3.ytimg.com
0.0.0.0 i4.ytimg.com
See the attached screen shot.
Now YouTube loads much faster.
 |
| Description |
|
| Filesize |
102.68 KB |
| Viewed |
502 Time(s) |

|
|
|
Back to top
|
|
 |
Dave_G

Joined: 21 Jul 2011 Posts: 459
|
Posted: Wed 25 Apr 2012, 06:28 Post subject:
|
|
For those that use stackoverflow.com regularly, they have a new ad server
so put this in your hosts file and save same time and bandwidth.
0.0.0.0 altfarm.mediaplex.com
|
|
Back to top
|
|
 |
linuxcbon
Joined: 09 Aug 2007 Posts: 693
|
Posted: Thu 14 Mar 2013, 22:55 Post subject:
|
|
Two more things :
1/ how to sort the hosts file alphabetically :
# sort +1 -2 /etc/hosts > toto.txt
toto.txt is the new sorted file.
2/ then you can remove duplicates from toto.txt and update hosts :
uniq toto.txt > /etc/hosts
|
|
Back to top
|
|
 |
Ted Dog

Joined: 13 Sep 2005 Posts: 983 Location: Heart of Texas
|
Posted: Thu 14 Mar 2013, 23:18 Post subject:
|
|
great hints, still trying to figure how google gets cookie drop when google is blocked. Figure some 'sites' are hardcoding ip addresses in http source and that is how it happens.
|
|
Back to top
|
|
 |
watchdog
Joined: 28 Sep 2012 Posts: 119
|
Posted: Fri 15 Mar 2013, 07:29 Post subject:
List of hosts |
|
I suggest to use the .txt file from:
http://msmvps.com/blogs/hostsnews/default.aspx
to block by /etc/hosts most common adverts.
|
|
Back to top
|
|
 |
linuxcbon
Joined: 09 Aug 2007 Posts: 693
|
Posted: Fri 15 Mar 2013, 19:44 Post subject:
Re: List of hosts |
|
This has nothing to do with this howto.
Here is explained how to write your file "manually", so you have full control. I recommend you do it yourself manually.
|
|
Back to top
|
|
 |
|