cloud-init and UseDomains=yes

Feb 18, 2019
1
0
1
1. Setup

  • I use the PROXMOX 6 (proxmox-ve: 6.1-2)
  • I set up a DNS server with dnsmasq
  • dnsmasq is configured to send search-domains
  • The VM is running Arch Linux
  • Within the VM systemd-networkd and systemd-resolved are used
  • I use "cloud-init" 19.3 with netplan 0.98-1

2. Problem

There are no search domains configured in "/etc/resolv.conf" although "dnsmasq" sends them to the VM.

Code:
# [...]
nameserver 10.0.0.2

3. Logs

Extract from dnsmasq logs: This shows the options transferred from dnsmasq to the dhcp client (VM). I replaced all "internal" IP-addresses.

Code:
option: 53 message-type  5
option: 54 server-identifier  10.0.0.3
option: 51 lease-time  12h
option: 58 T1  6h
option: 59 T2  10h30m
option:  1 netmask  255.255.255.0
option: 28 broadcast  10.0.0.255
option: 12 hostname  server1
option: 42 ntp-server  213.239.239.166
option: 15 domain-name  in.exmple.com
option:119 domain-search  xxxxx
option:  6 dns-server  10.0.0.2
option:  3 router  10.0.0.1

4. Configs

The configuration of resolved looks like this:

Code:
resolvectl status

Code:
Link 2 (eth0)
      Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
DefaultRoute setting: yes
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: allow-downgrade
    DNSSEC supported: yes
  Current DNS Server: 10.0.0.2
         DNS Servers: 10.0.0.2

The network cloud-init configuration for the vm contains this:

Code:
$ sudo qm cloudinit dump 1 network

Code:
version: 1
config:
    - type: physical
      name: eth0
      mac_address: 'xxxxx'
      subnets:
      - type: dhcp4
      - type: dhcp6
    - type: nameserver
      address:
      - '10.0.0.2'
      search:
      - 'in.example.com'

This is the data netplan got via DHCP:

Code:
% sudo netplan ip leases eth0

Code:
# This is private data. Do not parse.
ADDRESS=10.0.0.3
NETMASK=255.255.255.0
ROUTER=10.0.0.1
SERVER_ADDRESS=10.0.0.2
NEXT_SERVER=10.0.0.2
BROADCAST=10.0.0.255
T1=21600
T2=37800
LIFETIME=43200
DNS=10.0.0.2
NTP=213.239.239.166
DOMAINNAME=in.example.com
DOMAIN_SEARCH_LIST=in.example.com
HOSTNAME=server1
CLIENTID=xxxxxx


The generated .network-file for networkd looks like this:

Code:
% cat /run/systemd/network/10-netplan-*.network

Code:
[Match]
MACAddress=xxxxxxx
Name=eth0

[Network]
DHCP=yes
LinkLocalAddressing=ipv6

[DHCP]
RouteMetric=100
UseMTU=true

5. Findings

If I modify the .network file manually and restart networkd + resolved, the /etc/resolv.conf contains the configured domains.

Code:
% cat /run/systemd/network/10-netplan-*.network

Code:
[Match]
MACAddress=xxxxxxx
Name=eth0

[Network]
##### MODIFICATION: BEGIN #########
UseDomains=yes
##### MODIFICATION: END #########
DHCP=yes
LinkLocalAddressing=ipv6

[DHCP]
RouteMetric=100
UseMTU=true

6. Question

What do I need to do to make proxmox/cloud-init/netplan generate the "correct" .network file?
 
option: 15 domain-name in.exmple.com
I assume this is a typo.

The network cloud-init configuration for the vm contains this:
There is no need to configure a cloud-init network, if a DHCP server pushes those to the VM anyway.

UseDomains=yes
Sadly this is the only thing that needs to be set beforehand. This doesn't seem to be done by cloud-init. Maybe you can use the runcmd [0] for this. You will need to try with a custom could-init config [1].

Another thing, might be that LLMNR [2] gets in the way.

[0] https://cloudinit.readthedocs.io/en/latest/topics/modules.html#runcmd
[1] https://pve.proxmox.com/pve-docs/pve-admin-guide.html#_deploying_cloud_init_templates
[2] https://wiki.archlinux.org/index.php/Systemd-networkd#systemd-resolve_not_searching_the_local_domain
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!