具有多个运行接口的计算机上的 Linux 主机名解析
我的 Linux 机器上有 4 个正在运行的 eth 端口(eth0 到 eth3)。因此,如果我输入命令 host
,将返回哪个 eth 端口的 IP 地址? linux 如何决定返回哪个 eth 端口的 IP 地址?
谢谢, Linux彭瑟尔
I have 4 running eth ports on my Linux machine (eth0 through eth3). So if i give the command host <hostname>
, which eth port's ipaddress will be returned? how does linux decide which eth port's ip address to be returned?
Thanks,
LinuxPenseur
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
host 不会查看您的本地 IP,它会根据 /etc/nsswitch.conf 中指定的规则查找主机名
在 nsswitch.conf 中,您通常会有此条目:
这意味着解析器将首先检查 /etc/hosts,如果在那里找不到任何内容,它将检查 /etc/resolv.conf 并向指定的 DNS 服务器询问 IP,可选择附加 resolv.conf 中指定的“搜索”和“域”后缀
请参阅 http://www.faqs.org/docs/linux_network/x-087-2- resolv.library.html
host does not look at your local IPs, it looks up the hostname based on the rules specified in /etc/nsswitch.conf
In nsswitch.conf you will typically have this entry:
This means that the resolver will first check /etc/hosts, if it cannot find anything there it'll check /etc/resolv.conf and ask the specified DNS servers for the IP, optionally appending the "search" and "domain" suffixes specified in resolv.conf
See http://www.faqs.org/docs/linux_network/x-087-2-resolv.library.html
您的“主要”界面是什么?就用了那个。
http://ubuntuforums.org/archive/index.php/t-1120370.html
What's your "primary" interface? That one is used.
http://ubuntuforums.org/archive/index.php/t-1120370.html