27 May 2016

djwong: (Default)
Miscellaneous notes from converting Ubuntu 16.04 from NetworkManager/resolveconf to systemd-{networkd,resolved}.

In 14.04, system had the following /etc/network/interfaces:

auto br0
iface br0 inet dhcp
bridge_ports be0


and the following /etc/udev/rules/70-net-persistent.rules:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="XX:XX:XX:XX:XX:XX", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="be0"

But now that we've upgraded to 16.04, we have choices: stay with the old ifupdown, or migrate to NM or systemd-networkd. ifupdown still works just fine, though it may go away some day, doesn't have a convenient UI, etc. So let's try NetworkManager, which has a convenient CLI:

# nmcli con add type con-name br0 ifname br0
# nmcli con modify br0 bridge.stp no
# nmcli con modify br0 ipv6.addr-gen-mode stable-privacy
# nmcli con add type
# nmcli con add type bridge-slave con-name enp1s0f0 ifname enp1s0f0 master br0
# nmcli con up enp1s0f0


Unfortunately, it kills dhclient when tearing down the bridge prior to going to sleep and never restarts it after resume. The end result is that when the IPv4 lease expires there's nothing to renew the DHCP and IPv4 stops working an hour or so after resume.

So maybe let's try networkd. First, we set up the NIC in /etc/systemd/network/enp1s0f0.network:

[Match]
Name=enp1s0f0

[Network]
Bridge=br0


Next, we establish a bridge device in /etc/systemd/network/br0.netdev:

[NetDev]
Name=br0
Kind=bridge
MACAddress=XX:XX:XX:XX:XX:XX


Note that we're cloning the NIC's MAC address to the bridge for convenience. Finally, we need to actually configure the bridge (/etc/systemd/network/br0.network):

[Match]
Name=br0

[Network]
DHCP=ipv4

[DHCP]
UseDomains=true


This sets up the bridge to request IPv4 information via DHCP, and to use the domain provided by the server as a default search domain. Next, we disable NM and resolvconf in favor of the systemd replacements:

# systemctl stop NetworkManager
# systemctl disable NetworkManager
# systemctl stop resolvconf
# systemctl disable resolvconf
# systemctl enable systemd-networkd
# systemctl start systemd-networkd
# systemctl enable systemd-resolved
# systemctl start systemd-resolved
# ln -sf ../run/systemd/resolve/resolv.conf /etc/resolv.conf


Reboot for changes to take effect.

Profile

djwong: (Default)
Bogus J. Simpson

May 2016

S M T W T F S
1234567
891011121314
15161718192021
2223242526 2728
293031    

Style Credit

Expand Cut Tags

No cut tags
Page generated 21 May 2025 08:09
Powered by Dreamwidth Studios