How to use the Windows hosts file to block adverts

WindowsOnline advertising is an important industry for job creation, but unfortunately there are still many advertising companies that use aggressive (including Windows circumvention tactics) to deliver software bundles and with that all sorts of misleading webpages (think those download buttons!) and annoying and malicious adverts.

For the most part adverts which are not intrusive (this doesn’t include persistent cookies) and or follow you from site to site, are a fact of life and necessary if you want to consume online content without having to pay for it.

Some of my readers might already use ad blocking plugins such as AdBlock, but there is another way to block adverts by editing the Windows ‘hosts’ file. This file is your Windows address book for website domains. Every time you type an website address into your browser, the ‘hosts’ file will log it.

Note: All website domains are translated into IP address’s which then allow you to connect to that website. The ‘hosts’ file can also be used to block any web address from accessing your computer. It’s this blocking feature that I will discuss in this post.

Here is how you can block adverts from appearing in your software and your ad-supported software:

  • Open Windows Explorer and Type > C:\Windows\System32\drivers\etc in the task bar
  • Double tap ‘hosts’ file and open with Notepad – IMPORTANT: make a backup copy and name it > ‘hosts- original’ before you edit this file.
  • You will now see the following IP address information:

                   # localhost name resolution is handled within DNS itself.
                   #         127.0.0.1        localhost
                   #        ::1                     localhost

  • Note: You can now add individual websites following the machine name which is denoted by the ‘#’ symbol
  • Next – add the websites we want to block following the ‘#’ symbol highlighted above in the Notepad ‘hosts’ file i.e.127.0.0.1 blocked site.com *
  • The ‘hosts’ file will now search for this domain at the loopback address, but will not be found because the address is actually offline (looping back to your localhost address 127.0.0.1)
  • Next – go to host file site www.hosts-file.net click > download from the “Primary” link and extract the host file (this will be over 30Mb) to your desktop – this is endorsed by my friends at Malwarebytes
  • Once the extraction is complete you will see ‘BAD HOSTS BEIGN HERE’ – this will list millions of domains that will be blocked
  • Next – Click > Save As – navigate to C:\Windows\System32\drivers\etc for the Windows hosts file is located
  • Click the dropdown menu next to ‘Save as type’ > All Files, then double-click the file in the ‘etc’ folder called ‘hosts’
  • Windows will notify you that there is another ‘hosts’ file – you will need to replace it – this will take some time

Once the ‘hosts’ file has finished populating with the blocked domains, any browser or software program you open, will no longer be able to display those adverts. Hosts-file.net regularly update the hosts file blocked list, so it’s worth visiting the site every month, to download and update your blocked website listing.

Safe surfing folks!

Julian

This entry was posted in browser, google, privacy, windows and tagged , , , , . Bookmark the permalink.

2 Responses to How to use the Windows hosts file to block adverts

  1. Eminem says:

    Just the worst kind of advice to give to people. In microsoft windows you have 2 hosts files to administrate, a 32bits and a 64bits and if you want to have it on more than one machine, then you need to administrate even more files.
    Bad advertisement companies change often domain names, which makes it a big job to keep the list up to date and suddenly you are blocking a host which do have legitimate content, they just happen to had the bad luck of buying a domain which used to be used for advertisement once in the time. Also you may block services which happens to use the same domain name as the web advertisement server.

    If you want to block advertisements, you use proper tools for it, like privoxy or a browser addon, you negate the risk of blocking legitimate communication and get rid of the advertisement and you can keep the lists up to date with just a push of a button.

    So please, stop giving bad advice to people.

    • Julian says:

      #Eminem# Thanks for your comment. You are correct when you say ad networks (affiliates and publishers included) will change their domain names in response to be being blocked – but mainly by AV detection engines. Legitimate content may also get blocked, or the site/page may have been compromised. Your comment regards using browser add ons also comes with similar issues to the host file domain blocking – everyone is using URL lists and most will come from Google. Google SafeBrowsing is also much more aggressive and is blocking known URLs and these are being collected by AV vendors (to support their URL blocking). You could also visit VirusTotal. My point is clear – this post isn’t bad advice. It’s factual and relevant given the above, but you are free to disagree.

Leave a Reply

Your email address will not be published. Required fields are marked *