Q: When I was configuring the DNS server on CentOS 7.x, cloud-init was in its normal operation. But why didn't the DNS take effect?
A: This issue may occur if the virtual machine template has three DNS servers already configured in the /etc/resolv.conf
file and does not allow adding more DNS servers, which is typical for Linux distributions that use /etc/resolv.conf
for DNS configuration. The cause is that cloud-init implements its DNS server configuration by adding the new server to the existing ones in resolv.conf
rather than replacing them. According to the resolv.conf(5) manual page, there can only be up to three DNS servers inresolv.conf
. Therefore, if the virtual machine template already has three DNS servers configured in the /etc/resolv.conf
file, attempting to add a new server via cloud-init will fail, and the system will export the log ignoring nameserver {dns_server}: adding would exceed the maximum of '3' name servers (see resolv.conf(5))
in /var/log/cloud-init.log
accordingly.
Q:When I was configuring the DNS via cloud-init on Ubuntu 18.04 or later versions, I didn't select "Configure network via cloud-init" and cloud-init was in its normal operation. Why didn't the DNS take effect?
A: Starting from version 18.04, Ubuntu introduced the netplan
component for network management, which configures a DNS server for each network interface individually. Although AVE's ConfigDrive
format is compatible with most networking components, if "Configure network via cloud-init" is not selected, the data provided by ConfigDrive will not match the format required by cloud-init's netplan. As a result, the DNS configuration will not take effect.