Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ad-blocking with your hosts file
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
neenee
Veteran
Veteran


Joined: 20 Jul 2003
Posts: 1786

PostPosted: Wed Oct 01, 2003 8:25 pm    Post subject: ad-blocking with your hosts file Reply with quote

hi everyone,

while reading a reply in a thread about privoxy, i made a reply
about a different method i use to block ads myself. lovechild
(remember him? from the love-patch. woo!), replied and told
me it might be useful to post my hosts-addition and a small
accompanying text to explain what it is for and how it works.

so here i am, making that post.

what this addition does:

adding known ad-hosts to your hosts file, and listing them with
the ip 127.0.0.1, will make anything wanting to connect to that
ad-host, connect to 127.0.0.1 / localhost instead, which will
prevent the ad-image from being loaded.

in short: the ad will be blocked.

what's nice about this method, is that it does not require any
package to be emerged, or any service which might use up val-
uable resources while it does its thing.

furthermore, it is completely customizable, and ofcourse it's
very easy to do so; just open up your hosts file in any texteditor,
add any new host you come across, save the file and reload
your web-page or whatever you're seeing ads in.

how to make it work:

a) go here and download the hosts file.
b) copy the contents of the downloaded hosts file to your
/etc/hosts, while omitting the first line, which mentions localhost,
and possible others which you configured yourself.
c) save the file and you're done.

append, do not replace your hosts file.

enjoy the web, a lot more ad-free.

*update* thanks Aron for helping me keep this post useful ;-)


Last edited by neenee on Fri Dec 30, 2005 12:04 am; edited 3 times in total
Back to top
View user's profile Send private message
TheWart
Guru
Guru


Joined: 10 May 2002
Posts: 432
Location: Nashville,TN - USA

PostPosted: Wed Oct 01, 2003 9:28 pm    Post subject: Reply with quote

Thanks a ton!

This is great.
_________________
Face it, we are all noobs.

On the box it said it was designed for Win XP or better, so why won't it work with Linux?
Back to top
View user's profile Send private message
Jesse
Tux's lil' helper
Tux's lil' helper


Joined: 24 Apr 2002
Posts: 148

PostPosted: Wed Oct 01, 2003 10:49 pm    Post subject: Reply with quote

Is this really sane? It slows my webbrowsing to an utter crawl.
Back to top
View user's profile Send private message
neenee
Veteran
Veteran


Joined: 20 Jul 2003
Posts: 1786

PostPosted: Wed Oct 01, 2003 11:57 pm    Post subject: Reply with quote

it should not slow anything down; ofcourse
looking up hosts might take a fraction of a
second longer, but that's negligable.

if anything, it should speed up browsing
when ads are on a site, since their hosts
no longer have to be contacted and no
ad-images have to be loaded.
Back to top
View user's profile Send private message
Malakin
Veteran
Veteran


Joined: 14 Apr 2002
Posts: 1692
Location: Victoria BC Canada

PostPosted: Thu Oct 02, 2003 12:42 am    Post subject: Reply with quote

Quote:
Is this really sane? It slows my webbrowsing to an utter crawl.
With most browsers this actually speeds things up since it doesn't download the image. Some browsers take a while to timeout while trying to fetch the image though.

I used this technique for many years but ended up moving to Privoxy about 6 months ago. It took a little tweaking to get it working perfectly but now I'm totally happy with it. All sites I frequent are 100% ad free, browsing is faster since I'm not downloading all that garbage and fewer system resources are used since my 10 browser windows don't have all these extra images and flash ads in them. Using the hosts technique I was probably only able to block about 30% of the ads from sites I frequent.
Back to top
View user's profile Send private message
Squinky86
Retired Dev
Retired Dev


Joined: 25 Mar 2003
Posts: 309
Location: Alabama, USA

PostPosted: Thu Oct 02, 2003 6:03 pm    Post subject: Reply with quote

Malakin wrote:
With most browsers this actually speeds things up since it doesn't download the image. Some browsers take a while to timeout while trying to fetch the image though.


If you have such a browser, try to get apache going. If that's out of the question and you really don't want such a thing, point the adhosts to a real server that wouldn't mind giving out a trillion 404 messages.

If even that can't be done, use Mozilla :).
_________________
Me
Back to top
View user's profile Send private message
neenee
Veteran
Veteran


Joined: 20 Jul 2003
Posts: 1786

PostPosted: Thu Oct 02, 2003 6:20 pm    Post subject: Reply with quote

unless i am mistaken, there is no noticable
delay when a browser calls for an ad which
is in your hosts file pointing to localhost.

hm.. as for pointing to another host instead
of localhost; i doubt there are admins around
which would allow linking to their server like
this.

and linking to something else than localhost
would mean an increase in distance for the
fake ad-host traffic, which would increase
possible delays.
Back to top
View user's profile Send private message
RedBeard0531
Guru
Guru


Joined: 21 Sep 2002
Posts: 415
Location: maryland

PostPosted: Mon Oct 06, 2003 3:49 am    Post subject: Reply with quote

I know that this is an unpopular opinion, but this is a VERY bad idea. Those adds are there for a reason. that page that is giving you free information is trying to make somemoney, and is probrobly barley covering the bandwidth. Imagine if everyone did this. It might mean the end of the free internet. I have no problem blocking popups because they are annoying, but are the ad bars THAT annoying? Im not trying to preach, I just want to pointout some of the consequenses of this.
_________________
OH MY GOD! Kenny just killed Kenny!
That Basterd!
Back to top
View user's profile Send private message
GenKiller
n00b
n00b


Joined: 04 Mar 2003
Posts: 66
Location: United States of America

PostPosted: Mon Oct 06, 2003 4:12 pm    Post subject: Reply with quote

RedBeard0531 wrote:
I have no problem blocking popups because they are annoying, but are the ad bars THAT annoying? Im not trying to preach, I just want to pointout some of the consequenses of this.


In the same way I find those Flash and gif animations ads _extremely_ annoying. From what I've seen, the ads that are not pay-per-click ads the owner does not get a lot of money from, if any.

I think many people would agree that ad-blocking solutions would be completely unnecessary if there were rules stating no popups, animations, and sound.
_________________
http://www.digital-drip.com
Back to top
View user's profile Send private message
furanku
l33t
l33t


Joined: 08 May 2003
Posts: 905
Location: Hamburg, Germany

PostPosted: Mon Oct 06, 2003 6:43 pm    Post subject: Reply with quote

Hi RedBeard,

with the same logic you could say that we all should not zap around, talk, go to the toilet, talk, etc, during a commercial break in a TV show. Or to read all advertisments in a magazine.

It's legal for a company to try to get my attention to get some "informations" I don't want to know in my head. Therefore it's also legal for me to try to ignore that as good as I can.

I don't want to forbid advertisments, so I don't wanna be forced to see them.

Frank
Back to top
View user's profile Send private message
Malakin
Veteran
Veteran


Joined: 14 Apr 2002
Posts: 1692
Location: Victoria BC Canada

PostPosted: Mon Oct 06, 2003 6:58 pm    Post subject: Reply with quote

Quote:
unless i am mistaken, there is no noticable
delay when a browser calls for an ad which
is in your hosts file pointing to localhost.

Netscape 4 had problems with this, it would request the image and wouldn't draw the rest of the page until it got it, it would eventually time out and draw the rest of the page but the delay was large enough to make this approach unfeasable. It's possible this was fixed in the latest versions of 4.x but I don't think it was ever fixed. (netscape 6.x/7.x is a totally different browser and has no such problems)
Back to top
View user's profile Send private message
Balthasar
n00b
n00b


Joined: 25 May 2003
Posts: 62
Location: Florida

PostPosted: Tue Oct 07, 2003 9:45 am    Post subject: Reply with quote

I for one think this is great. I have better things to be doing with my time than trying to decipher where the ads stop and the page begins.

As for them not getting money, not many seem to anymore, way back when click through was great, I for one took advantage of them in my eariler webmaster days, never did generate much revenue, but the ads nowadays are pointless and normally point to sites that have nothing to do with what your looking for.

Thanks
_________________
"Trust the computer industry to shorten ‘Year 2000’ to ‘Y2K’. It was this kind of thinking that caused the problem in the first place."

Just because it's common sense, doesn't mean it's common practice. - Will Rogers
Back to top
View user's profile Send private message
Lovechild
Advocate
Advocate


Joined: 17 May 2002
Posts: 2858
Location: Århus, Denmark

PostPosted: Tue Oct 07, 2003 11:48 am    Post subject: Reply with quote

I started blocking all those porn banners - I don't mind technology related banners and text only ads, but I don't want to be bothered with porn pops up and flashy banners.. speaking of flash, that dies too.
Back to top
View user's profile Send private message
Jeedo
Apprentice
Apprentice


Joined: 02 May 2003
Posts: 202
Location: Akureyri, Iceland

PostPosted: Mon Nov 10, 2003 8:28 pm    Post subject: Reply with quote

also check out http://ssmedia.com/utilities/hosts/ (maybe it would be cool to merge the changes in those files)
Back to top
View user's profile Send private message
Jeedo
Apprentice
Apprentice


Joined: 02 May 2003
Posts: 202
Location: Akureyri, Iceland

PostPosted: Mon Nov 10, 2003 8:53 pm    Post subject: Reply with quote

i found out how to merge many host files:

[code]
cat file1 file2 | grep "^127.0.0.1" | sort | uniq >> merged_hosts_file
[ /code]

Do you know of any other files like this one to download and merge into one super-hosts file.
Back to top
View user's profile Send private message
furanku
l33t
l33t


Joined: 08 May 2003
Posts: 905
Location: Hamburg, Germany

PostPosted: Mon Nov 10, 2003 9:20 pm    Post subject: Reply with quote

Jeedo wrote:
(maybe it would be cool to merge the changes in those files)


That's easy to do. First bring the dowloaded files in the same format: Remove the comments in the beginngig and the end with an editor. The file mentioned by you uses whitespaces instead of tabs, the above mentioned uses tabs. Change the tabs in the new one using
Code:
$ unexpand -a hosts.cfm >hosts.cfm.tabs

Merge this and the above mentioned 'hosts' fils with cat, sort them and remove duplicated lines:
Code:
$ cat hosts hosts.cfm.tabs | sort | uniq >hosts.new

Append that file to your /etc/hosts (of course remove before the old ad blocking host list). I know that could be done in a more "pipe-guru-method" in one step, but it works this way. From the approx. 5700 hosts in the new file are just aprox. 840 which weren't in the old file.

Frank

Edit: oops, you've been faster ;)
Back to top
View user's profile Send private message
gdoubleu
Tux's lil' helper
Tux's lil' helper


Joined: 07 May 2003
Posts: 80

PostPosted: Tue Nov 11, 2003 9:43 pm    Post subject: Reply with quote

an alternative to messing with the hosts file if you have mozilla or firebird would be this beauty of an extension i recently came accross, http://adblock.mozdev.org/dev.html.

This development build actually prevents ads/flash/javascript from being downloaded (if you so choose), instead of just not being displayed as in previous versions.

The user defined filters can use either wildcards or regular expressions.

here are a few filters i use that block a considerable number of ads/banners:
Code:
/.*[/][Aa][Dd][SsVv]?[/._-].*/
/.*[/]banners?[/].*/

and one i use to block most avatars:
Code:
*avatar*
Back to top
View user's profile Send private message
Jeedo
Apprentice
Apprentice


Joined: 02 May 2003
Posts: 202
Location: Akureyri, Iceland

PostPosted: Tue Nov 11, 2003 9:48 pm    Post subject: Reply with quote

Howto merge:
Code:

cat HOSTS csuchico.edu-hosts my-hosts neenee-hosts ssmedia-hosts | grep "^127" | perl -pe 's/ {7}/\t/g' | perl -pe 's/\r//g' | sort | uniq


Urls to host files:
Quote:

http://cos.evilforums.com/~neenee/bin/ad_hosts.tar.gz
http://ssmedia.com/utilities/hosts/
http://www.ecst.csuchico.edu/~atman/spam/adblock.shtml
http://www.accs-net.com/hosts/get_hosts.html


With this i made a super-hosts file which combined all of the above into one large file.
Back to top
View user's profile Send private message
spudicus
Apprentice
Apprentice


Joined: 05 Dec 2002
Posts: 177
Location: Geraldton, Australia

PostPosted: Fri Nov 14, 2003 12:56 am    Post subject: Reply with quote

Two otherplaces you can get host files from are: kazaa lite and spybot,
However, aren't there limits to the size of the hosts file?

Also, you could probably replace the adds with a pic/text of your choice by
pointing to 127.0.0.1/mypic.htm, or something similar

edit: After looking at the site posted above by Jeedo, it seems adding 0.0.0.0 to /etc/hosts instead of 127.0.0.1, will achieve faster results.
The downside is it doesn't work on all OS's (I'm yet to try it on Gentoo) and you can't insert your own personal pic, and we all know how important that is :wink:
Back to top
View user's profile Send private message
Jeedo
Apprentice
Apprentice


Joined: 02 May 2003
Posts: 202
Location: Akureyri, Iceland

PostPosted: Fri Nov 14, 2003 11:30 pm    Post subject: Reply with quote

It would be unpolite of me to say i had this great super-hosts file and not provide it, so here goes:

Main site: http://212.30.222.56:81/GNU/Linux-ppc/common/programs/hosts-block/

Mirror: http://157.157.138.42/~jeedo/GNU/Linux-ppc/common/programs/hosts-block/

Also one member of the forums has generusly offered to host this, if you still want to just pick up the tarball and provide the url..

There is a script there do generate the hosts files, that is under the GPL, however some of the hosts files are not freely avalible so they are at most freely avalible. One is GPL though.
Back to top
View user's profile Send private message
Malakin
Veteran
Veteran


Joined: 14 Apr 2002
Posts: 1692
Location: Victoria BC Canada

PostPosted: Sat Nov 15, 2003 1:05 am    Post subject: Reply with quote

Quote:
aren't there limits to the size of the hosts file?
That's a good point, I know windows xp definitely has a limit and it's fairly restrictive so you have to keep the hosts file small. Haven't hit any limits in Linux yet though.
Back to top
View user's profile Send private message
neenee
Veteran
Veteran


Joined: 20 Jul 2003
Posts: 1786

PostPosted: Sat Nov 15, 2003 9:10 am    Post subject: Reply with quote

i have used the same (17000+ lines) hosts file
with windows without a problem. perhaps your
definition of a small hosts-file differs from mine?
Back to top
View user's profile Send private message
Malakin
Veteran
Veteran


Joined: 14 Apr 2002
Posts: 1692
Location: Victoria BC Canada

PostPosted: Sat Nov 15, 2003 10:04 pm    Post subject: Reply with quote

neenee wrote:
i have used the same (17000+ lines) hosts file
with windows without a problem. perhaps your
definition of a small hosts-file differs from mine?

odd, in windows once my hosts file hit a certain point it completely ignored it until I cut down the size and it was certainly nowhere near 17000 lines. Maybe there was an error in it somewhere but I thought I've read other people saying the same thing.

With a hosts file that big I wonder if it could cause any performance issues?
Back to top
View user's profile Send private message
neenee
Veteran
Veteran


Joined: 20 Jul 2003
Posts: 1786

PostPosted: Sun Nov 16, 2003 5:55 pm    Post subject: Reply with quote

i have never experienced any performance
issues myself - not even with a pentium 120
running windows. so i doubt it.
Back to top
View user's profile Send private message
Lovechild
Advocate
Advocate


Joined: 17 May 2002
Posts: 2858
Location: Århus, Denmark

PostPosted: Sun Nov 16, 2003 7:29 pm    Post subject: Reply with quote

Biggest problem I've had was etc-update wanting to "update" my hosts file every once in while after a related upgrade and it will take AGES to load the file in before you can reject it.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum