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 google.com, 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 127.0.0.1 which is the IP address of your local machine and localhost is the name of the server, so for instance if you type in hosts file,block websites,hosts