bond0/从属 eth* 接口没有默认网关路由获得分配的 IP

bond0/从属 eth* 接口没有默认网关路由获得分配的 IP

我在我的 Debian Wheezy 盒子上设置了 4-NIC 绑定。全新启动后,系统可以访问 LAN,但无法解析外部主机名或访问外部 IP。这似乎是因为 bond0 接口没有获取默认网关路由,而是从属接口之一(通常是 eth3)获取了它。

route -n启动后的结果:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.2.1     0.0.0.0         UG    0      0        0 eth3
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth3
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 bond0
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 eth3

我眼前的网络问题可以通过执行以下操作来缓解route add default gw 192.168.2.1 bond0:但当我可能没有物理访问权限时,我至少需要计算机在重新启动后获得外部网络访问权限。

所谓的从属接口每次都会获得自己的 IP 地址。我怀疑这可能是问题的根源。这里发生了什么?的结果ifconfig,注意eth3:

bond0     Link encap:Ethernet  HWaddr bc:5f:f4:be:4a:cc
          inet addr:192.168.2.3  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::be5f:f4ff:febe:4acc/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:522992 errors:0 dropped:4871 overruns:0 frame:0
          TX packets:885760 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:53459302 (50.9 MiB)  TX bytes:736701670 (702.5 MiB)

eth0      Link encap:Ethernet  HWaddr bc:5f:f4:be:4a:cc
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:85101 errors:0 dropped:5 overruns:0 frame:0
          TX packets:412890 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:8568619 (8.1 MiB)  TX bytes:37311255 (35.5 MiB)
          Memory:f7400000-f7480000

eth1      Link encap:Ethernet  HWaddr bc:5f:f4:be:4a:cc
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:1285 errors:0 dropped:12 overruns:0 frame:0
          TX packets:75 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:185579 (181.2 KiB)  TX bytes:16930 (16.5 KiB)
          Memory:f7300000-f7380000

eth2      Link encap:Ethernet  HWaddr bc:5f:f4:be:4a:cc
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:2039 errors:0 dropped:11 overruns:0 frame:0
          TX packets:472583 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:326122 (318.4 KiB)  TX bytes:699347095 (666.9 MiB)
          Memory:f7200000-f7280000

eth3      Link encap:Ethernet  HWaddr bc:5f:f4:be:4a:cc
          inet addr:192.168.2.135  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:434565 errors:0 dropped:410 overruns:0 frame:0
          TX packets:210 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:44378800 (42.3 MiB)  TX bytes:26282 (25.6 KiB)
          Memory:f7100000-f7180000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:78 errors:0 dropped:0 overruns:0 frame:0
          TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:9310 (9.0 KiB)  TX bytes:9310 (9.0 KiB)

就像/etc/network/interfaces这样:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
bond-master bond0
bond-mode 4

auto eth1
iface eth1 inet manual
bond-master bond0
bond-mode 4

auto eth2
iface eth2 inet manual
bond-master bond0
bond-mode 4

auto eth3
iface eth3 inet manual
bond-master bond0
bond-mode 4

auto bond0
iface bond0 inet static
address 192.168.2.3
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1
slaves eth0 eth1 eth2 eth3
bond-slaves none
bond-mode 4
bond-miimon 100
bond-downdelay 200
bond-updelay 200

我在交换机上尝试了多种端口组合,每次都得到大致相同的结果(有时接口与 eth3 不同)。升级主板后确实出现了这个问题;在旧主板上,我有一个 2-NIC 绑定,效果很好。 (在现有的 Wheezy 安装上升级硬件是否存在任何可能的问题?)升级后,我删除了旧文件/etc/udev/rules.d/70-persistent-net.rules,并让它重新生成,因此该文件现在包含:

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:1c.2/0000:07:00.0 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="bc:5f:f4:be:4a:cc", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:1c.4/0000:09:00.0 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="bc:5f:f4:be:4a:bd", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:1c.3/0000:08:00.0 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="bc:5f:f4:be:4a:ce", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:1c.5/0000:0a:00.0 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="bc:5f:f4:be:4a:bf", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

最后一件事,我确实尝试将以下内容添加到我的/etc/network/interfaces文件中,希望得到一种“解决方法”解决方案。

auto bond0
...
post-up route add default gw 192.168.2.1 bond0
pre-down route del default gw 192.168.2.1 bond0

这似乎没有什么区别,并且启动后,路由表中没有 bond0 的默认 GW 路由(与上面完全相同)。我很想知道我在那里做错了什么,并至少将其用作临时解决方案。

答案1

好吧,这让我得到了简单的答案:update-rc.d network-manager disable然后重新启动。我根本不知道 NetworkManager 还在运行,但它确实在运行,而且它正在分配 IP。

答案2

我发现刷新 eth* IP 地址有帮助,就像这篇文章中一样: https://ubuntuforums.org/showthread.php?t=2315062

IEsudo ip addr flush dev ethX

可能需要找到一个在系统重新启动后仍然存在的解决方案

答案3

输入以下命令:

route add default gw 192.168.2.1 bond0 

进入/etc/rc.local

相关内容