Cloud-init based guest customization fails to set DNS settings on Debian 10.x/11.x/12.x/13.x
search cancel

Cloud-init based guest customization fails to set DNS settings on Debian 10.x/11.x/12.x/13.x

book

Article ID: 422988

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • Setting DNS settings fails for cloud-init based guest customization on Debian 10.x/11.x/12.x/13.x. Refer How does vSphere Guest OS Customization work with cloud-init to customize a Linux VM for more details about the guest customization.
  • This issue is observed on both DHCP and STATIC IP customization when using cloud-init as the engine.
  • Customization task still succeeds but DNS settings (server and search domain) are set in guest network configuration incorrectly.
  • No error in customization log and cloud-init log.
  • This issue does NOT happen when using Perl based customization.

Environment

  • vCenter Server 7.x
  • vCenter Server 8.x
  • vCenter 9.x

Cause

Cloud-init fails to correctly set dns settings(server and search domain) for Debian 10.x/11.x/12.x/13.x, more details in the cloud-init bug Network: Fail to set DNS server and search domain on Debian12.

Resolution

This is a known issue with cloud-init and currently there is no resolution.

Workaround

  1. Enable running customization script by following the steps in Setting the customization script for virtual machines in vSphere 7.x and 8.x.
  2. Include the below customization script in customization specification and replace DNS_SEARCH_DOMAIN/PRIMARY_DNS_SERVER/SECONDARY_DNS_SERVER with the expected dns settings.

    #!/bin/sh
    if [ x$1 = x"postcustomization" ]; then
        cat <<EOF > /etc/resolv.conf
    search DNS_SEARCH_DOMAIN
    nameserver PRIMARY_DNS_SERVER
    nameserver SECONDARY_DNS_SERVER
    EOF
        echo "Updated /etc/resolv.conf" > /root/post_customization.log
    fi

  3. The above customization script will be executed and set dns settings correctly during cloud-init based guest customization.