尝试为我的 Ubuntu 机器添加第二个 IP 地址

尝试为我的 Ubuntu 机器添加第二个 IP 地址

我正在使用 Ubuntu 14.04,并尝试为我的计算机添加第二个 IP 地址,并使它们可以从任何地方访问。以下是我的配置/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 46.10.222.174
netmask 255.255.252.0
gateway 46.10.222.1

auto eth0:0
iface eth0:0 inet static
address 46.10.222.142
netmask 255.255.252.0

现在,当我尝试从机器本身 ping 另一个目的地时,看一下我收到的内容:

ping abv.bg
ping: unknown host abv.bg

正如您所测试的,没有问题ping abv.bg。我不知道为什么我会遇到这个问题。

我的第二个也是最重要的问题是,我只能使用 IP 46.10.222.174 ping 并访问机器。

为什么我无法访问我的第二个 IP?你可以自己测试一下。你可以 ping 我的第一个 IP,但无法 ping 第二个 IP,为什么?

我的错误在哪里?

答案1

您应该(以 root 身份)创建一个文件 /etc/resolv.conf,其中包含以下几行

search yourdomain.com

nameserver 8.8.8.8
nameserver 4.4.4.4

这将允许 DNS 使用 Google 名称服务器。建议使用“search yourdomain.com”行,但可选 - 如果您输入“myhost”,它将查找“myhost.yourdomain.com”

相关内容