How to Edit the Hosts File in Windows 10 to Block Malware
One of the easiest yet least known ways to drastically improve any PC’s ability to defend itself against malware such as adware or spyware is to simply redirect malicious websites using the hosts file.
What is a hosts file and how does editing it block malware?
Before we begin, let’s first talk about what a host file is. When a PC accesses the internet, it uses a DNS server to resolve domain names to IP addresses. Your PC then follows the IP addresses to the servers that will serve you a webpage or provide you with another service.
For example, when you type in Google.com, your PC will ask a DNS server what the IP address of Google.com is. The DNS server may then respond with something like 220.127.116.11 which is then where your PC will go to find the webpage you’re looking for.
The hosts file allows your PC to bypass the DNS for the domain names and address that are specified within the file. As you may imagine, if we had a regularly updated list of malicious websites, we can easily redirect those websites to something like 0.0.0.0 thereby preventing you from the possibility of getting infected by those websites. Additionally, if you are infected, a modified hosts file can also help block known adware and spyware as they’re no longer able communicate with the advertising servers they’re expecting to retrieve ads from.
Now that you’ve been convinced that editing the hosts file can significantly improve your online security, here’s how to edit it.
Edit the Hosts File
Go to the Start Menu and type in Notepad. Right click on Notepad and click on Run as administrator. This is important! If you don’t do this, you will get permission errors when trying to save the modified hosts file.
Once Notepad is open, go to File, then click on Open. Alternatively, you can also hit Ctrl+O.
Click on the address bar, type in C:\Windows\System32\drivers\etc and hit enter. This should navigate you to the C:\Windows\System32\drivers\etc directory. You can also do this manually if you’d like.
You should see an empty directory. Don’t worry. You haven’t done anything wrong. At the bottom right corner is a drop down menu that allows you to select the file type to show. The file type is Text Documents (*.txt) by default. Switch this to All Files (*.*).
At this point, you should see a list of files. Select hosts and click Open.
Once the hosts file is open, you can now copy a modified hosts file such as the hosts file from MVPS.org and paste it into your hosts file.
Once the file is pasted in, go ahead and click on File then click on Save. Alternatively, you can also hit Ctrl+S.