5 domain-name-system gentoo fqdn
我的问题解决了我的 Gentoo Linux 系统上 hostname -f 的奇怪行为。
症状:
rt01 ~ # time hostname -f
rt01.domain.net
real 0m5.007s
user 0m0.001s
sys 0m0.000s
Run Code Online (Sandbox Code Playgroud)
使用 strace 我可以看到执行了以下步骤:
该机器上的 iptables 设置阻止它连接到任何 DNS 服务器。所以它 - 按设计 - 在这一点上被阻止。我的期望是,使用以下配置不需要此步骤:
/etc/host.conf
# This keyword specifies how host lookups are to be performed. It
# should be followed by one or more lookup methods, separated by
# commas. Valid methods are bind, hosts, and nis.
#
order hosts, bind
Run Code Online (Sandbox Code Playgroud)
/etc/hosts
# IPv4 and IPv6 localhost aliases
127.0.0.1 rt01.domain.net rt01 localhost
<public ip> rt01.domain.net rt01
::1 localhost
Run Code Online (Sandbox Code Playgroud)
/etc/conf.d/主机名
# Set to the hostname of this machine
hostname="rt01"
Run Code Online (Sandbox Code Playgroud)
有人可以向我解释一下,为什么 hostname -f 尝试连接到 DNS 服务器。我认为 /etc/hosts 提供的信息应该足够了。
DNS 查询的解析顺序取决于 的内容/etc/nsswitch.conf。具体来说,该行的选项顺序为hosts
例如,此行将导致您的计算机在检查本地文件之前查询服务器:
hosts: dns files
Run Code Online (Sandbox Code Playgroud)
手册页:http://man7.org/linux/man-pages/man5/nsswitch.conf.5.html
| 归档时间: |
|
| 查看次数: |
155 次 |
| 最近记录: |