How do I alias a hostname in windows?

28

5

Same question as How to alias a hostname?

but for windows, particularly windows 7

I don't want to specify an ip address (hosts file) just an alias so that \\mylaptop points to \\longcomputername and all programs will be able to find it should I use that dns

Maslow

Posted 2011-08-05T16:46:48.390

Reputation: 786

1Have you tried just editing the hosts file (in C:\windows\system32\drivers\etc) with just "longcomputername mylaptop"? – Mike Keller – 2011-08-05T17:09:44.547

3@MikeKeller - The OP specifically said he didn't want to use the hosts file, and the hosts file (as I understand it, at least) only works on a name-to-IP basis - it can't deal with name-to-name associations. – Iszi – 2011-08-05T17:14:06.697

I'm very interested in seeing an answer to this. One problem that I've run into recently is trying to map the same network location more than once - Windows won't let you do it. You can map it twice by using the name for the first one, and the IP for the second. If there is a way to alias names, one might be able to map the same network location a bunch of times. – Fopedush – 2011-08-05T18:30:22.953

Answers

16

HOSTS is only for giving names to IP addresses. So you can so something like:

10.1.1.2 Computer.domain.com Alias1 Alias99

And with that you could ping 10.1.1.2 by "computer.domain.com" "alias1" or "alias99".

But you can't do

Computer Alias1 Alias99

To do it by host names only (I.E. the target host is on a dynamic IP), then you need a DNS server (assuming dynamic IP on target host, then you'll need one that keeps up to date with the host's changing IP).

In the DNS server you'd set alias entries ("CNAME" records) that point to the target machine's Host entry ("A" record).

Ƭᴇcʜιᴇ007

Posted 2011-08-05T16:46:48.390

Reputation: 103 763

5that's why I asked if there was a non-hosts method since hosts requires ip – Maslow – 2011-08-05T20:14:17.903

6@Maslow - Yup, and the root of the answer is, "use DNS". :) I just wanted to expand the answer to include why HOSTS can't do this (for future visitors). – Ƭᴇcʜιᴇ007 – 2011-08-05T20:25:06.050