Forcing IP Resolution of a Domain for Local Testing Purposes

If you need to test a server using a domain name, but can not repoint the domain to test, you can force your local machine to resolve the domain name to the IP address of your choice.  You do this using the hosts file, on Windows, or the resolv.conf file on a linux OS.  This is going to be OS specific, find the directions below for your OS.

 

Windows XP:

COMING SOON!

Windows Vista/7/8:

Start -> All Programs -> Accessories -> Notepad

Right click and run as administrator.

File -> Open

%SystemRoot%\system32\drivers\etc\hosts

You may need to type in the name hosts again.

Here you can edit.  The format is rather clear.  For each line you have an IP followed by white space, followed by each FQDN you want to resolve to this IP.  This list of FQDN’s need to be white space delimited.  Save the file.  Flush your DNS cache:

ipconfig /flushdns

If you are testing with a web browser, you may need to take additional steps to circumvent DNS caching within the program.

If you are going to be editing this file often, you can also make a shortcut as so:

Create a shortcut in a folder of your choice.
For the “Type the location of the item” field, put in the following:
C:\Windows\System32\notepad.exe C:\Windows\System32\drivers\etc\hosts

creating_hosts_shortcut_01

Click Next. On this screen I just title the shortcut ‘hosts’.

Drag this shortcut to your task bar.

Right click on the notepad icon that shows, then right click on the notepad icon in the popup bubble. From there go to Properties.

creating_hosts_shortcut_02

 

On the Shortcut tab, go to Advanced. Check the box for Run as Administrator.

creating_hosts_shortcut_03

Click OK, Click OK. Now when you click on that link it will prompt you to run Notepad as Administrator and allow you to edit and save the hosts file very easily.

Also, COMING SOON!

Mac OS X 10.0 – 10.1.5:

COMING SOON!

Mac OS X 10.2 and newer:

COMING SOON!


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *