At times you might want to block websites on your computer or your kids’ computer(Depending upon who is more naughty). Now you could create firewall rules or use some antivirus to do it but the best way to achieve this in a simple way would be to modify the host files.
Block Websites Without Any Software Using Host File
What are Host Files?
Host files are files that are used to map domain names or hostnames to IP addresses. You don’t need to map every website that you visit its IP address because that happens by default when you visit a website. But for some specific cases, you might want to do that. We usually use the host files in web development to test a domain name with our local server.
Blocking a Website
To block a website, we need to simply map a domain name or URL of that website to our localhost (127.0.0.1). On Windows The host file is located here C:\Windows\System32\Drivers\etc\hosts Linux users can find it in /etc/hosts. It looks like this you just need to add a new line with the localhost address to the domain name that you want to block.
Let’s say you wish to block facebook.com, so you need to add this line at the end of the file. 127.0.0.1 www.facebook.com
This will require administrator permissions, and your end file should look like this
Now let us try to load Facebook. You can see that we have successfully blocked a website on our computer and if you ever wish to unblock it, simply remove that line and you will be good to go.
That was easy. Wasn’t it? If u still have a doubt regarding something, feel free to pen down your comments and I’ll be there for you.