1

I want to peer connect between two bridges in my netplan configuration.

Under iproute2 the commands would be:

ip link add dev vethb1 type veth peer name vethb2       
brctl addif br1 vethb1
brctl addif br2 vethb2

I'm porting from OpenVSwitch, so it's possible I'm thinking about this the wrong way.

Unfortunately, the netplan documentation doesn't seem to cover all device types, particularly veth. Although it does mention veth in terms of matching, so there's some part of netplan that must know what it means.

I've tried doing a vlan with no id but it expects an id.

Creating an ethernet doesn't seem to accept a type or peer attribute. Networkd calls this kind but that isn't an accepted key either.

What does a veth peer link look like in a netplan config?

2 Answers 2

7

@slangasek is correct. As of 0.39 there is no support in the netplan yaml. However, netplan is based on systemd-networkd and plays nicely with it. So here's the solution I came up with:

Create a file called /etc/systemd/network/25-veth-b1b2.netdev with the contents:

[NetDev]
Name=vethb1
Kind=veth
[Peer]
Name=vethb2

Then add to your /etc/netplan/01-netcfg.yaml

Under:

ethernets:

Add:

    vethb1: {}
    vethb2: {}

What this does is tells netplan to expect interfaces from somewhere called vethb1 and vethb2. ({} is an empty match. match: {} works also, but leaving it blank or just match: causes a parsing error.)

Then you can add those interfaces to your bridge:

bridges:
  b1:
    interfaces: [vethb1]
  b2:
    interfaces: [vethb2]

Then rebuild your netplan config and restart systemd-networkd:

$ netplan generate
$ service systemd-networkd stop
$ service systemd-networkd start
1
  • Works great, cheers! Would like to mention that atleast for Netplan 0.99 on Ubuntu 20.04 you do not need to explicitly restart systemd-networkd, a regular netplan apply does the job. In case one wants to change the MTU of the VETH pair that should also be done in the Netplan config, but I had to remove any match: {} definitions otherwise I get the error "No valid settings found in the [Match] section, ignoring file" from systemd-networkd.
    – timss
    Nov 10, 2021 at 14:26
1
+50

As of netplan 0.39, there is no support for configuring veth devices through netplan yaml. This is currently under consideration for implementation in a future release.

2
  • Is there a way I can get the functionality? Perhaps by creating a networkd.netdev file? Jul 17, 2018 at 5:30
  • Yes, veth is supported directly in systemd-networkd as described in systemd.netdev(5).
    – slangasek
    Jul 19, 2018 at 14:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .