How to block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
User avatar
catweazel
Level 19
Level 19
Posts: 9884
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

How to block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by catweazel »

Your hosts file sits in /etc/hosts and probably looks like this:

Code: Select all

127.0.0.1       localhost
127.0.1.1       Fenella

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Give it a huge upgrade to stop web-nasties by opening this link and copy everything from this line onwards:

Code: Select all

# [Start of entries generated by MVPS HOSTS]
In a terminal, sudo nano -w /etc/hosts and paste the text at the end of the file.

ctrl-o, enter to save, then ctrl-x to exit.

All done.

The file is updated regularly so if web security is important to you, check the link every month for updates.

If you'd like to know more, see this link. It's Windwoes oriented but it'll give you a good idea of what's going on.

Edit: To automate the download process and the update of the hosts file, see this link. Thanks to user majpooper for the tip.
Last edited by catweazel on Tue Oct 24, 2017 2:24 am, edited 2 times in total.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
User avatar
sammiev
Level 4
Level 4
Posts: 369
Joined: Sat May 19, 2012 12:16 pm

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by sammiev »

Thanks testing it now.
Resistor
Level 4
Level 4
Posts: 245
Joined: Wed Nov 03, 2010 12:04 am
Location: Western Ozarks

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Resistor »

Thanks, catweazel.

I've often wondered how it worked in Linux.
Do we need to do anything with the other Host files?
Dell Inspiron 15-7567 Gaming Laptop i5, 8GB Ram, 256GB SSD. - Win 10 Inhibited. Nvidia GTX 1050 Ti. LM 19.3 Cinnamon x2
Asus VivoBook F512FA-AB34, 8 GB Ram, Kernel 5.3.0-45-generic, i3-8145U. No Win10.
User avatar
catweazel
Level 19
Level 19
Posts: 9884
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by catweazel »

Resistor wrote:Do we need to do anything with the other Host files?
No.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
User avatar
Pierre
Level 20
Level 20
Posts: 10978
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Pierre »

these type of Host File Lists are useful, but you do need to constantly update them . .

other folks just use a browser add-on like No Script to do the job.
& there is nothing wrong with the "belt & braces" approach, either.
8)
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.
Resistor
Level 4
Level 4
Posts: 245
Joined: Wed Nov 03, 2010 12:04 am
Location: Western Ozarks

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Resistor »

I appreciate the insight, catweazel.
I know more now, than I did on Saturday... :mrgreen:
Dell Inspiron 15-7567 Gaming Laptop i5, 8GB Ram, 256GB SSD. - Win 10 Inhibited. Nvidia GTX 1050 Ti. LM 19.3 Cinnamon x2
Asus VivoBook F512FA-AB34, 8 GB Ram, Kernel 5.3.0-45-generic, i3-8145U. No Win10.
Resistor
Level 4
Level 4
Posts: 245
Joined: Wed Nov 03, 2010 12:04 am
Location: Western Ozarks

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Resistor »

Pierre wrote:these type of Host File Lists are useful, but you do need to constantly update them . .

other folks just use a browser add-on like No Script to do the job.
& there is nothing wrong with the "belt & braces" approach, either.
8)
That be me... belt & braces.
I'm glad to no longer be running with a largely useless hosts file.
It has been a long time...
Dell Inspiron 15-7567 Gaming Laptop i5, 8GB Ram, 256GB SSD. - Win 10 Inhibited. Nvidia GTX 1050 Ti. LM 19.3 Cinnamon x2
Asus VivoBook F512FA-AB34, 8 GB Ram, Kernel 5.3.0-45-generic, i3-8145U. No Win10.
Aleron Ives
Level 3
Level 3
Posts: 127
Joined: Sun Sep 17, 2017 2:20 am
Location: California

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Aleron Ives »

Manually pasting this into your hosts file every month seems rather inelegant, but I guess it is the most straightforward and cross-platform-friendly solution if MVPs doesn't want to ask people to run extra peerblocking software.
User avatar
catweazel
Level 19
Level 19
Posts: 9884
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by catweazel »

Aleron Ives wrote:Manually pasting this into your hosts file every month seems rather inelegant
catweazel wrote:To automate the download process and the update of the hosts file, see this link.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
Aleron Ives
Level 3
Level 3
Posts: 127
Joined: Sun Sep 17, 2017 2:20 am
Location: California

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Aleron Ives »

I guess I should have chosen my words more carefully. Using your hosts file for this purpose seems rather inelegant. :wink:
User avatar
catweazel
Level 19
Level 19
Posts: 9884
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by catweazel »

Aleron Ives wrote:Using your hosts file for this purpose seems rather inelegant. :wink:
<shrug>
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
User avatar
Moem
Level 20
Level 20
Posts: 11982
Joined: Tue Nov 17, 2015 9:14 am
Location: The Netherlands
Contact:

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Moem »

I don't see what's inelegant about it. If you already know you aren't interested in a certain portion of what the internet offers, why not simply deny it entry to your computer?
Image

If your issue is solved, kindly indicate that by editing the first post in the topic, and adding [SOLVED] to the title. Thanks!
Aleron Ives
Level 3
Level 3
Posts: 127
Joined: Sun Sep 17, 2017 2:20 am
Location: California

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Aleron Ives »

I was under the impression that the hosts file was intended for addresses that DNS can't resolve, e.g. the hostnames of the machines on your LAN, so you can access them easily. This seems like a task best suited to browser-based blocking software, where you could use features such as analytics to see which filters are being used frequently and to prune filters that have no hits to speed up the process of checking the blocklist on each page you visit. I'm not really sure how you would expect these entities to be accessing your PC other than through a browser, so globally blocking them in a manner that gives no feedback as to the efficacy of each filter seems a bit heavy handed an inefficient IMHO. Am I missing some added benefit of doing it this way?
User avatar
Moem
Level 20
Level 20
Posts: 11982
Joined: Tue Nov 17, 2015 9:14 am
Location: The Netherlands
Contact:

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Moem »

It's easy. Set it and forget it. I can see why you'd call it 'heavy handed', but 'inefficient'... no. It works very well and there is very little effort, how can it be inefficient?
Image

If your issue is solved, kindly indicate that by editing the first post in the topic, and adding [SOLVED] to the title. Thanks!
User avatar
Flemur
Level 18
Level 18
Posts: 8875
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by Flemur »

I used to use the 'hosts' file but it doesn't support wild-cards; 'privoxy' is a lot easier once you get it set up.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
syg00
Level 4
Level 4
Posts: 211
Joined: Fri Jul 21, 2017 4:00 am

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by syg00 »

Very last century. I park a pi3 as a getway/router so the entire house can be protected without having to constantly update each machine individually.

Each to their own.
User avatar
majpooper
Level 6
Level 6
Posts: 1333
Joined: Thu May 09, 2013 1:56 pm
Location: North Carolina, USA

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by majpooper »

A very simple script and a cron and you are done - what's the big deal?
User avatar
sammiev
Level 4
Level 4
Posts: 369
Joined: Sat May 19, 2012 12:16 pm

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by sammiev »

I did setup a script and cron job to run each day but you can also setup to receive an email when a update to the hosts file is updated.

Then run the script as required than each day. It seems last update was mid Sept.

Just saying.

http://winhelp2002.mvps.org/updates.htm
User avatar
catweazel
Level 19
Level 19
Posts: 9884
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by catweazel »

Aleron Ives wrote:I was under the impression that the hosts file was intended for addresses that DNS can't resolve
Clearly it's also intended for addresses you don't want to resolve.
Aleron Ives wrote:This seems like a task best suited to browser-based blocking software, where you could use features such as analytics to see which filters are being used frequently and to prune filters that have no hits to speed up the process of checking the blocklist on each page you visit.
Nonsense. The file is loaded and the list checked in microseconds flat.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
User avatar
all41
Level 16
Level 16
Posts: 6595
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: How to block block ads, banners, 3rd party cookies, page counters, web bugs and hijackers

Post by all41 »

hey catweasel how can you tell if it works?
please don't plonk me
Light travels faster than sound. That's why some people appear smart until you hear what they are saying.
You will seldom see a grey-beard wearing a tinfoil hat.
Post Reply

Return to “Tutorials”