Block Unwanted Sites Without Installing any softwares
By on April 16th, 2008

The Internet in itself is not a very safe place to be in with viruses, torjans, adware and malware all waiting to attack your computer. You can stay safe from these using Antivirus softwares or Anti spyware softwares. To top that list there are tons of sites which popup unwanted ads on you to make your surfing experience a horrible one.

To overcome that there are several softwares and addons to block those ads but those solutions are rather limited to a single browser and the next time you change your PC you will have to reinstall those softwares.

Instead of using multiple softwares for multiple programs to block advertisements you can use a simple trick that will block those ads out without the need for installing any softwares.

The Hosts File

In Windows there is a file called hosts using which you can control the mapping of network names to IP addresses. You can call it as a local DNS cache which windows checks first before using the DNS servers provided by your ISP.

So in short you can control the DNS cache for your system using the hosts file. Let’s put it as such you may not want to load a NSFW (not safe for work) site on your office PC and you just want to make sure it does not load the site at all you can use the hosts file to redirect the NSFW site to say, here is how you can do that.

Locate and open the hosts file

The host file can be located on a Windows XP or Windows Vista machine by going to C:\Windows\System32\Drivers\etc folder. The hosts file does not have any extension and is read only so you will have to change the file permissions before editing it. (Remember to change back the permission to read only once you have edited it so that malicious code can not write to it)

If this is the first time you are opening the hosts file then it should look like the screen shot below


Add a DNS entry to map a IP to a server

In the file as you can the first parameter is which is the IP address of your local machine and localhost is the name of the server, so for instance if you type in http://localhost/ on your machine it will redirect you internally to So now you can simply enter another entry to block your NSFW website and point it out to go to by adding an entry like this.

Once you have done this close the hosts file and try loading the domain in your browser you will internally get redirected to and your site will not load. If you have a webserver running on port 80 you will see the welcome page for that instead of your site.

If you are a bit overambitious and want the NSFW site to go to or any other site you want, you can use this simple trick. Open cmd and type in tracert Once you issue this command you will see some packets being transferred which traces the route, we are not interested in that though. Just after you issue the command you will see the IP Address of the site you are trying to trace, copy that and replace the in the above example with the new IP Address.


For this example I added a entry on my hosts file to point URL to the Google IP and when I open the browser and type in here is what I see when I load in the browser.


This setting is global and any browser or application that tries to access will get the Google Page in response. If you want to restore normalcy simply delete the entry you added from the hosts file.


You can use the trick to play fun on a colleague and redirect their favorite sites to some other site, you can use it for endless different things but the main purpose of this should be to block unwanted sites that pop up ads or are not safe for children and so on.

Since this trick does not require you to install any software you can create and store a hosts file on a portable drive and use it where ever you want.

I will definitely suggest you to use a comprehensive list of sites to block created by and pre configured to the hosts file. Just download and copy the file to the etc folder or simply use the bat file included to do it automatically for you and you can start a ad free Internet experience without having to install any softwares.

Author: Keith Dsouza Google Profile for Keith Dsouza
I am the editor-in-chief and owner of Techie Buzz. I love coding and have contributed to several open source projects in the past. You can know more about me and my projects by visiting my Personal Website. I am also a social networking enthusiast and can be found active on twitter, you can follow Keith on twitter @keithdsouza. You can click on my name to visit my Google+ profile.

Keith Dsouza has written and can be contacted at

Leave a Reply

Name (required)

Website (optional)

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'advanced_comment' not found or invalid function name in /home/keith/ on line 1694
Copyright 2006-2012 Techie Buzz. All Rights Reserved. Our content may not be reproduced on other websites. Content Delivery by MaxCDN