Nameserver configuration for PVE cluster and VMs

Jun 1, 2023
33
12
8
We have two nameservers in our company, both reachable via ip or name. Today I did some work on this nameservers and I have to restart them serval times and there were longer downtimes, but one of both servers was always available. Allthough I thought this setup with both nameserver is redundant and I had no problems with this setup before some problems came up :-(.

On our PVE clusters both nameservers are stored in /etc/resolv.conf. If the second nameserver is ofline all is fine, but if the first nameserver in the list is not available nameresolution on the cluster was problematic somehow. It did work after querying the first server timet out, but some things ran in timeouts, e.g. replication jobs. We use systemd resolver on our VMs and there it is no problem if one of the nameservers is away and now I wonder if I could install and configure systemd resolver also on our PVE cluster nodes. Has anyone done this and how does it work? Will it cause problems e.g. when updating the cluster? Are there any other things I could do to make sure that namerelolution will work better if the first nameserver in resolv.conf is not reachable?

Another question is related to the configuration of our virtual machines. In each config file stored in /etc/pve/qemu there is a nameserver setting, e.g.:

nameserver: 10.10.10.2

Where and when is this setting used? I know that this nameserver is used after cloning a templating and start the VM the first time, but is it also used if dhcp addresses are used for a VM? Normaly the procedure setting up new VMs is the following for us:

#1 Clone a new VM from a template.
#2 Set a fixed ip address for the new VM and do other stuff related to the VM config.
#3 Start the VM the first time. At this point the nameserver from the VM config is used.
#4 Use cloud-init to perform the initial VM configuration. At this point cloud-init fails, e.g. when packages are retrived, if the nameserver is not reachable.
#5 Reboot the VM.
#6 Do the rest of the configuration via ansible. Here I configure both nameservers and systemd resolver.

The problem is #4. We use no cloud-init network configuration, but would it make sense to have such a config to give the VMs ip settings and configure also both nameservers?

Is it possible to configure a list of nameservers in the VMs config file or can only one nameserver be configured there?

How do you handle your nameserver setup? What are best practices regarding nameresolution for PVE clusters and the VMs running on such clusters? Is the best solution using a loadballancer in front of our different nameservers and configure the loadballancers ip address on our systems instead using different nameserver ip addresses?
 
In each config file stored in /etc/pve/qemu
That directory does not exist.
there is a nameserver setting,
Of more than a hundred <vmid>.conf files in my homelab exactly one has such an entry. It is a remnant of an experiment with "Cloud-Init" - so that's the term to search for in your environment...
 
That directory does not exist.

Sorry, that was a typo. But I am sure you mean what directory I was talking about...

Of more than a hundred <vmid>.conf files in my homelab exactly one has such an entry. It is a remnant of an experiment with "Cloud-Init" - so that's the term to search for in your environment...

How do your hundrets of VMs get their ip address? dhcp or do you use static ips?

With dhcp I do not need the nameserver setting, but I will test what happens if I use static ips for my VMs and if nameserver is not given.
 
How do your hundrets of VMs get their ip address? dhcp or do you use static ips?
(( Just-for-the-record: more than one hundred. Not multiple hundreds. :-) ))

My rule of thumb:
  1. critical servers need a static configuration as I do not like a dependency of another service
  2. most of the other machines get their IP address (and gateway and nameserver) via DHCP by a static assignment. I want to make sure "service-x" tomorrow gets the same address as yesterday
  3. a few other systems get dynamic addresses
There are multiple strategies to handle IP address management. My approach is to do it "old school" and it is not the most lightweight one...