Skip to content

Netplan

Commands

netplan status

Issue: Value search is empty in /etc/resolve.conf, but DHCP server provide it

systemd-netpland #cloud-init

State

Debian 12 /etc/resolve.conf managed systemd-resolved

# cat /etc/resolv.conf  | grep -vE '^#|^$'
nameserver 10.10.1.1
search .

Network config managed Netplan by: cloud-init -> netplan -> networkd

# cat /etc/netplan/50-cloud-init.yaml | grep -vE '^#|^&' 
network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
            match:
                macaddress: bc:24:11:07:c6:38
            set-name: eth0

DHCP server has option for search with value pve.loc, but on host this value is empty:

# grep Domains /etc/systemd/resolved.conf
#Domains=
# resolvectl domain
Global:
Link 2 (eth0):

Solution 1

Disable Netplan config management by cloud-init:

cat << EOF >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
network: {config: disabled}
EOF

Add dhcp4-overrides: values to /etc/netplan/50-cloud-init.yaml

network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
            match:
                macaddress: bc:24:11:07:c6:38
            set-name: eth0
            dhcp4-overrides:
                use-dns: true
                use-domains: true

Apply: - reboot - sudo neplan apply

Networkd will implement these changes to interface configuration:

# cat /run/systemd/network/10-netplan-eth0.network
[Match]
PermanentMACAddress=bc:24:11:07:c6:38
Name=eth0

[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6

[DHCP]
RouteMetric=100
UseMTU=true
UseDomains=true

Result :

# cat /etc/resolv.conf  | grep -vE '^#|^$'
nameserver 10.10.1.1
search pve.loc

# resolvectl domain
Global: pve.loc
Link 2 (eth0):