3

我的 Linux 机器上有 4 个正在运行的 eth 端口(eth0 到 eth3)。那么如果我给出命令host <hostname>,将返回哪个 eth 端口的 ipaddress?linux如何决定返回哪个eth端口的ip地址?

谢谢, LinuxPenseur

4

2 回答 2

4

host 不查看您的本地 IP,它根据 /etc/nsswitch.conf 中指定的规则查找主机名

在 nsswitch.conf 中,您通常会有以下条目:

hosts: files dns

这意味着解析器将首先检查 /etc/hosts,如果它在那里找不到任何东西,它将检查 /etc/resolv.conf 并向指定的 DNS 服务器询问 IP,可选地附加“搜索”和“域”后缀在 resolv.conf 中指定

http://www.faqs.org/docs/linux_network/x-087-2-resolv.library.html

于 2011-02-15T10:28:11.930 回答
2

你的“主要”界面是什么?那个是用的。

http://ubuntuforums.org/archive/index.php/t-1120370.html

于 2011-02-15T10:28:23.413 回答