Ubuntu Server 9.10 上的两个网络适配器 - 不能同时工作吗?

7 networking ubuntu-9.10 interface

我正在尝试在 Ubuntu(服务器版)9.10 中设置两个网络适配器。一个用于公共互联网,另一个用于私有 LAN。

在安装过程中,我被要求选择一个主网络适配器(eth0 或 eth1)。我选择了 eth0,在 的内容中向安装程序提供了下面列出的详细信息/etc/network/interfaces,然后继续。过去几天我一直在使用具有这些设置的此适配器,一切都很好。

今天,我决定是时候设置本地适配器了。我编辑/etc/network/interfaces以添加 eth1 的详细信息(见下文),并使用sudo /etc/init.d/networking restart.

此后,尝试使用其外部 IP 地址 ping 机器失败,但我可以 ping 其本地 IP 地址。

如果我使用 关闭 eth1 sudo ifdown eth1,我可以再次通过其外部 IP 地址成功 ping 机器(但显然不是其内部 IP 地址)。恢复 eth1 使我们回到原来的问题状态:外部 IP 不工作,内部 IP 工作。

这是我的/etc/network/interfaces(我已经删除了外部 IP 信息,但这些设置从工作时起没有改变)

rob@rhea:~$ cat /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 (public) network interface
auto eth0
iface eth0 inet static
        address xxx.167.218.118
        netmask 255.255.255.240
        network xxx.167.218.112
        broadcast xxx.167.218.127
        gateway xxx.167.218.126

# The secondary (private) network interface
auto eth1
iface eth1 inet static
        address 192.168.99.4
        netmask 255.255.255.0
        network 192.168.99.0
        broadcast 192.168.99.255
        gateway 192.168.99.254
Run Code Online (Sandbox Code Playgroud)

然后我这样做:

rob@rhea:~$ sudo /etc/init.d/networking restart
 * Reconfiguring network interfaces...                                   [ OK ]
rob@rhea:~$ sudo ifup eth0
ifup: interface eth0 already configured
rob@rhea:~$ sudo ifup eth1
ifup: interface eth1 already configured
Run Code Online (Sandbox Code Playgroud)

然后,从另一台机器:

C:\Documents and Settings\Rob>ping xxx.167.218.118

Pinging xxx.167.218.118 with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for xxx.167.218.118:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Run Code Online (Sandbox Code Playgroud)

回到有问题的 Ubuntu 服务器上:

rob@rhea:~$ sudo ifdown eth1
Run Code Online (Sandbox Code Playgroud)

...再次在另一台机器上:

C:\Documents and Settings\Rob>ping xxx.167.218.118

Pinging xxx.167.218.118 with 32 bytes of data:

Reply from xxx.167.218.118: bytes=32 time<1ms TTL=63
Reply from xxx.167.218.118: bytes=32 time<1ms TTL=63
Reply from xxx.167.218.118: bytes=32 time<1ms TTL=63
Reply from xxx.167.218.118: bytes=32 time<1ms TTL=63

Ping statistics for xxx.167.218.118:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
Run Code Online (Sandbox Code Playgroud)

所以……我做错了什么?

解决的修复第一去除从eth1的节中的网关信息(如MikeyB建议的),然后删除用于从所述路由表作为这样的eth1的网络地址的路由:

sudo route del -net 192.168.99.0 netmask 255.255.255.0 dev eth1

Mik*_*eyB 4

几乎可以肯定,您不应该有两个默认网关。

尝试从 eth1 节中删除默认网关,看看是否有帮助。