Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want resolve Windows' hostname (computer name) to another IP. 127.0.0.1 myhostname in hosts file doesn't work. ping myhostname shows that it have ethernet adapter IP (192.168.1.2).

It works in Windows 7, but not in Windows 8.

Any ideas?

share|improve this question
    
If drop ethernet connection, it resolves to 127.0.0.1. But still doesn't want read hosts file (e.g 8.8.8.8 myhostname doesn't work). –  veg Mar 27 '13 at 0:24
    
What file (please provide the full path) are you editing? Can we see its contents? –  ernie Mar 27 '13 at 0:33
    
I edit Windows hosts file. It works for any other name except windows hostname. –  veg Mar 27 '13 at 0:34
3  
Maybe you could tell us a little bit more of what you are trying to accomplish? –  G Koe Mar 27 '13 at 1:54
    
It works in Windows 7, could someone confirm it works on Windows 8? –  veg Mar 27 '13 at 2:39

1 Answer 1

The hosts file is used to map

hostnames to IP addresses.

It will NOT Map IP addresses to hostnames but it can be used to produce hostname "aliases".

The hosts file produces the internal equivalent of A and PTR records from the DNS, i.e. mapping of hostname to IP address .

For adding a alias name to a server in the hosts file you have to make the following structure:

In the first column you have to add the IP-Address, in the second column the host-name and in the third column you have to add the desired alias-name. Any subsequent columns are alias for that host. In the example's second line the IP-Address 192.168.0.2 is for the server test.server.com and another name for it is test.

For example:

127.0.0.1       localhost            test.server.com
192.168.0.2     test2.server.com     test2
192.168.0.3     another.server.com   another

This uses the hosts file on your computer. You will need to edit the hosts file on each computer that will use the alias; if you want to make this a global change, you need to use a real DNS server.

share|improve this answer
    
Thank you @C.Schmalzgruber –  G Koe Mar 27 '13 at 1:38
    
In the example's second line the IP-Address 192.168.0.2 is for the server test.server.com and another name for it is test. It's not true, if you try to access test.server.com you will get 127.0.0.1. On topic: it doesn't help me to change hostname IP. –  veg Mar 27 '13 at 1:49
    
The Hosts file will NOT map IP-->Hostname. It goes the other way. You CAN setup a DNS server... –  G Koe Mar 27 '13 at 1:53
    
Why should I use DNS server for SINGLE machine? –  veg Mar 27 '13 at 1:55
    
Well, could you explain why 127.0.0.1 justanotherhostname.com works fine, but 127.0.0.1 myhostname doesn't? –  veg Mar 27 '13 at 2:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.