I followed these docs to make systemd-resolved aware of Incus builtin DNS server.
While it works great (I can ping instances with ping [instance].incus, I noticed that the configuration is not persistent and I always have to re-run systemctl restart incus-dns-incusbr0 when there are changes to the network, such as when my laptop comes back from sleep and wifi is re-estabilished.
I know this is probably not an Incus-specific question, but I’m unsure what to look for. Does anyone have a solution for making the Incus DNS configuration persistent on laptops running systemd?
Is there a way to re-run the unit whenever there’s a network change?
While the problem commonly appears when the laptop sleeps, network changes such as the wifi being disconnected or reconnected are the true cause.
For example, right now I’m connected to wifi after the laptop resumed from suspend. If I run resolvectl status incusbr0, this is the output:
$ resolvectl status incusbr0
Link 6 (incusbr0)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
And pinging an instance by incus DNS will result in Name or service not known. After running systemctl restart incus-dns-incusbr0.service, the problem is fixed:
$ resolvectl status incusbr0
Link 6 (incusbr0)
Current Scopes: DNS
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 10.79.179.1
DNS Servers: 10.79.179.1
DNS Domain: ~incus
But if I manually disconnect from wifi, the problem comes back.
I did a bit of research since I had some interest. It looks like you might be able to use the NetworkManger-dispatcher functionality.
The basic idea is to run a script when your WiFi connection reconnects. You might need to enable the systemd service for Networkmanger-dispatcher if it is not already enabled.
There might be another way by adding a few lines to the systemd service you already have. I am was not able to figure it out in the amount of time I spent on the task.
Good luck, and please update us with any progress.
@jarrodu BTW thanks for researching the network manager solution, but it ended up not working for me. It turns out that the issue was not Wifi shutdown, but some other event which I couldn’t identify and that caused the incus DNS to lose its configuration