Score:0

How to connect veth interfaces to bridge slave ports

id flag

This will probably be easier to explain with a diagram, so this is the basic setup:

There are 2 containers 10.0.0.1 & 10.0.0.2 running inside a host machine, and I've also created a linux bridge br0.

Each of the containers sees its own network interface as eth0, but the host machine sees it as vethxxxx. Looking at the picture in the basic setup, there is no connectivity between the containers.

What I can do easily is to add both veth interfaces into the bridge using brctl addif, and they will be able to communicate right away, but this is not exactly what I am looking to do.

What I want to do is to be able to have more granular control over the forwarding between the containers; to emulate a managed switch on br0 controlled by the host machine. If these were physical machines, I believe this could be done using nmcli with something like:

nmcli connection add type ethernet slave-type bridge con-name br0-port1 ifname <port name> master br0

and then connect the cables from the machines into the ports used in that command.

Is there a way to effectively achieve the same setup virtually (like in pic #3)?

Score:2
pt flag

You cannot "attach" a veth interface to a bridge port; you can make it a bridge port by adding it to a bridge.

A veth interface is effectively a virtual ethernet cable running between a pair of ports. The way you typically use them in the context of containers is that one end of the "cable" becomes eth0 inside the container, and the other end is added as a bridge port, so you end up with:

enter image description here

A linux bridge device does act like a managed switch in that you can configure vlans per port, control stp per port, etc.

A. Trevelyan avatar
id flag
Thanks, there was some visible confusion that u cleared up with this response.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.