Skip to content

Instantly share code, notes, and snippets.

@bay-systems
Created July 27, 2024 22:37
Show Gist options
  • Save bay-systems/418ec3ff96fc598ba3cd49e379cd8e4b to your computer and use it in GitHub Desktop.
Save bay-systems/418ec3ff96fc598ba3cd49e379cd8e4b to your computer and use it in GitHub Desktop.
Create a network bridge interface with systemd-networkd

Create a bridge interface with systemd-networkd

  • bridge will be named br0

Find the network device:

ip -l
# 2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...

Create the files:

/etc/systemd/network/bind.network

[Match]
Name=enp0s31f6

[Network]
Bridge=br0

/etc/systemd/network/br0.netdev

[NetDev]
Name=br0
Kind=bridge

/etc/systemd/network/br0.network

  • this example assigns a static ipv6 address and a dynamic ipv6 address, which assumes there is a DHCPv6 server on the network
  • use DNS server addresses from your network provider or others like 1.1.1.1 or 8.8.8.8 (there are others)
[Match]
Name = br0

[Network]
Address = 192.168.0.10/24
Gateway = 192.168.0.1
DNS = 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001
DHCP = ipv6

Switch to systemd-networkd and systemd-resolved

  • NetworkManager can coexist with systemd-networkd (for example to manage wifi connections)
  • but should remove other network managers like ifupdown, netplan, connman
# run these commands as superuser
apt install systemd-resolved
systemctl enable systemd-networkd
systemctl enable systemd-resolved
chown root:systemd-network /etc/systemd/network/*
# remove existing network manager like ifupdown, connman, netplan.io, etc.
apt purge ifupdown
systemctl start systemd-networkd
systemctl start systemd-resolved
cd /etc/
ln -sf ../run/systemd/resolve/resolv.conf .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment