Plus configure custom domain as a shortcut
When you add a permanent entry to the local DNS cache on your PC, it will always override the information provided by the nameserver. If a nameserver gives the wrong address for a domain or provides no information at all, you can still access the domain if it’s listed in the local Hosts file.
It could also improve lookup performance. If you frequently access a particular server, and you know its IP address isn’t likely to change anytime soon, you can add a local entry to eliminate the initial delay as Windows looks it up. For example, add an entry for your personal website or corporate mail server, so that those DNS lookups aren’t needed.
Also, if you frequently access a remote server without a domain name (rather than only by its IP address), you can configure a custom domain name, to be used as a kind of “shortcut” to the server. So, instead of typing MySQLServer.CorporateDomain.net, you could just type SQL1 into your browser and connect to that server.
Edit Local HOSTS File
To edit your local DNS lookup file, go to the following folder: C:\Windows\System32\Drivers\etc. Note: I am assuming that you have Windows installed in drive C, otherwise change it to your own Windows drive.
Note that there is a special way you have to open the hosts file in order to be able to edit it. Read my previous post on how to edit the hosts file here first. Once open, add an entry at the bottom with two pieces of information: the IP address and the customized domain name. The IP address and the domain name entry should be separated by a single space or a tab. In the example below, I entered an IP address for my Western Digital NAS and I gave it a name of NAS:
Now when I type http://NAS into my browser window, it brings me straight to the web portal for my NAS. Note that you cannot just type the word NAS into the address bar for most browsers because, by default, it will perform a search using your default search engine. You need to have the HTTP in the front so that the browser understands you are trying to resolve a DNS address. It will then check the HOSTS file first.
As for making sites a tiny bit faster, you can add an entry like I did here for my website:
Since my web server IP address isn’t changing anytime soon, I can just add it to the HOSTS file and Windows will never need to do a DNS lookup for that domain.
What’s more fun is using the hosts file to manipulate DNS entries. For example, I could put a different IP address, but leave helpdeskgeek.com as the host name. Now when I type helpdeskgeek.com on that computer, it would take me to whichever site is hosted on that IP address!
Make sure to read my full post on how to block and redirect websites using the HOSTS file. If you have any questions, feel free to comment. Enjoy!