I was playing around with vagrant-libvirt and wanted to bridge my virtual machines to my LAN so that they get a DHCP lease and are reachable from the network. Since vagrant-libvirt does apparently not create bridges for you, I created one:

brctl addbr br0

and added enp10s0 to it:

brctl addif br0 enp10s0

and learned an important lesson in linux networking:

Note: Adding an interface to a bridge will cause the interface to lose its existing IP address. If you're connected remotely via the interface you intend to add to the bridge, you will lose your connection. This problem can be worked around by scripting the bridge to be created at system startup.

I can understand that it loses its address because the kernel might be reinitializing the interface, but why does it not recover? There is a dhcp server on enp10s0's network, so I naively expected it would come back (I am used to work with Hyper-V's virtual switches, where you can create and delete them without cutting your connection to the host).

Is it because I assigned no ip address to the bridge before attachking enp10s0? Or because the bridge is not up yet? Or both?

  • under the hood: once an interface becomes a bridge port, it's barred from participating in layer 3 (routing). Only the implicit self port of the bridge (ie here br0) can now do routing. If I had actual references from where I know this I'd post it as an answer, but I don't.
    – A.B
    Sep 29 '19 at 13:15
  • Thanks for shedding some light! So if I would have upped the bridge (e.g. ip link set dev br0 up) before attaching enp10s0 it would have worked? I'd love to upvote your comment, but I don't have enough rep yet.
    – Benni
    Sep 30 '19 at 9:21

I don't know why bridge-utils has this known limitation that is biting you. Although some may prefer the familiar brctl tool, at least in your case I'd suggest trying the newer iproute2 tools documented in the same Arch wiki page you linked to. In your case:

ip link add name br0 type bridge
ip link set br0 up
ip link set enp10s0 up
ip link set enp10s0 master br0

I don't have deeper knowledge, but believe at least some of the iproute2 tools use newer kernel interfaces than older tools like bridge-utils. If the above works for you where brctl fails, I'd suspect that is the reason.

  • No, just my incompetence - but I'd like to understand what is going on under the hood.
    – Benni
    Sep 28 '19 at 9:00
  • @Benni: I wouldn't call it incompetence to choose one set of tools over another. AFAIK many people prefer the more traditional brctl tools to the sometimes-confusing ip tools' syntax. The ip tools are newer and I think at least some of them make use of newer kernel APIs to do their work. I don't have insight deeper than that as to why using brctl results in the problem you encountered.
    – fmyhr
    Sep 28 '19 at 10:24
  • 1
    Using iproute2 also seems to release the IP of the underlying interface.
    – timss
    May 27 '20 at 15:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.