Here's a quick way to fake a DNS entry. The idea is that you (as a developer) want to browse the site you're working on via the domain name for some reason. Maybe you're testing the virtual host settings on your server, or you're demonstrating for a client or whatever.

The following is a quick and easy way to do it by editing the hosts table on your local machine. The hosts table was a very early incarnation of the DNS system, that is still used for certain circumstances (holding the loopback hostname for example). It is simply a text file with IP / hostname pairs listed one per line.

Find and open the hosts table

Fire up your favourite text editor (vi / emacs / kate / whatever in Linux, notepad in Windows) and point it at the /etc/hosts file (linux) or %SYSTEMROOT%\system32\drivers\etc (Windows). The hosts table file looks something like this on my laptop        localhost.localdomain        localhost

Or this on windows

 # Copyright (c) 1993-1999 Microsoft Corp.
 # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
 # This file contains the mappings of IP addresses to host names. Each
 # entry should be kept on an individual line. The IP address should
 # be placed in the first column followed by the corresponding host name.
 # The IP address and the host name should be separated by at least one
 # space.
 # Additionally, comments (such as these) may be inserted on individual
 # lines or following the machine name denoted by a '#' symbol.
 # For example:
 #          # source server
 #              # x client host localhost

Add your entry

The hosts table is arranged in columns. The first column is the IP address, the second is the hostname. So if we wanted to add a temprary resolution for to the IP address we would add the following to the bottom of the hosts table.

You can check if its working by pinging the domain name. It should happily resolve to the IP you just entered. Job done! Once you no longer need the entry you can remove it or comment it out with a hash (#) at the start of the line.