Using hosts file to block unwanted sites - failing to block

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
lexington523

Using hosts file to block unwanted sites - failing to block

Post by lexington523 »

I solved this problem on my own but I thought that others might find it useful. I was not able to find this answer anywhere else on the web.

If you are using your hosts file to redirect unwanted sites to your own computer but you find that the sites are not being blocked even from a ping. The solution is probably that you overwrote the hosts file in stead of appending to it. I did this and it removed the ipv6 localhost info. Once this was gone, the hosts file would not redirect any traffic. Linux ignored the hosts file untill I replaced this line.

::1 localhost

I don't know why missing the ipv6 localhost info has this effect. If anyone does it would be nice if you could reply below.
In any case, make sure you append blocked sites to your hosts file. Do not overwrite it. The minimum info to make it would correctly will look like this:

-------------
127.0.0.1 localhost

::1 localhost

0.0.0.0 site.youwanttoblock.com
AUserInEssex

Re: Using hosts file to block unwanted sites - failing to bl

Post by AUserInEssex »

To reply massively late:

- thanks;
- this page, on adding an adblocking hosts file, is useful: https://delightlylinux.wordpress.com/20 ... osts-file/
Post Reply

Return to “Tutorials”