Ubuntu 26 container does not apply DHCP search domain

TIL

Ubuntu 26 in Incus container does not apply the DHCP search domain by default. Search domain is also known as “DHCP Option 119”.

With Ubuntu 24 and earlier this was fine.

This is a regression that nobody seem to have noticed. Or everybody worked around it.

Let me show you the problem.

$ incus launch images:ubuntu/resolute/cloud u26 --network eno1
Launching u26
$ incus exec u26 -- hostname -f
u26
$ incus exec u26 -- hostname -A
u26.example.com

Next, get rid of that silly 127.0.1.1.

$ incus exec u26 -- sed -i '/127.0.1.1/d' /etc/hosts
$ incus exec u26 -- hostname -f
u26

Look at the resolvectl output

$ incus exec u26 -- resolvectl
Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub

Link 26 (eth0)
    Current Scopes: DNS
         Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 172.16.16.1
       DNS Servers: 172.16.16.1
     Default Route: yes

Hmm. There’s no domain search. But my DHCP does provide it.

Ubuntu Incus cloud containers use netplan. We can instruct netplan to apply DHCP domain search.

root@u26:~# hostname -f
u26
root@u26:~# vi /etc/netplan/50-cloud-init.yaml
root@u26:~# cat /etc/netplan/50-cloud-init.yaml
network:
  version: 2
  ethernets:
    eth0:
      dhcp4: true
      dhcp4-overrides:
        use-domains: true
root@u26:~# netplan apply
root@u26:~# hostname -f
u26.example.com

Hurray, we’ve got a FQDN now

resolvectl shows it too

$ incus exec u26 -- resolvectl
Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub

Link 26 (eth0)
    Current Scopes: DNS
         Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 172.16.16.1
       DNS Servers: 172.16.16.1
        DNS Domain: example.com
     Default Route: yes

For completeness, here is what you’ll see with Ubuntu 24. No need to change the netplan config.

$ incus launch images:ubuntu/noble/cloud u24 --network eno1
Launching u24
$ incus exec u24 -- sed -i '/127.0.1.1/d' /etc/hosts
$ incus exec u24 -- hostname -f
u24.example.com

BTW Incus debian cloud containers have the same problem.

Debian uses systemd-networkd, by default it ignores DHCP search domain too.

To solve that you’ll have to edit the .network file. Add a [DHCP] section with UseDomains. Here is an example of such a modified file.

[Match]
Name=eth0

[Network]
DHCP=ipv4

[DHCP]
UseDomains=true

After adding the UseDomains you can restart the service.

systemctl restart systemd-networkd

Thanks, good to know.