Linux 桥接不转发数据包

Ale*_*oux 10 linux hyper-v gentoo bridge

我正在尝试使用 2 个以太网接口设置 Linux 网桥,但无法使其正常工作。我正在使用 Gentoo Linux 并认为这会很容易,但我最终无法让数据包通过网桥。在 Hyper-V 下虚拟化的所有内容对任何事情都很重要(但我对此表示怀疑)。

这是我的配置。

 ------              ------------------           --------         -----------
| NUX3 |------------|eth1  BRIDGE  eth0|---------| ROUTER |-------/ INTERNET /
 ------              ------------------           --------        -----------
192.168.1.195/24    192.168.1.197/24 (br0)     192.168.1.101/24
00:15:5d:00:01:12   00:15:5d:00:01:08 (eth0)   00:15:5d:00:01:03
                    00:15:5d:00:01:13 (eth1)       
Run Code Online (Sandbox Code Playgroud)

# cat /etc/conf.d/net

bridge_br0=( "eth0 eth1" )
config_eth0=( "null" )
config_eth1=( "null" )
config_br0=( "192.168.1.197 netmask 255.255.255.0 brd 192.168.1.255" )
routes_br0=( "default via 192.168.1.101" )
Run Code Online (Sandbox Code Playgroud)

# brctl 显示

bridge name      bridge id              STP enabled      interfaces
br0              8000.00155d000108      no               eth0
                                                         eth1
Run Code Online (Sandbox Code Playgroud)

# brctl showstp br0

<...>
eth0 (1)               state               forwarding
eth1 (2)               state               forwarding
<...>
Run Code Online (Sandbox Code Playgroud)

# cat /etc/sysctl.conf

net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-arptables = 0
net.bridge.bridge-nf-call-iptables = 0
Run Code Online (Sandbox Code Playgroud)

# ifconfig

<...>
br0    UP BROADCAST RUNNING MULTICAST
       inet addr:192.168.1.197  Bcast:192.168.1.255  Mask:255.255.255.0
<...>
eth0    UP BROADCAST RUNNING PROMISC MULTICAST
<...>
eth1    UP BROADCAST RUNNING PROMISC MULTICAST
<...>
Run Code Online (Sandbox Code Playgroud)

# brctl showmacs br0

port no mac addr                    is local?        ageing timer
  1     00:15:5d:00:01:03           no                   1.51
  1     00:15:5d:00:01:08           yes                  0.00
  2     00:15:5d:00:01:12           no                  36.22
  2     00:15:5d:00:01:13           yes                  0.00
Run Code Online (Sandbox Code Playgroud)

BRIDGE 可以 ping 通 ROUTER 但不能 ping NUX3,NUX3 不能 ping BRIDGE 和 ROUTER。对我来说一切都很好,但我显然错过了一些东西。如果有人能指点我,我真的很高兴!

谢谢。

小智 9

主机上的底层网络设备可能没有启用混杂模式。例如,在 VMWare 中,如果底层虚拟网络适配器不是 +promisc,那么访客桥接器将惨遭失败——即使它认为自己能够进入混杂模式,但它不能。

我没用过HyperV,但是逻辑应该是一样的,如果主机不允许guest进入混杂模式,网桥就不能来回传递数据包,因为网卡只会处理被寻址的帧专门给它。

如果您禁用网桥,您就可以 ping NUX3 和路由器,对吗?


小智 7

在 hyper-v 管理器中,转到要在其上使用网桥的 vm 的设置,并在要用作网桥一部分的每个网络接口下启用“允许 mac 地址欺骗”复选框。我使用的是 Windows Server 2008r2 SP1。这就是我为让它工作而做的。我也在使用预装了所有 Hyper-V 驱动程序的 Ubuntu 12.04,但我认为这并不重要。


小智 5

桥接工作正常。

  1. 之前说需要开启MAC地址欺骗
  2. 在最新的内核中,iptables 也为桥接器规定了实际值。所以它必须配置或禁用。要禁用网桥的 iptables 规则,请执行: sysctl net.bridge.bridge-nf-call-iptables=0

  • OMG 在 KVM 下设置 EVE NG 嵌套虚拟化时遇到问题,无法通过桥接网络 ping 我的网关...但是在 eve 中使用此命令我能够 ping 网关.. vert 非常感谢您发布 sysctl net.bridge .bridge-nf-call-iptables=0 (2认同)