如何在hosts文件中引用主机名?

时间:2013-02-21 17:50:09

标签: macos networking hosts hosts-file

我连接到与“staging.local”相同的网络上的本地服务器(其中staging是本地服务器上的主机名)。

是否可以在os x hosts文件中执行此命名:

staging.local  mydomain.com

这似乎不起作用。直接引用IP地址确实有效,但它可以经常更改(192.168.0.196 mydomain.com)。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

不,使用unix主机文件无法做到这一点。

这可以使用CNAME进行DNS / bind,但hosts文件基本上就像使用A / PTR一样 - 不允许使用别名。

你可以创建别名供ssh使用,如果你将在〜/ .ssh / config

中使用它们
Host staging.local
 HostName mydomain.com