Q: The DNS server configured via cloud-init on CentOS 7.x does not take effect, even though cloud-init runs successfully. Why?
A: This issue may occur if the virtual machine template has three DNS servers already configured in the /etc/resolv.conf
file, which prevents the addition of any more. This is a common limitation in Linux distributions that use /etc/resolv.conf
for DNS configuration. cloud-init attempts to add a new DNS server to the existing list of servers in resolv.conf
rather than replacing them. According to the resolv.conf(5) manual, only three DNS servers are allowed in resolv.conf
. If the virtual machine template already contains three DNS servers configured in the /etc/resolv.conf
file, cloud-init will fail to add a new one. In this case, the /var/log/cloud-init.log
will record ignoring nameserver {dns_server}: adding would exceed the maximum of '3' name servers (see resolv.conf(5))
.
Q: The DNS configured via cloud-init for operating systems that use the eni network configuration tool (such as Debian OS) does not take effect, even though cloud-init runs successfully. Why?
A: This issue may occur because the virtual machine typically uses resolvconf.service
to configure DNS when configuring network via the eni network configuration tool. Some operating systems may not have this service installed, leading to DNS configuration failures. To resolve this, ensure that the resolvconf.service
is installed when creating the template and configured to autostart on boot.
Q: The static IP, router, and DNS configured via cloud-init for operating systems that use the Netplan network configuration tool (such as Kylin Desktop v10) does not take effect, even though cloud-init runs successfully. Why?
A: This issue may occur when the systemd-networkd
service is not set to autostart on boot, as it is essential for the virtual machine's Netplan network configuration tool to manage the network. Although the cloud-init service has written the expected configuration to the Netplan directory, the network configuration may fail for the systemd-networkd
service is not running. In this case, run the netplan apply
command to start the systemd-networkd
service and apply the relevant configuration. If the described cause is accurate, the network configuration should then be successfully restored. You can use the command systemctl enable systemd-networkd
when creating the cloud-init template to set the service to autostart on boot.
Q: The static IP network configured via cloud-init for operating systems that use the Netplan network configuration tool (such as Ubuntu 18.04 system) does not take effect, even though cloud-init runs successfully. Why?
A: This issue may occur when multiple configuration files exist in the /etc/netplan
directory, such as 01-network-manager-all.yaml
and 50-cloud-init.yaml
, which the system processes sequentially, causing potential conflicts to interfere with the application of network configuration.
For example, if the 01-network-manager-all.yaml
file specifies the DHCP configuration for the virtual NIC ens4, it may override or interfere with the configuration for ens4 in the 50-cloud-init.yaml
file. Additionally, if the 01-network-manager-all.yaml
file contains configurations for NICs that do not exist, it may also lead to network configuration failures, preventing the configurations in the 50-cloud-init.yaml
file from being applied.
To address this issue, it is recommended to back up the 01-network-manager-all.yaml
file and remove it from the /etc/netplan
directory, then recreate the cloud-init template for creating cloud-init virtual machines.
Q: The static IP address configured via cloud-init for operating systems that use the eni network configuration tool (such as Debian or Ubuntu 16.04) does not take effect, even though cloud-init runs successfully. Why?
A: This issue may occur when the /etc/network/interfaces
file is incorrectly configured.
Since cloud-init writes the network configuration info to the /etc/network/interfaces.d/50-cloud-init.cfg
file, if the /etc/network/interfaces
file is not configured correctly, the configurations in the 50-cloud-init.cfg
file will be rendered ineffective, as well as the static IP address.
Refer to the following requirements when configuring the /etc/network/interfaces
file.
Include source statements
The /etc/network/interfaces
file must include the following statements to ensure that configuration files in the /etc/network/interfaces.d/*
directory can be successfully loaded:
source /etc/network/interfaces.d/*
Avoid conflicts
The /etc/network/interfaces
file should not contain the same configurations as the NIC specified in the /etc/network/interfaces.d/50-cloud-init.cfg
file to prevent potential configuration conflicts.
Here's an example of a /etc/network/interfaces
file that meets the requirements, where only the loopback interface lo is configured:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
It is recommended to modify the configuration as described above to ensure that the network configurations in the 50-cloud-init.cfg
file are correctly loaded and taking effect.