Block Google, MSN (Windows Live) and Yahoo Ads using Hosts File

Discussion in 'Tutorials and Guides' started by safeguy, Aug 1, 2009.

  1. safeguy
    Offline

    safeguy Distinguished Member

    Joined:
    Jul 3, 2009
    Messages:
    5,634
    Trophy Points:
    268
    Ratings:
    +1 / 0 / -0
    Block Google, MSN (Windows Live) and Yahoo Ads using Hosts File

    Are you irritated by the numerous ads 'served' to you while you are browsing the web. If you do, here is one way you can save yourself from all that 'stress'. All you have to do to block ads, banners or cookies is by 'tweaking' windows hosts file.

    For those of you who do not know what a hosts file is, here is a short background information:

    "The Windows Hosts file contains the mappings of IP addresses to host names. This file is loaded into memory (cache) at startup, then Windows checks the Hosts file before it queries any DNS servers, which enables it to override addresses in the DNS. This prevents access to the listed sites by redirecting any connection attempts back to the local machine. Another feature of the HOSTS file is its ability to block other applications from connecting to the Internet, providing the entry exists.

    When a web site or application calls up an advert it normally uses a standard URL like www.anADVERTsite.com which like any URL typed into a web browser must be translated into a machine recognised numerical identifier (IP address) which is a unique identifier of a location on the internet."


    Explanation of why 'editing' the hosts file works in blocking ads:

    By editing the hosts file, the HTML or Java-Script used to call the ads would be unable to reach these ads servers or engines, which are mainly used to serve the ads to you. .

    Alright, let us begin editing the hosts file of your system.

    First of all, we navigate to the folder containing the hosts file.

    Location of Windows Hosts file:

    Windows 95/98/Me
    C:\Windows\hosts

    Windows NT/2000/
    C:\Winnt\System32\drivers\etc\hosts

    Windows XP Home/XP Pro /Vista
    C:\Windows\System32\drivers\etc\hosts

    (Note that you may need administrator access for Windows NT/2000/XP/Vista)

    Locate the hosts file, and right click on it. Select Open.When prompted with "Open With" dialog box to choose a program you want to use to open this file, select any one of these:

    Notepad
    Wordpad
    Any other text editor.

    Block Google Ads


    Add the following lines to your windows host file and block Google from serving ads on your computer. It also helps to cover your track when visiting sites that use Google Analytics.

    127.0.0.1 pagead.googlesyndication.com
    127.0.0.1 pagead2.googlesyndication.com
    127.0.0.1 adservices.google.com
    127.0.0.1 ssl.google-analytics.com
    127.0.0.1 www.google-analytics.com
    127.0.0.1 imageads.googleadservices.com
    127.0.0.1 imageads1.googleadservices.com
    127.0.0.1 imageads2.googleadservices.com
    127.0.0.1 imageads3.googleadservices.com
    127.0.0.1 imageads4.googleadservices.com
    127.0.0.1 imageads5.googleadservices.com
    127.0.0.1 imageads6.googleadservices.com
    127.0.0.1 imageads7.googleadservices.com
    127.0.0.1 imageads8.googleadservices.com
    127.0.0.1 imageads9.googleadservices.com
    127.0.0.1 partner.googleadservices.com
    127.0.0.1 www.googleadservices.com
    127.0.0.1 apps5.oingo.com
    127.0.0.1 www.appliedsemantics.com
    127.0.0.1 service.urchin.com

    Don't forget to save the 'edited' hosts file.

    For those of us who are using Firefox, we can make use of two add-ons/extensions to block Google ads:


    Google also serves ads (to be more precise, text ads) in an iFrame. Therefore, to block Google text ads, it is important to block iFrame coming from ad servers, and in this case, Google’s ad servers. We can do so by installing the Adblock Plus extension. After Adblock Plus is installed, go to the Tools > Extensions menu, highlight Adblock, and click the Options button. In the New Filter: input box, paste this: http://*.googlesyndication.com/*

    P.S. Make sure that in the Adblock preferences window, it is set to Remove ads instead of Hide ads.

    There is also another extension/add-on known as CustomizeGoogle which lets you block Google Analytics cookies. Using this feature makes you more anonymous. But your visit on a single webpage can still be logged. This way, both Google and the owner of the website knows that someone visited a webpage, but it's difficult to track all pages you're visiting.

    Block MSN (Windows Live) Ads


    Add the following lines to your windows host file and block Windows Live/Hotmail/MSN from serving ads on your computer.

    127.0.0.1 view.atdmt.com
    127.0.0.1 rad.live.com
    127.0.0.1 rad.msn.com
    127.0.0.1 live.rads.msn.com
    127.0.0.1 ads1.msn.com

    Don't forget to save the 'edited' hosts file.

    Block Yahoo Ads

    Add the following line to your windows host file and block Yahoo Messenger from serving ads on your computer.

    127.0.0.1 insider.msg.yahoo.com

    Don't forget to save the 'edited' hosts file.

    Now, whenever you login to Gmail, Windows Live Mail, Ymail, you will no longer see ads.

    Additional information:

    If that isn't enough for you, you can block more ads by using an already 'tweaked' hosts file which has already added numerous entries/lines in order to block numerous 'sources' of advertisements. For example. you can download it from MVPS.org

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

    Download the zip file from here and extract:

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

    However, take note guys that in most cases a large HOSTS file (over 135 KB) tends to slow down the machine especially if you are using Windows 2000 and XP. To resolve this issue (manually) open the "Services Editor"

    * Start | Run (type) "services.msc" (no quotes)
    * Scroll down to "DNS Client", Right-click and select: Properties
    * Click the drop-down arrow for "Startup type"
    * Select: Manual, click Apply/OK and restart.

    Sources:

    http://labnol.blogspot.com/2004/10/tweak-your-windows-hosts-file.html
    http://labnol.blogspot.com/2005/11/prevent-google-analytics-from-tracking.html
    http://labnol.blogspot.com/2007/05/secret-google-search-url-that-removes.html
    http://underscorebleach.net/jotsheet/2004/09/block-google-text-ads
    http://thenonhacker.deviantart.com/journal/18675053/

    Update:

    Oops, I forgot that changing the hosts file in Vista is a bit 'different' due to UAC. The 'problem' is if you try to modify your hosts file in Vista, it will not let you save it. It tells you that you don't have permission.

    So here's how to successfully modify the hosts file:

    1) Browse to Start -> All Programs -> Accessories
    2) Right click "Notepad" and select "Run as administrator"
    3) Click "Continue" on the UAC prompt
    4) Click File -> Open
    5) Browse to "C:\Windows\System32\Drivers\etc"
    6) Change the file filter drop down box from "Text Documents (*.txt)" to "All Files (*.*)"
    7) Select "hosts" and click "Open"
    8) Make the needed changes and close Notepad. Save when prompted.

    Source: http://geekswithblogs.net/thibbard/archive/2006/12/13/ChangingYourHostsFileInVista.aspx
  2. Guest Ads
    Online

    Google King of the Internet

  3. as6670
    Offline

    as6670 Regular Member

    Joined:
    Apr 21, 2009
    Messages:
    99
    Trophy Points:
    16
    Ratings:
    +0 / 0 / -0
    I use Hostman which blocks over 70,000 parasites.. :) It is beta but stable, been using this for about a year now with no issues.

    http://www.abelhadigital.com/

    Loads more info here

    http://www.mvps.org/winhelp2002/hosts.htm
  4. brayden
    Offline

    brayden Prominent Member

    Joined:
    Jun 12, 2008
    Messages:
    3,700
    Trophy Points:
    166
    Ratings:
    +0 / 0 / -0
    YOu know that linux has a hosts file exactly like the windows one? you can look at it through:
    Code:
    cat /etc/hosts
    and then add sites to it, just like with windows. :p
  5. NinjaRicer
    Offline

    NinjaRicer Notable Member

    Joined:
    Apr 11, 2008
    Messages:
    924
    Trophy Points:
    66
    Ratings:
    +0 / 0 / -0
    Mac OS X also has a hosts files. In 10.5 Leopard, it's under /private/etc/hosts. You can access and edit through the Terminal with the command. You do need to have the password to the account you're using to edit it.
    Code:
    sudo nano /private/etc/hosts
  6. brayden
    Offline

    brayden Prominent Member

    Joined:
    Jun 12, 2008
    Messages:
    3,700
    Trophy Points:
    166
    Ratings:
    +0 / 0 / -0
    Maybe because Max OS is based on UNIX it has that ;)
  7. hellnoire
    Offline

    hellnoire *nix Technical Support

    Joined:
    Jan 24, 2009
    Messages:
    8,925
    Trophy Points:
    266
    Ratings:
    +0 / 0 / -0
    Bray, you can test for me if you'd like but I think you need to use it under root access to access and save the Hosts file.
  8. brayden
    Offline

    brayden Prominent Member

    Joined:
    Jun 12, 2008
    Messages:
    3,700
    Trophy Points:
    166
    Ratings:
    +0 / 0 / -0
    Nope, don't need root access to edit the hosts file in linux.
  9. luffy
    Offline

    luffy Prominent Member

    Joined:
    Jun 19, 2009
    Messages:
    2,031
    Trophy Points:
    166
    Ratings:
    +0 / 0 / -0
    Thank you.
  10. hellnoire
    Offline

    hellnoire *nix Technical Support

    Joined:
    Jan 24, 2009
    Messages:
    8,925
    Trophy Points:
    266
    Ratings:
    +0 / 0 / -0
    Fair enough, works for me lol.
  11. Neo
    Offline

    Neo Experienced Member

    Joined:
    Jun 19, 2010
    Messages:
    1,558
    Trophy Points:
    106
    Ratings:
    +2 / 0 / -0
    i edited host file but i still see yahoo ads ??