kick off the hosts file, which is located under C:\Windows\System32\drivers\etc.
Occasionally you may need to edit the hosts file on your machine.
Your host file might have been edited maliciously in an attack, or as a prank.
Hannah Stryker / How-To Geek
Alternatively, you may just want to control access to certain websites or control connection traffic.
What is the Hosts File Used For?
Since they were used to aide in data pipe name resolution, hosts files grew to become massive documents.
The syntax stays mostly the same across all platforms.
Most hosts files will have several entries forloopback.
We can use that for the basic example for the typical syntax.
It isn’t used much in in modern Windows networking, however.
The Windows hosts file, like other files that can be found in the Windows folder, is protected.
You need administrative privileges to move, edit, or delete the file.
You don’t need to go download another one just for this job.
)” rather than “Text Documents (.txt).”
After you change that setting, locate the “hosts” fileand click open.
it’s possible for you to then edit the hosts file however you’d like.
There are a few obvious things to do with it, likeblock or reroute internet traffic.
you’re free to use it toblock access to websites, if you want.
you better run Notepad as administrator, navigate to the hosts file, and then open it up.
There are a few ways you might do this.
Once notepad is open you’re able to edit the file.
In this example we will block Facebook.
To do this just enter in the following after the # mark.
you’re able to also use theloopback addressinstead of0.0.0.0, but that is basically up to personal preference.
Now that you have edited your Hosts file verify to save it.
Now notice if we make a run at access Facebook in IE we can’t get to the page.
you could use your favoritecommand-line editoror your favorite GUI text editor.
For this example we will use Vim, since it is one of the traditional text editors in Linux.
Ubuntu’s hosts file location is the /etc/ folder.
Now that it is open we can edit it to redirect Facebook into nothing.
You will notice that with Ubuntu there is also a section for IPv6.
Now we can save the file and make a run at go to Facebook.com.
The hosts file on macOS is located in/etc/just like on Linux.
The file will look a lot like the hosts file found in Windows and Linux.
Again we are going to redirect Facebook to 0.0.0.0.
Safari, just like a surfing app on Windows and Ubuntu, will be unable to connect to Facebook.
Why Isn’t The Hosts File Blocking Connections?
All of the major modern browsers offerDNS Over HTTPS (DOH).
For our purposes here, it limits the utility of the hosts file.
A lot of browsers will enable DNS Over HTTPS automatically and use their own DNS servers.
That results in the net web client completely bypassing the hosts file.
This should get you started in understanding the Hosts file and how it can help protect your rig.