Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the hosts file redirect an IP address? [closed]

Tags:

windows

hosts

I have cloned a Windows 2003 machine and put it on the same domain as the original.

I want to make sure that the clone never accesses the original. I want it to think it is the original. I don't want to exhaustively check the clone for everything that might reference the name or IP address of the original and change to the name or IP address of the clone.

Will I get what I want if I add the following two lines to the hosts file on the clone?

127.0.0.1   originalname   #divert attempts to access the original machine
127.0.0.1   192.168.1.2    #divert attempts to access the original machine

originalname is the name of the original machine. 192.168.1.2 is the IP address of the original machine.

like image 584
cja Avatar asked May 31 '13 10:05

cja


People also ask

How do I divert my IP address?

Download the appropriate VPN app for your device. Open the VPN app and select a server, within your own country is fine although if you want to access a specific service make sure to choose a server in a country where it's unblocked. That's it! You should now have a different IP address.

Does hosts file override DNS?

The hosts file on your computer allows you to override DNS and manually map hostnames (domains) to IP addresses. This can come in handy during migrations as you might want to see how your website looks on a different server, but perhaps the DNS hasn't propagated yet.

What is the hosts file used for?

HOSTS files are used to override the DNS system for testing purposes so that a Web browser or other application can be redirected to a specific IP address.


1 Answers

You first line should do the trick although you might want to add an additional short name to that entry.

Your second entry will never work. You can not redirect/mask an IP address with another IP address. The server should no longer think it should be resolved at 192.168.1.2 once you put the first line in place.

To be 100% sure you can always Flush the DNS cache for good measure. http://technet.microsoft.com/en-us/library/cc782459(v=ws.10).aspx

This is worth reading and should explain the process of name resolution on Windows operating systems: http://support.microsoft.com/kb/172218.

Hosts files can not redirect IP addresses. They can only redirect names/hosts to resolve to a different IP address.

like image 194
Gerric Chaplin Avatar answered Nov 03 '22 09:11

Gerric Chaplin