PDA

View Full Version : HOWTO: Amend your hosts file to block ads (by site)



goldaryn
August 22nd, 2006, 04:17 PM
Note: this is very much a beginner's guide.


Q: What is a HOSTS file / Why might I want to do this?
A: It's explained nicely at http://www.mvps.org/winhelp2002/hosts.htm


Q: But why do this in Ubuntu? My Ubuntu is like a shield of steel!
A: Many reasons. But mainly to save bandwidth by not loading lots of rubbish. For each site listed as 127.0.0.1, content (usually ad banners etc) from that site isn't loaded. In a web browser that picture/frame will 404.

So, how to do it:
The host file in Linux lives at /etc/hosts. We are going to add some lines to it.

Disclaimer:

***** NOW HEAR THIS *****

A) ***BACK UP*** your /etc/hosts BEFORE YOU START

B) You must APPEND to (not overwrite) the file. You need the stuff that's already in there! That means: paste in the additional lines AFTER what's already in there!

C) I do not recommend doing this if you HOST WEB PAGES from your PC.


End of disclaimer.



1) >>>>>>> BACKUP YOUR HOSTS FILE <<<<<<<<<

$ sudo cp /etc/hosts /etc/hosts.old

2) Download a good hosts file. I recommend the MVPs one:

http://www.mvps.org/winhelp2002/hosts.txt

3) Open your hosts file.

$ sudo gedit /etc/hosts

4) Paste in the contents of hosts.txt into the bottom of /etc/hosts.

5) It should take effect immediately. Close and reload your web browser then try to go to one of the blocked sites. It should 404.

Luc

bodhi.zazen
September 16th, 2006, 09:04 AM
Here is a link to a site with a script to update your hosts file:

hostsfile.mine (http://hostsfile.mine.nu/downloads/)

Look on the very bottom of the page for this:

Unix/Linux bash Hosts updater script (txt) (m)

Here is the script if you would like to examine the code:

Hosts update script (http://hostsfile.mine.nu/downloads/updatehosts.sh.txt)

Download the script
Make the script executable (chmod a+x updatehosts.sh)
Install tofrodos (sudo apt-get install tofrodos)
sudo ./updatehosts.sh

Optional
127.0.0.1 = your computer
0.0.0.0 = nowhere

"0.0.0.0" is faster as "127.0.0.1" will wait for a timeout :twisted:


This command will change 127.0.0.1 to 0.0.0.0 :

sudo sed -i -e 's_127.0.0.1_0.0.0.0_g' /etc/hosts

WARNING: We now need to manually edit /etc/hosts and change the line(s) at the top with localhost and your hostname back to 127.0.0.1 localhost


#These may be on one line or multiple lines
127.0.0.1 localhost
127.0.0.1 Ubuntu # Change Ubuntu to your hostname

It is best to do this from the terminal with vim or nano as graphical editors will take forever to load (the hosts file is large).

angler
October 17th, 2006, 02:02 AM
After running the script, which ran seemlessly, I don't see any changes to the HOSTS file... which one should it change? I was hoping to do like I did in ******* and cut/paste the loopbacks into the file, but I lost admin rights when I did it. Maybe I made a n00b mistake, I'll try it again. thanks

bodhi.zazen
October 17th, 2006, 04:34 AM
it modifies /etc/hosts

If you lost admin rights, boot to failsafe.

If you do not know, to get your host name, at the CLI type:
hostname


nano /etc/hostsAdd the line
127.0.0.1 localhost.localdomain <hostname>
<hostname> = your host nameAt the top fo the file.

Crtl-X to exit, type Y to save.

Reboot
reboot

666porcondissaum
November 18th, 2008, 03:10 AM
Thank you very much.:confused:

Mark_in_Hollywood
February 11th, 2010, 09:51 PM
Following this post, I read:

Unix/Linux bash Hosts updater script (txt) (m)

Here is the script if you would like to examine the code:

Hosts update script

* Download the script
* Make the script executable (chmod a+x updatehosts.sh)
* Install tofrodos (sudo apt-get install tofrodos)
* sudo ./updatehosts.sh


I downloaded the updatehosts.sh.txt

but, doing: chmod a+x updatehosts.sh -- did not remove the .txt. So there I quit and am asking for clarification:

Do I rename the file updatehosts.sh.txt manually before or after running chomd a+x?

bodhi.zazen
February 12th, 2010, 07:15 AM
Do I rename the file updatehosts.sh.txt manually before or after running chomd a+x?

It does not matter if you rename the file before or after the chomd.

mr.nope
April 21st, 2010, 04:26 PM
On Ubuntu Lucid Lynx 10.04 the script is currently broken because of the following changes to the tofrodos package.




tofrodos (1.7.8.debian.1-2) unstable; urgency=low

With this release the symlinks "unix2dos" and "dos2unix" are dropped from the
package. This will allow the introduction of the original dos2unix package,
which also supports conversion to MacOS style files.

Should you have scripts depending on these symlinks, I recommend using
shell-aliases, like in the following example for bash:

alias unix2dos="/usr/bin/fromdos -u" (or todos)
alias dos2unix="/usr/bin/fromdos -d" (or just fromdos)

-- Alexander Reichle-Schmehl <tolimar@debian.org> Thu, 21 Jan 2010 20:59:11 +0100

I simply updated the script by replacing all occurrences of dos2unix with fromdos using gedit (CTRL+H). Works like a charm now.

Helkaluin
May 30th, 2010, 10:30 PM
Just want to put a reminder here for all who are looking into using /etc/hosts to block ads: this seem to break desktopcouch, and with that UbuntuOne and Gwibber and Evolution. Multiple beam.smp processes will be spawned, sucking up CPU cycles, and seem to take forever to parse lines in /etc/hosts

The bug is here: https://bugs.launchpad.net/ubuntu/lucid/+source/desktopcouch/+bug/530541

Chad on the page suggested dnsmasq or similar as an alternative to /etc/hosts for the time being...

SonicsDemon
May 31st, 2010, 01:42 AM
Awesome! \\:D/ I love this script! Thanks!

ipernar
June 9th, 2010, 04:29 PM
Here is a link to a site with a script to update your hosts file:

hostsfile.mine (http://hostsfile.mine.nu/downloads/)



here is my host file if you wish to block porn :)

http://datasaver.orgfree.com/hosts.zip
xthosts no longer works so I had 2 change! :)

bodhi.zazen
June 9th, 2010, 05:26 PM
here is my host file if you wish to block porn :)

http://user.xthost.info/zelenalista/hosts.zip

thank you !!

The zip file does not download =(

ipernar
June 10th, 2010, 08:17 AM
thank you !!

The zip file does not download =(

Dude it must download :)
just click download (2times) after clicking the link

One friend of mine was at my apartment (slept over) and he wanted to search for porn on my comp and was shocked to realise he cant get it... hahah

It was funny to see his face, i said... wazap bro... no porn today... and he said... yeah dude, i searched...but couldnt get into site...

email me if yoou want me to send it via email ;)
ipernar@yahoo.com

TheTank
June 10th, 2010, 09:35 AM
Optional
127.0.0.1 = your computer
0.0.0.0 = nowhere

"0.0.0.0" is faster as "127.0.0.1" will wait for a timeout :twisted:


This command will change 127.0.0.1 to 0.0.0.0 :

sudo sed -i -e 's_127.0.0.1_0.0.0.0_g' /etc/hosts

WARNING: We now need to manually edit /etc/hosts and change the line(s) at the top with localhost and your hostname back to 127.0.0.1 localhost

1st off, great suggestion! Thanks

2nd I would not do it this way.
What I would do is apply the 127.0.0.1 -> 0.0.0.0 on the mvp file.

Workflow:
download mvp file
apply the mentioned sed to it
then take a hosts.base and concat the mvp file to it and write it out to /etc/hosts

bodhi.zazen
June 10th, 2010, 03:54 PM
Dude it must download :)
just click download (2times) after clicking the link

One friend of mine was at my apartment (slept over) and he wanted to search for porn on my comp and was shocked to realise he cant get it... hahah

It was funny to see his face, i said... wazap bro... no porn today... and he said... yeah dude, i searched...but couldnt get into site...

email me if yoou want me to send it via email ;)
ipernar@yahoo.com

Had to allow cookies to DL the zip file.

OMG that is one huge hosts file, lol

daggoth8
August 30th, 2010, 12:01 AM
Looking at the hosts updatehosts.sh script from

http://hostsfile.mine.nu/downloads/updatehosts.sh.txt

There could be a possible bug with the sanity test on line 54.

if [ 'grep -c "banner" /tmp/hosts' ];then

Did the author accidently put quotes around the grep, instead of using
backticks? Perhaps it could have been written like this instead...

if [ $( grep -c "banner" /tmp/hosts ) ] ; then

That said, the script works perfectly, so thanks :-)

rocksockdoc
October 2nd, 2010, 08:25 AM
There is an unmentioned "problem" here, in practical terms, which can be rectified easily, if you know how.

The problem is how to merge multiple huge hosts files and to rid yourself of duplicate entries.

Just one solution is to use the following command post merger is to employ "sort -u".
$ sudo sort -u /etc/hosts -o /etc/hosts

Since you probably don't want the first few lines sorted, do a 'mark a'
ma

And then, just because, do a mark b:
mb

And then run the command:
:'a,'b!sort -u

Which is, "from a, to b, sort -unique".

BTA
March 14th, 2011, 05:43 PM
Hi, I'm a first time Ubuntu user (aka Super Beginner) - This is my first post and I realize this is an old thread but I needed some help with the script updating my host file:

I installed tofrodos and when I do the last step - "sudo ./updatehosts.sh" - I get this message:

-------------------------------------------------------------
This script will update your Hosts file to the latest version
Your original Hosts file will be renamed to /etc/hosts.original
-------------------------------------------------------------

Checking for required applications...
... wget
... unzip
... dos2unix
tofrodos (which contains dos2unix) is missing.
... grep
One or more required applications are missing. Aborting now ...
adam@adam-MT6840:~$

It says I'm missing tofrodos which contains dos2unix. I've scoured the internet and these forums but I cannot find a solution. Any suggestions??

Thanks

bodhi.zazen
March 14th, 2011, 07:09 PM
http://packages.ubuntu.com/cgi-bin/search_packages.pl?keywords=tofromdos&searchon=name&subword=1&version=all&release=all

sudo apt-get install tofromdos

DGINSD
April 5th, 2011, 08:52 AM
http://packages.ubuntu.com/cgi-bin/search_packages.pl?keywords=tofromdos&searchon=name&subword=1&version=all&release=all

sudo apt-get install tofromdos

I need help with using the update script, I'm very new with Ubuntu so I could use a little more detailed instruction on the process. keeps getting killed saying I dont have tofrodos.

bodhi.zazen
April 5th, 2011, 06:16 PM
I need help with using the update script, I'm very new with Ubuntu so I could use a little more detailed instruction on the process. keeps getting killed saying I dont have tofrodos.

Read the post right above yours =)

DGINSD
April 5th, 2011, 08:45 PM
Read the post right above yours =)

I tried that it didn't work. Tried it again and loaded dostounix (I think it was) as well and got it to work, but I have a few other questions as well.

How often should this script be run to update the hosts (weekly, monthly) or is it a one time deal?

Theres some conflicting posts in this thread about changing the host address to 0.0.0.0 instead of leaving them as 127.0.0.1 (or what ever standard is), some clairification on this? Safe to do? Evolution and other mail programs still work?

Any other reccomended hosts lists to add?

Thank you for your help and the info.

bodhi.zazen
April 5th, 2011, 08:52 PM
OK, glad you got it working.

It is the same list as is used for AdblockPlus.

Update, up to you. I think the list itself is updated either daily or almost daily. I personally update it (when I use a hosts file) every few months, sooner if I start seeing ads.

On a desktop you could use either 0.0.0.0 or 127.0.0.1 , on a server (which I would not advise) you should probably use 127.0.0.1.

You can use either, easy enough to switch if you have a problem.

Alternates to a host file would include a proxy (privoxy) or using adblock extensions with your browser.

DGINSD
April 5th, 2011, 10:11 PM
OK, glad you got it working.

It is the same list as is used for AdblockPlus.

Update, up to you. I think the list itself is updated either daily or almost daily. I personally update it (when I use a hosts file) every few months, sooner if I start seeing ads.

On a desktop you could use either 0.0.0.0 or 127.0.0.1 , on a server (which I would not advise) you should probably use 127.0.0.1.

You can use either, easy enough to switch if you have a problem.

Alternates to a host file would include a proxy (privoxy) or using adblock extensions with your browser.

You say "when u use a hosts file" why would you ever need to do that, and how would you do that? Isn't the bennifit of using 0.0.0.0 faster site loading. Some recomended reading on using a proxy (its a totally new idea to me so I know nothing about it). I think what I meant by alternatives is additions to the host file such as know hijack sites and what not.

DGINSD
April 6th, 2011, 03:28 PM
You say "when u use a hosts file" why would you ever need to do that, and how would you do that? Isn't the bennifit of using 0.0.0.0 faster site loading. Some recomended reading on using a proxy (its a totally new idea to me so I know nothing about it). I think what I meant by alternatives is additions to the host file such as know hijack sites and what not.

Just realized I didn't phrase my first question correctly, what I meant was why would you ever not want to use a hosts file? What need would there be to do that?

bodhi.zazen
April 6th, 2011, 04:11 PM
Just realized I didn't phrase my first question correctly, what I meant was why would you ever not want to use a hosts file? What need would there be to do that?

A hosts file is one option, other options include using a proxy (priviox / squid) and a third is extensions on browsers.

Each has advantages and disadvantages.

The disadvantage of a hosts file is that you need to manually keep the list up to date and you would have to keep it up to date on each desktop.

The disadvantage of browser extensions is that they apply to a single browser for a single user. The advantage is that these lists are typically more up to date and easier to customize per user.

For multiple users on a lan a proxy makes more sense, but it takes a bit more knowledge to set up and not all users may need the same content filtering.

You will have to decide for yourself what makes the most sense.
The

IT2870
April 6th, 2011, 11:52 PM
I had to log in just to thank you for this. I work in IT and never even knew about this.(never got deep into the internet\web part of IT)....What's got me so happy is I often work off of a broadband card when I'm out and about. I hate the freezing,especially any video(youtube,etc.) but just accepted it....until today. It's like i just went from a modem 54k to a DSL connection. THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!

DGINSD
April 23rd, 2011, 05:30 PM
There is an unmentioned "problem" here, in practical terms, which can be rectified easily, if you know how.

The problem is how to merge multiple huge hosts files and to rid yourself of duplicate entries.

Just one solution is to use the following command post merger is to employ "sort -u".
$ sudo sort -u /etc/hosts -o /etc/hosts

Since you probably don't want the first few lines sorted, do a 'mark a'
ma

And then, just because, do a mark b:
mb

And then run the command:
:'a,'b!sort -u

Which is, "from a, to b, sort -unique".

I need some help with this post I'm still finding my way around the terminal. The part I'm having trouble with is the mark A and mark B. How is this done, to mark certain lines, if possible a more detailed step by step? What directory, proper syntax to mark, or is that something that needs to be done with a text editor (the marking) to the hosts file it's self?

rocksockdoc
April 25th, 2011, 01:42 AM
The part I'm having trouble with is the mark A and mark B. How is this done, to mark certain lines, if possible a more detailed step by step?

I'll try to explain this but explaining 'vi' commands is, shall we say, a bit problematic, mainly because there are two modes and the commands only work in one of the two modes but there is no visual clue what mode you're in. Also, most of us have 'finger memory' ... which means the commands are embedded in our finger muscles - so - actually 'explaining' the steps is problematic. Those of you who know vi well know what I mean by that; if you don't know vi well, you won't really understand why that is the case. You'll learn.

Lastly, it takes VASTLY more time to explain than the two or three keystrokes take to do ... so it' 'seems' confusing ... but it's really simple.

First off, once in vi, you MUST clearly get yourself in the command mode by using the ESCAPE key religiously! (Hit it once, hit it twice, and, for good effect, if you're uncertain, hit it thrice!). :) You only need to hit it once, but, I need to underscore the point that you must be in the right mode.

Also, you must be using a vi editor. There are lots of them. Vi, vim, Gvim, etc. (all will have 'vi' in the name somewhere). Or, just open up a terminal window and type:


vi /tmp/fooOnce you have an empty file "foo" open, import the hosts file:

ESCAPE:r/etc/hostsThe ":r" means to "read in" the file which follows "/etc/hosts".

Now, with your "j" key, move down (use the "k" key to move up).

At some point, hit "mx" (that will mark that spot as an "x"). Then use your "j" and "k" key again to go to a different spot and then hit "my". Now you've marked a spot as a 'y').

At this point, do whatever you want between those two spots, e.g., to sort:
:'x,'y!sort

Which, interpreted, is:
: = command
'x = from x
'y = to y
!sort = run the sort command

If things don't seem to work, hit the escape key a few times (and stay away from the 'i' key while doing commands.

Hope this helps.
Rock

DGINSD
April 26th, 2011, 07:33 PM
Firstly Thank you for the help, slowly but surely I'm learning

I got it to work but a few more details I'd like. What is vi I guess I mean in contrast to an editor like gedit?

When I do a "mx" should a physical mark be made on the document (e.g. an x) something to note you did it?

Are there any other navigation keys other than j and k, as that could take a very long time to get to the bottlom of a large hosts file?

Save and exit, how do I do it?

I think thats it for now, again thank you for the help.

sdemsc
April 26th, 2011, 08:23 PM
thanks. i am using script and works perfactly

DGINSD
May 4th, 2011, 04:42 AM
Uh, so just a heads up. I was trying to watch some flash videos on a web site, but for what ever reason the videos wouldn't play. After an hour or two of trying to figure out what the hell was wrong, out of desperation I put my hosts file back to normal, and come to find out the site had placed ad's in the beginning of the video feeds which the hosts file in turn was blocking.

I was really enjoying the no ad's too. :(

Did I have something set up wrong, or is there a work around for this?

bodhi.zazen
May 4th, 2011, 07:50 AM
Uh, so just a heads up. I was trying to watch some flash videos on a web site, but for what ever reason the videos wouldn't play. After an hour or two of trying to figure out what the hell was wrong, out of desperation I put my hosts file back to normal, and come to find out the site had placed ad's in the beginning of the video feeds which the hosts file in turn was blocking.

I was really enjoying the no ad's too. :(

Did I have something set up wrong, or is there a work around for this?

You can remove or comment out the offending host.

DGINSD
May 4th, 2011, 03:14 PM
You can remove or comment out the offending host.

How could I find out which one is causing the problem? The ad displayed was an AT&T ad, I inspected the element but was not smart enough to figure out where the ad was coming from.

My concern is more and more sites will follow this model to counter ad block methods. The sites I was using to test Chargers.com and NFL.com and both had ads while the video loaded? Oddly enough once in a while the video would play but it was rather irregular.

bodhi.zazen
May 4th, 2011, 04:25 PM
How could I find out which one is causing the problem? The ad displayed was an AT&T ad, I inspected the element but was not smart enough to figure out where the ad was coming from.

My concern is more and more sites will follow this model to counter ad block methods. The sites I was using to test Chargers.com and NFL.com and both had ads while the video loaded? Oddly enough once in a while the video would play but it was rather irregular.

Well if that is the case, you might prefer NoScript , Adblock Plus, and Request Policy (addons).

If you inspect the elements, you will see (hopefully) "http://server.com"

search your hosts file for "server.com"

DGINSD
May 6th, 2011, 03:21 PM
Will those addins work in any browser, I use Chromium as my default instead of Firefox. If so how do I go about getting them?

bodhi.zazen
May 6th, 2011, 04:12 PM
Will those addins work in any browser, I use Chromium as my default instead of Firefox. If so how do I go about getting them?

Some of those addins are available for chormium yes, some not.

You will need to learn to manage your hosts file , that is the downside of this technique.

Open the file in gedit and search or use tools such as grep , sed, awk to automate the process.

mellowchuck123
July 7th, 2011, 06:59 PM
Here's a hosts file I'd like to contribute to every one.

It's a combination of 12 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

MAKE SURE YOU COPY THE ENTIRE FILE TO etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.


http://ubuntuone.com/p/13J6/

-Chuck

mellowchuck123
September 16th, 2011, 07:51 PM
September 16, 2011 HOSTS file.



This is a combination of 12 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

MAKE SURE YOU COPY THE ENTIRE FILE TO etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.

September 16th, 2011 HOSTS file link:

https://ubuntuone.com/6MVhZn91mwKeIvUoJl0CbK

mellowchuck123
November 4th, 2011, 11:19 PM
November 4, 2011 HOSTS file.



This is a combination of 12 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

The file is optimized, sorted & is in 0.0.0.0 format.

MAKE SURE YOU COPY THE ENTIRE FILE TO /etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.

November 4, 2011 HOSTS file link:

http://ubuntuone.com/4o5KKT545F9M4WZUpKO7PB



Side note- You might want to install an ad-blocking extension in your browser so you don't see the annoying "page not found" error where ads were before.

joneberger
November 17th, 2011, 11:02 PM
November 4, 2011 HOSTS file.



This is a combination of 12 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

The file is optimized, sorted & is in 0.0.0.0 format.

MAKE SURE YOU COPY THE ENTIRE FILE TO /etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.

November 4, 2011 HOSTS file link:

http://ubuntuone.com/4o5KKT545F9M4WZUpKO7PB



Side note- You might want to install an ad-blocking extension in your browser so you don't see the annoying "page not found" error where ads were before.

Awesome. Perfect.

Aberdeen
November 18th, 2011, 12:20 AM
Nice work and very much appreciated.;)

TheTank
November 21st, 2011, 05:43 PM
snip
Thanks for the continuous updates!

Quick question: have you checked the sites listed?
f.i. hidemyass.com is blocked, yet I was unaware that this is a problematic site.

I guess part of the list is also from a 'not desireable' list, perhaps used in companies. So it might be something to provide multiple such lists we can paste together to fit our needs.

thanks

mellowchuck123
November 22nd, 2011, 12:28 AM
Thanks for the continuous updates!

Quick question: have you checked the sites listed?
f.i. hidemyass.com is blocked, yet I was unaware that this is a problematic site.

I guess part of the list is also from a 'not desireable' list, perhaps used in companies. So it might be something to provide multiple such lists we can paste together to fit our needs.

thanks

All lists used are malwares and ads blocking hosts files. Sometimes these list maintainers make mistakes.

I can only check the sites I frequent. For instance- I use meebo.com and found that for whatever reason it was added to one of the lists I use to make this hosts file; it is now not blacklisted and I am in process of uploading hosts file for today. Therefore, if you find a entry that you believe shouldn't be in this list, I will gladly take it out if you give me a valid reason. I don't know what hidemyass.com is, but I'm assuming it's a proxy service; have you tried Tor? Do you like Tor if so? If you don't like Tor and prefer this site, why is this so?


-Chuck

mellowchuck123
November 22nd, 2011, 12:58 AM
November 21, 2011 HOSTS file.



This is a combination of 9 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

The file is optimized, sorted & is in 0.0.0.0 format.

MAKE SURE YOU COPY THE ENTIRE FILE TO /etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.

November 21, 2011 HOSTS file link:

http://ubuntuone.com/7333ex5gkroKUXKG44bfS7



Side note- You might want to install an ad-blocking extension in your browser so you don't see the annoying "page not found" error where ads were before.

jmate24
November 22nd, 2011, 10:39 AM
well the host file blocked my favorite flash video sites and all i really want is to block porn and also to make sure that the host file cannot be changed by any site but my own computer so i just copy and pasted the porn host file to my curent host file (of course after i made a backup of my original
sudo cp /etc/hosts /etc/hosts.old)

then i simply chmod-ed my host file to take away the write attribute.


sudo chmod a-w /etc/hosts

these lines are a good idea if you go to sites that try to hack/hijack your host file and make it point to their domain only.
by having a copy of your original and then making the host file ro then you can control what sites can be accessed from your computer (i.e. facebook, google, bing, hulu, etc.)

mellowchuck123
November 23rd, 2011, 01:21 AM
well the host file blocked my favorite flash video sites and all i really want is to block porn and also to make sure that the host file cannot be changed by any site but my own computer so i just copy and pasted the porn host file to my curent host file (of course after i made a backup of my original
sudo cp /etc/hosts /etc/hosts.old)

then i simply chmod-ed my host file to take away the write attribute.


sudo chmod a-w /etc/hoststhese lines are a good idea if you go to sites that try to hack/hijack your host file and make it point to their domain only.
by having a copy of your original and then making the host file ro then you can control what sites can be accessed from your computer (i.e. facebook, google, bing, hulu, etc.)

Which flash sites are blocked in the HOSTS file posted yesterday?

mellowchuck123
November 23rd, 2011, 01:47 AM
Here are the 9 lists I currently use if you would like to use your own script instead and sort and update your own HOSTS file --


http://www.mvps.org/winhelp2002/hosts.zip

http://hphosts.gt500.org/hosts.zip

http://updates.it-mate.co.uk/updates.asp

http://hosts-file.net/ad_servers.asp

http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext

http://someonewhocares.org/hosts/hosts

http://support.it-mate.co.uk/downloads/HOSTS.txt

http://hostsfile.mine.nu/Hosts

http://www.securemecca.com/Downloads/hosts.txt

TheTank
November 23rd, 2011, 05:41 PM
All lists used are malwares and ads blocking hosts files. Sometimes these list maintainers make mistakes.

I can only check the sites I frequent. For instance- I use meebo.com and found that for whatever reason it was added to one of the lists I use to make this hosts file; it is now not blacklisted and I am in process of uploading hosts file for today. Therefore, if you find a entry that you believe shouldn't be in this list, I will gladly take it out if you give me a valid reason. I don't know what hidemyass.com is, but I'm assuming it's a proxy service; have you tried Tor? Do you like Tor if so? If you don't like Tor and prefer this site, why is this so?
-Chuck
Thanks for the reply!

@hidemyass:
yes, it is simply a web proxy and I sometimes use it to a) check if there is something blocking my access to a site (censor) or if it is really down and b) do the same with content, f.i. when youtube blocks content because I live in the wrong country.

Plus such a censor tool need not only be national but also company thing.
Hence why I thought it might be a 'company block list' that filters out sites you can use to avoid sites blocked by companies.
Which in some cases is fine.

@Update:
Ok, will do. Thanks!

mellowchuck123
November 23rd, 2011, 08:22 PM
Thanks for the reply!

@hidemyass:
yes, it is simply a web proxy and I sometimes use it to a) check if there is something blocking my access to a site (censor) or if it is really down and b) do the same with content, f.i. when youtube blocks content because I live in the wrong country.

Plus such a censor tool need not only be national but also company thing.
Hence why I thought it might be a 'company block list' that filters out sites you can use to avoid sites blocked by companies.
Which in some cases is fine.

@Update:
Ok, will do. Thanks!

I willl remove hidemyass.com from my next update :) ;)

-Chuck

mellowchuck123
December 3rd, 2011, 12:17 PM
December 3, 2011 HOSTS file.



This is a combination of 9 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

LISTS USED -

http://www.mvps.org/winhelp2002/hosts.zip

http://hphosts.gt500.org/hosts.zip

http://updates.it-mate.co.uk/updates.asp

http://hosts-file.net/ad_servers.asp

http://pgl.yoyo.org/as/serverlist.php?

hostformat=hosts&showintro=1&mimetype=plaintext

http://someonewhocares.org/hosts/hosts

http://support.it-mate.co.uk/downloads/HOSTS.txt

http://hostsfile.mine.nu/Hosts

http://www.securemecca.com/Downloads/hosts.txt
The file is optimized, sorted & is in 0.0.0.0 format.

MAKE SURE YOU COPY THE ENTIRE FILE TO /etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.

December 3, 2011 HOSTS file link:

http://ubuntuone.com/6bcMKbj5S6cs8BUDe0rFSr


Side note- You might want to install an ad-blocking extension in your browser so you don't see the annoying "page not found" error where ads were before.

mellowchuck123
December 18th, 2011, 06:51 AM
December 18, 2011 HOSTS file.



This is a combination of 9 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

LISTS USED -



http://www.mvps.org/winhelp2002/hosts.zip

http://hphosts.gt500.org/hosts.zip

http://updates.it-mate.co.uk/updates.asp

http://hosts-file.net/ad_servers.asp

http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext

http://someonewhocares.org/hosts/hosts

http://support.it-mate.co.uk/downloads/HOSTS.txt

http://hostsfile.mine.nu/Hosts

http://www.securemecca.com/Downloads/hosts.txt
The file is optimized, sorted & is in 0.0.0.0 format.

MAKE SURE YOU COPY THE ENTIRE FILE TO /etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.

December 18, 2011 HOSTS file link:

[/URL] [U] http://ubuntuone.com/0Z6rhNrarrmehKCRcaLMh6 (http://ubuntuone.com/6bcMKbj5S6cs8BUDe0rFSr)


Side note- You might want to install an ad-blocking extension in your browser so you don't see the annoying "page not found" error where ads were before.

mellowchuck123
December 30th, 2011, 12:16 AM
December 29, 2011 HOSTS file.



This is a combination of 9 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

LISTS USED -

http://www.mvps.org/winhelp2002/hosts.zip

http://hphosts.gt500.org/hosts.zip

http://updates.it-mate.co.uk/updates.asp

http://hosts-file.net/ad_servers.asp

http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext

http://someonewhocares.org/hosts/hosts

http://support.it-mate.co.uk/downloads/HOSTS.txt

http://hostsfile.mine.nu/Hosts

http://www.securemecca.com/Downloads/hosts.txt

The file is optimized, sorted & is in 0.0.0.0 format.

MAKE SURE YOU COPY THE ENTIRE FILE TO /etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.

December 29, 2011 HOSTS file link:

http://ubuntuone.com/7QOZkqtE8Tn6Mp77pvePQG


Side note- You might want to install an ad-blocking extension in your browser so you don't see the annoying "page not found" error where ads were before.

bzd454
December 30th, 2011, 03:29 AM
thanks mellowchuck...

dumb question, i was wondering if there is a way to alphabetize it? because it blocks file hosting sites and a few others that i'd rather just delete from it individually if possible or maybe those other 2 hosts files in that section could be used to solve?

also, how about Bluetack?

thanks...

mellowchuck123
December 30th, 2011, 03:34 AM
thanks mellowchuck...

dumb question, i was wondering if there is a way to alphabetize it? because it blocks file hosting sites and a few others that i'd rather just delete from it individually if possible or maybe those other 2 hosts files in that section could be used to solve?

also, how about Bluetack?

thanks...

The HOSTS file is already alphabetized. If you are looking for sites to remove, Ctrl+F in gedit or whichever text editor your use, and search for the URL.

If you feel I should removed these sites, please give me a valid explanation and I will.

mellowchuck123
December 30th, 2011, 03:35 AM
thanks mellowchuck...

dumb question, i was wondering if there is a way to alphabetize it? because it blocks file hosting sites and a few others that i'd rather just delete from it individually if possible or maybe those other 2 hosts files in that section could be used to solve?

also, how about Bluetack?

thanks...

What about Bluetack? You mean bluetack.co.uk right? They have a HOSTS file now?

bzd454
December 30th, 2011, 09:36 AM
ok thanks....i must have merged it incorrectly or something...i was trying to get to some run of the mill file site like filefactory or filestube, then i tried to check the hosts file and it was A to Z for about 1/10th of the file or so and then started at A again so i gave up...i didn't know i could have searched with ctrl-f... on bluetack, i was just glancing at their forum and it seemed to mention a hosts file here and there but sounds like you are already aware of them...

chickenPie4breakfast
February 14th, 2012, 02:12 PM
Thanks MelloChuck 123 It's great of you to take the time to post these for the rest of us.

a question though, is it alright to have a few web addresses in one line like you do or have I downloaded it wrong somehow?

example line

0.0.0.0 www.trafficid7806.info www.tresorparis-uk.com www.tunnelingchina.com www.uberwarez.info www.uggaustraliaitalias.com www.uggbootsdeutschlands.com www.uggsshoponlineitalia.com www.uggssitoufficiale.com www.ummuclothing.com

mellowchuck123
February 14th, 2012, 04:52 PM
Thanks MelloChuck 123 It's great of you to take the time to post these for the rest of us.

a question though, is it alright to have a few web addresses in one line like you do or have I downloaded it wrong somehow?

example line

0.0.0.0 www.trafficid7806.info www.tresorparis-uk.com www.tunnelingchina.com www.uberwarez.info www.uggaustraliaitalias.com www.uggbootsdeutschlands.com www.uggsshoponlineitalia.com www.uggssitoufficiale.com www.ummuclothing.com

Hello chickenPie4breakfast,

The script I use optimizes the HOSTS file and that is one of the results; however, I saw it as well and have tested the sites still block. You can as well and correct me if I am wrong.

Thanks.

Thank you,
mellowchuck123

mellowchuck123
February 14th, 2012, 08:48 PM
February 14, 2012 HOSTS file.



This is a combination of 9 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

LISTS USED -



http://www.mvps.org/winhelp2002/hosts.zip

http://hphosts.gt500.org/hosts.zip

http://updates.it-mate.co.uk/updates.asp

http://hosts-file.net/ad_servers.asp

http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext

http://someonewhocares.org/hosts/hosts

http://support.it-mate.co.uk/downloads/HOSTS.txt

http://hostsfile.mine.nu/Hosts

http://www.securemecca.com/Downloads/hosts.txt

The file is optimized, sorted & is in 0.0.0.0 format.

MAKE SURE YOU COPY THE ENTIRE FILE TO /etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.

February 14, 2012 HOSTS file link:

https://ubuntuone.com/4iB1gOHsdbyxyMAONWZvhW


Side note- You might want to install an ad-blocking extension in your browser so you don't see the annoying "page not found" error where ads were before.

bzd454
February 22nd, 2012, 09:22 PM
does anyone know of a Hosts file manager for Ubuntu like HostsMan in Windows? i'm just looking for something that i could turn it on/off very easily without having to go thru the terminal so that i could allow a webpage here and there. i'm not too knowledgeable in linux.

mellowchuck123
February 25th, 2012, 05:37 PM
does anyone know of a Hosts file manager for Ubuntu like HostsMan in Windows? i'm just looking for something that i could turn it on/off very easily without having to go thru the terminal so that i could allow a webpage here and there. i'm not too knowledgeable in linux.

The only program I know is pup advert-block for Puppy Linux. Maybe you can compile it from source/port it to Ubuntu?

http://murga-linux.com/puppy/viewtopic.php?t=59290

bzd454
March 6th, 2012, 04:56 PM
The only program I know is pup advert-block for Puppy Linux. Maybe you can compile it from source/port it to Ubuntu?

http://murga-linux.com/puppy/viewtopic.php?t=59290

thanks for the response. Compiling is beyond my knowledge though.

i'm just trying to find something easy that would allow me to load up all these hosts file blocking lists as well as all the ABP blocking lists and malware lists etc and then when i visit a site and it doesn't work, be able to whitelist it and keep that whitelist when i update the blocking lists every month or so. and blocking all of china and russia would help i've heard. i'm not really sure the best way to do this though - maybe a firewall or the privoxy program would be better?

mellowchuck123
March 26th, 2012, 01:13 AM
March 25, 2012 HOSTS file.



This is a combination of 13 up-to-date(as of this moment) lists that block ads and sites with malwares(viruses, trojans, worms etc.)

LISTS USED -


http://www.mvps.org/winhelp2002/hosts.zip

http://hphosts.gt500.org/hosts.zip

http://updates.it-mate.co.uk/updates.asp

http://hosts-file.net/download/hosts.zip

http://hosts-file.net/hphosts-partial.asp

http://hosts-file.net/ad_servers.asp

http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext

http://someonewhocares.org/hosts/hosts

http://support.it-mate.co.uk/downloads/HOSTS.txt

http://hostsfile.mine.nu/Hosts

http://www.securemecca.com/Downloads/hosts.txt

http://sysctl.org/cameleon/hosts.win

Spybot S&D Hosts Immunization

The file is optimized, sorted & is in 0.0.0.0 format.

MAKE SURE YOU COPY THE ENTIRE FILE TO /etc/hosts using root or sudo.

_DO NOT_ REPLACE THE FIRST TWO LINES IN YOUR HOSTS FILE-

127.0.0.1 localhost
127.0.1.1 YOUR HOST NAME GOES HERE


If you already have blocking entries, add this list to the bottom of your hosts file.

March 25, 2012 HOSTS file link:

https://ubuntuone.com/0QsGWlv5mJ1jzRTBZuhOlr (https://ubuntuone.com/0QsGWlv5mJ1jzRTBZuhOlr)


:guitar:
Side note- You might want to install an ad-blocking extension in your browser so you don't see the annoying "page not found" error where ads were before.

Sadi58
April 3rd, 2012, 12:35 PM
Thanks...
Is there a way of getting "Spybot S&D Hosts Immunization" list from a permanent online address like others?
In this way, this compilation could be done automatically.
Or perhaps you might post this compiled hosts file to somewhere with a permanent address/link to save the extra effort of announcing every update.
Regards,
Sadi

Grandma_DOG
May 20th, 2012, 06:56 PM
Can a webpage using javascripts detect if you've blocked their ads via hostfile ? Will there be a line of countermeasures developed for people like us?

Sarys
July 17th, 2012, 04:14 PM
one question you said I should backup things? How?

Magnetizer
July 19th, 2012, 03:33 PM
Hello everybody,

I just wrote my own script that can check if one of the hostfiles is updated, automatically download the hostfiles from different places, merge them, undupe them, optimize them etc. and install the hostfile on your system.

After the script is finished you get an email with the difference between the old and the new hostfile. The script also makes a backup of your old hostfile. If anything goes wrong the script stops and you will get an email with the appropriate error message.

So far, the script works nicely but it is still in beta. Right now I use it for the hostfiles from:

http://someonewhocares.org/hosts/
http://winhelp2002.mvps.org/hosts.txt

but I will add other hostfiles aswell.

If you guys are interested I will post the script here.

Just let me know.

@mellowchuck123 your list of 13 hostfiles is quite impressive. Do you also have the URLs to the text/html version of those files?

Ot course, I could extend the script that it can handle .zip files but less work is more time for other things...;-)

Magnetizer
August 28th, 2012, 04:45 AM
Hello everybody,

Here is the thread where I posted the script:

http://ubuntuforums.org/showthread.php?t=2048812

It now uses 11 different blacklists to create a the hostsfile.

I hope it is useful to some of you.

XxionxX
October 27th, 2012, 01:42 AM
How did you make that script? It would be really cool to make my own.

Magnetizer
October 27th, 2012, 07:40 AM
Hi XxionxX,

What should I say?

I just thought about the problem and wrote the script from scratch in 'Perl' with 'vim' as my favourite editor.

Perhaps you have a specific question you would like me to answer? If so, just ask.

As a start, just have a look at the script. You can just download the last .zip file from:

http://ubuntuforums.org/showthread.php?t=2048812

The script is just a textfile that you can open. Then you can see if you can understand it. It is fairly staightforward and there is some inline documentation, so I hope it is self-explanatory.

I doubt it is really useful to recreate the script except if you have a better idea. The script is open-source and licensed under the GPL, so feel free to check it out, change it, give it to your friends and so on.

If you have any suggestions, just let me know.

I hope this is an answer to your question.

Kind regards,

Magnetizer