Hopstream
Hopstream

Reputation: 6451

How to reference a hostname in a hosts file?

I connect to local servers on the same network as "staging.local" (where staging is the hostname on the local server).

Is it possible to do the name in os x hosts file like this:

staging.local  mydomain.com

That doesn't seem to work. Referencing the ip address directly does work but it can change often (192.168.0.196 mydomain.com).

Any help would be greatly appreciated.

Upvotes: 0

Views: 1592

Answers (1)

David Houde
David Houde

Reputation: 4778

No, this cannot be done with unix hosts files.

This can be done with DNS/bind using CNAME, but the hosts file is basically like using A/PTR -- No aliases allowed.

You can create aliases for using by ssh if this is what you will be using them for in ~/.ssh/config

Host staging.local
 HostName mydomain.com

Upvotes: 2

Related Questions