cloud-init icon indicating copy to clipboard operation
cloud-init copied to clipboard

Network: Fail to set DNS server and search domain on Debian12

Open PengpengSun opened this issue 2 years ago • 4 comments

Bug report

Fail to set DNS server and search domain on Debian12

Steps to reproduce the problem

This issue happens on both DHCP and STATIC IP customization on Debian 12 when using cloud-init as engine.

With DHCP IP and DNS settings, the same issue was reported on Ubuntu 18.04 at https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1776452, later Ubuntu moved to Netplan which doesn't have this issue any more. But for Debian, it's still using eni as networking configuration, so this issue still reproduces on Debian.

With STATIC IP and DNS settings, cloud-init sets DNS server and search domain in /etc/network/interface.d/50-cloud-init file which doesn't take effect.

Environment details

  • Cloud-init version: 22.4.2
  • Operating System Distribution: Debian 12.0
  • Cloud provider, platform or installer type: VMware vSphere

cloud-init logs

cloud-init.tar.gz

Tracked by VMware internal bug 3234146

PengpengSun avatar Jul 17 '23 07:07 PengpengSun

Thank you for filing the bug @PengpengSun can you attach your /etc/network/interfaces.d/50-cloud-init files that cloud-init wrote here please?

From your logs I grabbed network config and did the following on my system. I get the following ENI config which looks to add the dns search and nameservers onto the loopback interface. Is this what you are seeing?

cat > mynet <<EOF
{'version': 1, 'config': [{'type': 'physical', 'name': 'ens33', 'mac_address': '00:50:56:be:ba:f4', 'subnets': [{'control': 'auto', 'type': 'static', 'address': '10.161.125.224', 'netmask': '255.255.224.0', 'gateway': '10.161.127.253'}]}, {'type': 'nameserver', 'address': ['11.22.33.1', '11.22.33.2'], 'search': ['pp.com', 'pp.net']}]}
EOF
PYTHONPATH=. python3 -m cloudinit.cmd.main devel net-convert -k yaml -D debian -O eni  -p mynet -d test-issue-4255 -O eni

cat test-issue-4255/etc/network/interfaces.d/50-cloud-init 
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback
    dns-nameservers 11.22.33.1 11.22.33.2
    dns-search pp.com pp.net

auto ens33
iface ens33 inet static
    address 10.161.125.224/19
    gateway 10.161.127.253

blackboxsw avatar Jul 19 '23 03:07 blackboxsw

Thanks @blackboxsw Yes, I'm seeing the same in 50-cloud-init.txt

PengpengSun avatar Jul 19 '23 03:07 PengpengSun

I can reproduce this using Proxmox, and it's painful.

I think it happens because there already is a lo definition on /etc/network/interfaces, and it happens after source /etc/network/interfaces.d/*, thus overwriting it. removing the lo definition, or setting the source stanza after the base lo definition fixes it.

So, probably not directly a cloud-init bug…  Or maybe it should have the dns options set on actual interfaces rather than lo, or do some verifications about /etc/network/interfaces anyway..

gilou avatar Dec 02 '24 07:12 gilou

Or maybe resolvconf should allow for more than one lo definitions, not sure what are ifupdown / resolvconf stances on that..

gilou avatar Dec 02 '24 07:12 gilou