Integration with systemd-resolved inside a vm


I have a Ubuntu Jammy Desktop vm, installed with

lxc launch images:ubuntu/jammy/desktop

in which I’m running an LXD server. I want to integrate with systemd-resolved but for some reason the DNS queries do not work

ubuntu@u1:~$ lxc network set lxdbr0 dns.domain ''
ubuntu@u1:~$ lxc network get lxdbr0 dns.domain
ubuntu@u1:~$ lxc network get lxdbr0 ipv4.address
ubuntu@u1:~$ sudo resolvectl domain lxdbr0 ''
ubuntu@u1:~$ sudo resolvectl dns lxdbr0
ubuntu@u1:~$ sudo resolvectl status lxdbr0 
Link 3 (lxdbr0)
    Current Scopes: DNS
         Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server:
       DNS Servers:
        DNS Domain:
ubuntu@u1:~$ lxc ls --project prj-nc-env -f compact
   NAME     STATE           IPV4           IPV6    TYPE     SNAPSHOTS  
  nc-test  RUNNING (eth0)        CONTAINER  0
ubuntu@u1:~$ host
;; communications error to timed out
Host not found: 5(REFUSED) 

How can I troubleshoot the issue?

It seems that removing the ~ solves the issue:

ubuntu@u1:~$ lxc network set lxdbr0 dns.domain ''
ubuntu@u1:~$ resolvectl domain lxdbr0 ''

Not sure then whether the documentation is correct?

I cannot see in the documentation where it suggests to lxc network set lxdbr0 dns.domain to the domain with a tilde prefix?

Certainly that is incorrect, and should be fixed if in the docs, but I cannot see that.

Only the resolvectl domain lxdbr0 '~lxd' should have the tilde added.

Sorry my bad I made a confusion between:

resolvectl domain lxdbr0 ''


lxc network set lxdbr0 dns.domain ''

Maybe to make things clearer I’d put after:

If this option is not set, the default domain name is lxd.

the following sentence:

To set a domain you can use the following instruction:

lxc network set lxdbr0 dns.domain <domain_name>

and move the following block out of the indentation

When specifying the DNS domain, prefix the domain name with ~. The ~ tells resolved to use the respective name server to look up only this domain.

Depending on which shell you use, you might need to include the DNS domain in quotes to prevent the ~ from being expanded.

What do you think @ru-fu ^

The page is about configuring resolved, not about how to configure the network bridge. So we assume that the DNS domain is already configured - adding lxc network set lxdbr0 dns.domain <domain_name> doesn’t belong in here.

I created a PR though to make it clearer that the tilde is needed only when configuring resolved, and that the returned value (and therefore also the value you would configure for dns.domain) does not contain the tilde.

1 Like