我知道第一个是规范的 ,但是我不完全理解实际的含义。 这个问题是由主机名为-f的手册页触发的,特别是当它说:
Technically: The FQDN is the name gethostbyname(2) returns for the host name returned by gethostname(2). The DNS domain name is the part after the first dot.
假devise算机主机名是foo 。
采用以下configuration:
127.0.0.1 localhost 127.0.1.1 foo.example.com foo
命令主机名-f返回foo.example.com 。
虽然,具有以下configuration:
127.0.0.1 localhost 127.0.1.1 foo foo.example.com
命令hostname -f返回foo 。
具体来说,在讨论hostent.h_name时,是什么人称为“主机的正式名称”的第一个主机名?
注 :我在Debian上,但希望这些概念是一般* nix兴趣。
链接 :一个可能相关的问题。
链接 : 这个问题表明,第二种风格是错误的,但我已经看到它在networking上多次应用。
如你所怀疑的,第一个条目是规范的(官方)名称,其中所有后续名称都只是第一个的别名。 根据我的经验(在典型的产品环境中),/ etc / hosts看起来像这样:
127.0.0.1 localhost.localdomain localhost 10.0.0.1 myhostname.domain.tld myhostname