Early on, a central hosts file was manually maintained and shared by the Stanford Research Institute. This system lead to the invention of domains and top level domains like. In the end, the humble hosts file and innovators like Elizabeth J. Feinler lead to the invention of the Domain Name System still in use today.
First, open Notepad as an administrator by pressing the Windows key, typing in "notepad", and clicking "Run as administrator":. You won't be able to see any files in this directory because they aren't text documents. To change the file type, click on the dropdown in the bottom right of the Open menu and click on "All Files":. Note that everything is commented out with characters, meaning that nothing is actually being read from the hosts file. Modern versions of Windows include a sort of DNS system already, so if you visit localhost it'll automatically redirect you to If you're doing some local development and are having problems with localhost, you can just remove the comments from your hosts file:.
Then, open PowerShell by pressing the Windows key, searching for "powershell", and clicking "Run as Administrator":. After that, you should be able to visit localhost in your browser and see whatever you're hacking on. If you're still having issues, try closing your browser completely, then open a new browser window and try again. Even though hosts files have fallen out of favor with newer systems like DNS, they still work for legacy reasons. And hackers have definitely taken advantage of this in the past.
What they would do is point a common website like google. This IP address could serve a site that looks just like Google's, but is actually trying to steal your sensitive information. While this was a problem in the past, most security software like the Windows Security Suite can recognize and fix problems with the hosts file automatically. That said, if you open up your hosts file and see a lot of strange entries, then you may want to revert to the default Windows hosts file.
Just copy and paste the default hosts file from earlier in the article into your hosts file and save. Note that some third-party security software uses the hosts file to block dangerous websites. If that's the case, no worries — your security software should add all those entries back to your hosts file. We'll go over how this works in the next section. Don't want friends or family to visit certain websites on your computer?
Or are you like me and get distracted by all the cat photos on the internet? Also, close the browser windows that are open and reopen them. The one downside is that this only works on one device — you could just reach for your phone and browse Reddit on that instead.
Still, it's a neat way to create some friction on your work computer. This leads nicely into the last trick, which is to use the hosts file to make your life a little bit easier.
If you spend a lot of time adjusting your router's settings, or you have a cool project running on a Raspberry Pi , you'll know that typing in a long IP address is a drag. Instead, you can use the hosts file to make connecting to other devices on your local network much faster. For example, if your router is at Otherwise your browser might not recognize.
Fortunately there are a whole lot of valid TLDs nowadays. Again, the one downside to this method is that it only works on once device. You'd have to update the hosts files on your other devices to enable the same shortcuts. And that should be just about everything you need to know about the hosts file on Windows And a lot of this knowledge should carry over to Linux and macOS. Did you find this helpful? Are there any other hosts file tricks you know? Let me know over on Twitter. If you read this far, tweet to the author to show them you care.
Tweet a thanks. Learn to code for free. Get started. Instead of having to type the IP address into the address bar each time you want to watch YouTube videos, you can just enter the domain name, and the DNS server your device is using will map the name to the right address so you can get to the webpage a lot easier. The hosts file, since it serves as a sort of DNS server, works the same way.
You can enter an IP address that a domain name should be resolved to. In other words, you could order your computer to load a different IP address than the DNS server would, essentially letting you do a few cool things.
One reason to edit the hosts file is if you want a super basic way to block websites from loading on your computer. Enter an invalid or wrong IP address for the site you want to block, and each time you try accessing it, the hosts file will load the IP address you chose.
Depending on what you picked, it might c ompletely block the website. You can use the same technique to make the hosts file block malicious sites. There are even lists of hosts file entries such as this one you can download and import into your hosts file to block hundreds of malicious sites or ads.
Another use for the hosts file is to speed up your web browsing. Tip : Learn how to use alternate DNS servers to get faster internet access. You need to know where to go to find the hosts file before you can open it for editing.
This is the hosts file location in Windows 10 through Windows XP:. The hosts file is a text file, meaning that you need a text editor to make changes to it. There are a few examples in the hosts file to show you how to format your entries.
0コメント