Systemd-resolved integration does not work with NetworkManager

As I preferred this over Multipass I’ve been using LXD/LXC on my PC for quite a long time. For some technical issues after an upgrade I had to completely reinstall my Ubuntu 24.04 Desktop.

I also installed LXD/LXC as a snap package. It’s currently Version 5.21.4 LTS. I created a container as usual and so far everything is ok. Because I need DNS resolution in my workflows I configured resolved as described in this documentation: https://documentation.ubuntu.com/lxd/stable-5.21/howto/network_bridge_resolved/

Unfortunately this doesn’t provide a persistent configuration as it did in the past.

This is my /etc/systemd/network/lxdbr0.network:
[Match]
Name=lxdbr0
[Network]
Address=10.160.121.1/24
DNS=10.160.121.1
Domains=~lxd

$ lxc network show lxdbr0
name: lxdbr0
description: ""
type: bridge
managed: true
status: Created
config:
  ipv4.address: 10.160.121.1/24
  ipv4.nat: "true"
  ipv6.address: fd42:33cc:c803:150c::1/64
  ipv6.nat: "true"
used_by:
- /1.0/instances/opensim
- /1.0/profiles/default
locations:
- none
project: default

I’m not sure I used this resolved setup in the past, but this what I did several times on servers and it always worked (and still does on a external server and a VPS I own).

The difference to my other systems is that on my PC I have NetworkManager. Is there anything I’ve forgotten to achieve a persistent setup using this configuration.

As a workaround, since the manually added commands worked, I created the following file:
/etc/NetworkManager/dispatcher.d/99-lxdbr0-dns:

#!/bin/sh
INTERFACE=$1
ACTION=$2

if [ "$INTERFACE" = "lxdbr0" ] && [ "$ACTION" = "up" ]; then
    # Wait two seconds for LXD to initializing the bridge
    sleep 2
    /usr/bin/resolvectl dns lxdbr0 10.160.121.1
    /usr/bin/resolvectl domain lxdbr0 "~lxd"
fi

Please let me know, if there is a better option, because for further reference I like much more to follow official documentation.

Does it work for some time and then stops?

I just tested the lxdbr0.network approach documented here and it works for me.

Have you followed the steps in here? The easiest/safest might be to just reboot.

If that still doesn’t work, please share the output of resolvectl status.

2 Likes

Thank you for answering. Yes, I followed this approach, but have obviousely overlooked an error message.

The reason it did not work at all was that systemd-networkd was disabled. After I run the following command, everything worked as expected after a reboot.

systemctl enable systemd-networkd
2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.