Changing domain IP address without modifying DNS

Sometimes it is required to change the domain-ip mapping of a domain without actually modifying the DNS records. I usually require this for sanity testing before moving applications to a new server.

In such cases one option can be to use a secondary domain or a subdomain pointing to the new server and then complete testing.

Sometimes, applications are hard coded to use a specific domain name, thereby leaving no alternative but to test with the domain name only.

One solution to this problem is to modify the local hosts file. Thankfully Windows (from the early versions) uses a file called “hosts” (without any extension) to map domain names to ip addresses. This file contains no mappings by default but can be used to setup local domain-up mapping. Any mapping set here will only affect this system and will not cause any network wide changes.

This file is located in “c:windowssystem32driversetc” folder where “c” refers to the root windows drive. This file is plain text and can be edited in notepad.

A sample mapping would be (one mapping per line)

By adding this line, any DNS queries to will be translated to instead of the mapping in public DNS servers.

Remember to remove this mapping after testing. Forgetting to remove this mapping can cause some serious trouble later. I have spent hours debugging application problems because of leftover mapping from previous test runs.

Leave a Reply

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