canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.99k stars 882 forks source link

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

Open PengpengSun opened 1 year ago

PengpengSun commented 1 year ago

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 logs

cloud-init.tar.gz

Tracked by VMware internal bug 3234146

blackboxsw commented 1 year ago

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
PengpengSun commented 1 year ago

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