当前位置: 首页>>技术教程>>正文


linux – 在Ubuntu 10.04上,/etc/hostname是否应包含服务器的FQDN?

, ,

问题描述

在Ubuntu 10.04上,/etc /hostname是否应包含服务器的标准域名?

最佳办法

不,仅主机名部分。 According to Ubuntu’s man pages/etc/hostname应该仅包含主机名的主机名部分,而不应包含FQDN:

THE FQDN

You can’t change the FQDN (as returned by hostname –fqdn) or the DNS domain name (as returned by dnsdomainname) with this command. The FQDN of the system is the name that the resolver(3) returns for the host name.

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.

Therefore it depends on the configuration (usually in /etc/host.conf) how you can change it. Usually (if the hosts file is parsed before DNS or NIS) you can change it in /etc/hosts.

NOTES

The address families hostname tries when looking up the FQDN, aliases and network addresses of the host are determined by the configuration of your resolver. For instance, on GNU Libc systems, the resolver can be instructed to try IPv6 lookups first by using the inet6 option in /etc/resolv.conf.

FILES

/etc/hosts /etc/hostname This file should only contain domain name and not the full FQDN.

次佳办法

Josh指出了Ubuntu的建议,但我不确定这是一条硬性规定。

/etc/hostname用于设置系统的主机名,该名称与hostnameuname -n打印的名称相同。该名称将在登录提示时使用,例如在虚拟控制台上或在Gnome GDM登录屏幕上。

如手册页所述,在执行hostname --fqdndnsdomainname时,它也用作DNS查询的输入。

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.

这意味着,如果这只是一个简单的词,则解析程序将追加/etc/resolv.confsearchdomain设置中列出的域,以尝试查找FQDN。如果您在/etc /hostname中有一个FQDN,则意味着它不必尝试附加一个或多个域:名称是明确的。

所以我会说这是有效的。如果有人可以证明我的话,我会很感兴趣。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/11434.html,未经允许,请勿转载。