How do I set an alias name in the hosts file?

6

3

I have a production server, on which three different application are running. I need to configure aliases for that server, according to which application needs to be accessed by the user.

How do I set an alias name in the hosts file?

user11222

Posted 2009-09-15T14:00:57.817

Reputation: 219

Answers

7

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     test.server.com      test
192.168.0.3     another.server.com   another

C.Schmalzgruber

Posted 2009-09-15T14:00:57.817

Reputation: 292

4Default path to hosts file on Windows XP C:\WINDOWS\system32\drivers\etc\hosts – random – 2009-09-15T14:13:16.533

Based on the question I assumed that the threadstarter is knowing where the hosts-file is. Nevertheless thank you for the addendum :-) – C.Schmalzgruber – 2009-09-15T14:17:02.657

2uh, having two identical names 127.0.0.1 localhost test.server.com 192.168.0.2 test.server.com test for differnt IPs can cause headaches... I'll assume a copy&paste error there ;) – brandstaetter – 2009-09-15T14:33:44.067

thank u but others not able to connect to alias name. – user11222 – 2009-09-15T14:43:31.660

3Yes, 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. – pkaeding – 2009-09-15T15:12:51.663

3

Usually, the Syntax is:

<<IP>> hostname alias1 alias2

example:

127.0.0.1 localhost lo loopback

I hope it works the same under Windows XP

brandstaetter

Posted 2009-09-15T14:00:57.817

Reputation: 4 119