Using the HOSTS File to Overide Internet DNS


Introduction

It is possible to override internet DNS records locally for your own computer by manually specifying a DNS record hostname IP address using your computers HOSTS file. This will force your computer you resolve an internet name to the IP address you have specified rather than the IP address that will resolve if your computer was to check the public internet nameservers for that domain. The approach will also work for computer hostnames or ip addresses that operate on your internal network.

The ability to manually specify the resolution IP address for a particular hostname comes in handy when you want to test a website or a networking configuration on a new server from your local computer without actually changing the public internet IP address until you are ready.

HOSTS File on Windows

The HOSTS file for static DNS entries on windows operating systems is located:

C:\Windows\System32\drivers\etc\hosts

Note that the Windows hosts file does NOT have a file extension (Eg. txt) and so may not show up as having an application associated with it. However it is is a simple text file format and you can be opened in a standard text editor such as Windows Notepad. Just right-click the file, and choose Open.