How to add a local DNS entry for a domain

add a local DNS entry for a domain

How To Add or Edit Local Host For Testing Web Sites

There are many times when you want to test a website you have designed before the actual domain name’s DNS (Domain Name System) entry is updated, at that time we can add local DNS entry in a local host file to browse a website locally before publishing it worldwide.

What is the Hosts File On My Computer?

The hosts file is one of several system facilities that assists in addressing network nodes in a computer network. It is a common part of an operating system’s Internet Protocol (IP) implementation, and serves the function of translating human-friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network.

File content

The hosts file contains lines of text consisting of an IP address in the first text field followed by one or more host names. Each field is separated by white space – tabs are often preferred for historical reasons, but spaces are also used. Comment lines may be included; they are indicated by an octothorpe (#) in the first position of such lines. Entirely blank lines in the file are ignored. For example, a typical hosts file may contain the following:

127.0.0.1 localhost loopback
::1 localhost

How to open a hosts file?

Go to Start > run Notepad.

Right click on the Notepad icon and select Run as a administrator.

Select Open from the File menu option.

Browse to c:\windows\system32\drivers\etc\hosts.

Add the host name and IP address to the bottom of the host file.

For example, we want to resolve www.yahoo.com from an IP address 69.147.125.65, therefore we have added following in hosts file.

Save the host file and browse the website now as its resolving from a IP defined in a hosts file.

About Anant 373 Articles
Senior technical writer