1

I am trying to bridge two interfaces in a linux VM on a Mac but adding the second interface to the bridge breaks everything. I'm hoping to get some guidance on what I'm doing wrong.

Setup:

  • Network ------ MacOS / eth0:VirtualBoxLinux:eth1 ---- raspberry pi
  • The linux VM is a fresh install of a debian-9-based distro in VirtualBox 6.0 on MacOS 10.14.3.
  • MacOS is connected to the network via Wifi
  • VirtualBox exposes a bridged network interface to the VM as eth0
  • An Apple USB Ethernet adapter is plugged into the VM, exposed as eth1
  • A raspberry pi is plugged into the usb adapter to test things out.

The goal is to have the raspberry pi sit directly on the main network by bridging eth0 and eth1.

If I bring up eth0 and give it an IP from within the VM, the linux VM can happily talk to the network.

If I create a bridge with just eth0 in it and give the bridge an IP, the linux VM can still talk to the network.

if I then add eth1 to the bridge, the linux VM can not talk to the network anymore. At this point the raspberry can get an IP via DHCP but can't seem to be talking to the network either.

If I remove eth1 from the bridge, the linux VM's network connectivity is back.

Edit: even though I have STP disabled on the bridge, I waited a while after setting up br0 to see if things would work better. The fact that "brctl showstp" shows Forwarding on both eth0 and eth1, and that the raspberry is somehow able to get an IP via DHCP means there is at least something more or less going through.

Details:

Starting config: interfaces up, no IP assigned:

root@cbpp:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 08:00:27:06:fd:0a  txqueuelen 1000  (Ethernet)
        RX packets 6325015  bytes 7231844627 (6.7 GiB)
        RX errors 0  dropped 75  overruns 0  frame 0
        TX packets 1129  bytes 84075 (82.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 04:69:f8:eb:c8:1a  txqueuelen 1000  (Ethernet)
        RX packets 100  bytes 9369 (9.1 KiB)
        RX errors 1  dropped 0  overruns 0  frame 0
        TX packets 39002  bytes 5454636 (5.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Create the bridge, add eth0, get an IP via DHCP, ping a host:

root@cbpp:~# brctl addbr br0
root@cbpp:~# brctl addif br0 eth0
root@cbpp:~# brctl show
bridge name bridge id       STP enabled interfaces
br0     8000.08002706fd0a   no      eth0
root@cbpp:~# ifconfig br0 up
root@cbpp:~# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 08:00:27:06:fd:0a  txqueuelen 1000  (Ethernet)
        RX packets 161  bytes 16286 (15.9 KiB)
        RX errors 0  dropped 4  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 08:00:27:06:fd:0a  txqueuelen 1000  (Ethernet)
        RX packets 6352292  bytes 7256149955 (6.7 GiB)
        RX errors 0  dropped 76  overruns 0  frame 0
        TX packets 1129  bytes 84075 (82.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 04:69:f8:eb:c8:1a  txqueuelen 1000  (Ethernet)
        RX packets 106  bytes 9645 (9.4 KiB)
        RX errors 1  dropped 0  overruns 0  frame 0
        TX packets 39002  bytes 5454636 (5.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@cbpp:~# dhclient br0 -v
Internet Systems Consortium DHCP Client 4.3.5
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/br0/08:00:27:06:fd:0a
Sending on   LPF/br0/08:00:27:06:fd:0a
Sending on   Socket/fallback
DHCPREQUEST of 192.168.28.236 on br0 to 255.255.255.255 port 67
DHCPACK of 192.168.28.236 from 192.168.28.1
bound to 192.168.28.236 -- renewal in 3046 seconds.

root@cbpp:~# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.28.236  netmask 255.255.255.0  broadcast 192.168.28.255
        ether 08:00:27:06:fd:0a  txqueuelen 1000  (Ethernet)
        RX packets 869  bytes 100262 (97.9 KiB)
        RX errors 0  dropped 11  overruns 0  frame 0
        TX packets 45  bytes 4656 (4.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 08:00:27:06:fd:0a  txqueuelen 1000  (Ethernet)
        RX packets 6400166  bytes 7294827072 (6.7 GiB)
        RX errors 0  dropped 77  overruns 0  frame 0
        TX packets 1174  bytes 88761 (86.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 04:69:f8:eb:c8:1a  txqueuelen 1000  (Ethernet)
        RX packets 112  bytes 9921 (9.6 KiB)
        RX errors 1  dropped 0  overruns 0  frame 0
        TX packets 39002  bytes 5454636 (5.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


root@cbpp:~# ping -c 1 192.168.28.1
PING 192.168.28.1 (192.168.28.1) 56(84) bytes of data.
64 bytes from 192.168.28.1: icmp_seq=1 ttl=64 time=1.21 ms

--- 192.168.28.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.213/1.213/1.213/0.000 ms

Add eth1 to the bridge, see connectivity fail. Note: at this point, the raspberry is able to get an IP on its eth0 via DHCP but nothing seem to go through past that point either.

root@cbpp:~# brctl addif br0 eth1
root@cbpp:~# ping -c 1 192.168.28.1
PING 192.168.28.1 (192.168.28.1) 56(84) bytes of data.
From 192.168.28.236 icmp_seq=1 Destination Host Unreachable

--- 192.168.28.1 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

Config details at this point (bridge set up with eth0/eth1 but not working):

root@cbpp:~# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.28.236  netmask 255.255.255.0  broadcast 192.168.28.255
        ether 04:69:f8:eb:c8:1a  txqueuelen 1000  (Ethernet)
        RX packets 5755  bytes 668798 (653.1 KiB)
        RX errors 0  dropped 11  overruns 0  frame 0
        TX packets 82  bytes 9698 (9.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 08:00:27:06:fd:0a  txqueuelen 1000  (Ethernet)
        RX packets 6590263  bytes 7428675506 (6.9 GiB)
        RX errors 0  dropped 83  overruns 0  frame 0
        TX packets 1217  bytes 94469 (92.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 04:69:f8:eb:c8:1a  txqueuelen 1000  (Ethernet)
        RX packets 148  bytes 11577 (11.3 KiB)
        RX errors 1  dropped 0  overruns 0  frame 0
        TX packets 40112  bytes 5608073 (5.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@cbpp:~# brctl show
bridge name bridge id       STP enabled interfaces
br0     8000.0469f8ebc81a   no      eth0
                            eth1

root@cbpp:~# brctl showstp br0
br0
 bridge id      8000.0469f8ebc81a
 designated root    8000.0469f8ebc81a
 root port         0            path cost          0
 max age          20.00         bridge max age        20.00
 hello time        2.00         bridge hello time      2.00
 forward delay        15.00         bridge forward delay      15.00
 ageing time         300.00
 hello timer           0.00         tcn timer          0.00
 topology change timer     0.00         gc timer          73.23
 flags


eth0 (1)
 port id        8001            state            forwarding
 designated root    8000.0469f8ebc81a   path cost          4
 designated bridge  8000.0469f8ebc81a   message age timer      0.00
 designated port    8001            forward delay timer    0.00
 designated cost       0            hold timer         0.00
 flags

eth1 (2)
 port id        8002            state            forwarding
 designated root    8000.0469f8ebc81a   path cost         19
 designated bridge  8000.0469f8ebc81a   message age timer      0.00
 designated port    8002            forward delay timer    0.00
 designated cost       0            hold timer         0.00
 flags

root@cbpp:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

root@cbpp:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.28.1    0.0.0.0         UG    0      0        0 br0
192.168.28.0    0.0.0.0         255.255.255.0   U     0      0        0 br0

Remove eth1 from bridge, connectivity is restored:

root@cbpp:~# brctl delif br0 eth1
root@cbpp:~# ping -c 1 192.168.28.1
PING 192.168.28.1 (192.168.28.1) 56(84) bytes of data.
64 bytes from 192.168.28.1: icmp_seq=1 ttl=64 time=2.50 ms

--- 192.168.28.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.504/2.504/2.504/0.000 ms
root@cbpp:~#

Thanks!

  • 1
    Afaik the STP logic of a bridge interface typically needs at least 30 seconds to digest a change to the network. So give it a minute before verifying that there is a problem. – Ralph Rönnquist Feb 26 at 2:22
  • @Ralph thanks, I had waited quite a while to make sure this wasn't a timing thing (even though STP not enabled on the bridge). I edited the question to reflect that. – vmallet Feb 26 at 2:43
  • Guess: Whatever virtualbox does to emulate "bridged networking" together with the ethernet card emulation breaks down in your configuration. To debug this, I'd run tcpdump -ni iface_name on all three interfaces in three windows/terminal sessions inside the VM, and a fourth on the Mac for the Virtualbox interface. Compare the working situation to the non-working situation, and you should at least be able to narrow down the reason. – dirkt Feb 26 at 7:23
  • Maybe something gets confused by br0 changing its MAC address from the eth0 MAC to the eth1 MAC? – Ralph Rönnquist Feb 26 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.