Systemd-Networkd with Bonding

With systemd-networkd setup and running, now let's setup bonding.

Create virtual network device

First, we have to create a new virtual network device for our bond connection.

To do so, create a file at /etc/systemd/network/10-bond0.netdev with the following contents.

[NetDev]
Name=bond0
Kind=bond
Description="Link Aggregation"

[Bond]
Mode=active-backup
PrimaryReselectPolicy=always
MIIMonitorSec=1s
UpDelaySec=2s
DownDelaySec=2s

10-bond0.netdev

Here we are setting up bonding with active-backup mode. There are also other modes available.

Configure the bond

Next, create a file at /etc/systemd/network/10-bond0.network with the following configurations.

I'm setting it up with static IP and DNS here again, but you can use DHCP as well.

[Match]
Name=bond0

[Network]
Address=192.168.1.123/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4

10-bond0.network

Change adapter configurations

Now, we have to change our physical network interfaces to point to our newly-created bond interface.

Here I specified enp3s0 to be the primary slave.

[Match]
Name=enp3s0

[Network]
Bond=bond0
PrimarySlave=true

20-enp3s0.network

[Match]
Name=enp4s0

[Network]
Bond=bond0

30-enp4s0.network

Let's reboot and test our new bond interface!

reboot

networkctl

This gives me the following.

IDX LINK             TYPE               OPERATIONAL SETUP
  1 lo               loopback           carrier     unmanaged
  2 enp3s0           ether              carrier     configured
  3 enp4s0           ether              carrier     configuring
  4 bond1            ether              routable    configured

4 links listed.

Let's check the status of our bond interface.

cat /proc/net/bonding/bond0

Here's what I got:

Ethernet Channel Bonding Driver: v6.15.4-200.fc42.x86_64

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: enp3s0 (primary_reselect always)
Currently Active Slave: enp3s0
MII Status: up
MII Polling Interval (ms): 1000
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0

Slave Interface: enp3s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: ff:ff:ff:ff:ff:ff
Slave queue ID: 0

Slave Interface: enp4s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: ff:ff:ff:ff:ff:ff
Slave queue ID: 0

Here, we can see that our Bonding Mode is correctly set to active-backup.

We can also see that our Primary Slave is set to enp3s0 with primary_reselect set to always as expected.