← Back to team overview

cloud-init team mailing list archive

Struggling to override DNS

 

Hi

I am really struggling to override the DNS settings provided by DHCP.

I have tried setting /etc/cloud/cloud.cfg as the below.  I have also just tried putting the "network:" stanza into /etc/cloud/cloud.config.d/01-net.cfg on its own.

Neither option works.  The provider's DHCP provided DNS keeps on showing when you check networkctl --status.

I am running the Debian provided cloud-init on Debian Bookworm.

My cloud.cfg:

# If this is set, 'root' will not be able to ssh in and they
# will get a message to login instead as the default $user
disable_root: true

# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: false

apt:
   # This prevents cloud-init from rewriting apt's sources.list file,
   # which has been a source of surprise.
   preserve_sources_list: true

# The modules that run in the 'init' stage
cloud_init_modules:
   - set_hostname
   - update_hostname
   - update_etc_hosts

# The modules that run in the 'config' stage
cloud_config_modules:
   - runcmd

# The modules that run in the 'final' stage
cloud_final_modules:
   - package-update-upgrade-install
   - write-files-deferred
   - power-state-change

# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
   # This will affect which distro class gets used
   distro: debian
   # Other config here will be given to the distro class and/or path classes
   paths:
      cloud_dir: /var/lib/cloud/
      templates_dir: /etc/cloud/templates/
   package_mirrors:
      - arches: [default]
        failsafe:
           primary: https://deb.debian.org/debian
           security: https://deb.debian.org/debian-security
   ssh_svcname: ssh
   network:
      version: 2
      ethernets:
         zz-match-all:
            match:
               name: "en*"
            dhcp4: true
            dhcp6: true
            dhcp4-overrides:
               use-ntp: false
               use-dns: false
            dhcp6-overrides:
               use-ntp: false
               use-dns: false
            nameservers:
               addresses: [9.9.9.9,149.112.112.112]
            renderer:
               - networkd