[Azure] User's customized dns search domains is over-written as re-config network on every boot
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Description of problem:
This issue only exists on Azure cloud-init.
With the 22.1 version, we add dns search domains via nmcli con modify 'System eth0' +ipv4.dns-search domain.tld, after reboot, the config is over-written by cloud-init(the changes to /etc/sysconfig/
[1] https:/
But some users prefer to persist the customized network config(e.g. DNS) after reboot, so could you please help to check how to enhance this patch[1] to meet customer's requirement[2]?
[2] User's requirements:
We add additional search domains to certain servers, mostly because they communicate with legacy urls in our company without using fqdn.
Additional info:
Below[3] is a workaround to persist user's customized DNS. But as all the customized network configs will be over-written after reboot, so maybe we need to consider how to avoid it.
[3] Adding the customized DNS to /etc/dhcp/
e.g.
Modify /etc/dhcp/
timeout 300;
append domain-search "searchdomain1.
append domain-search "searchdomain2.
append domain-name-servers 1.1.1.1;
Reboot the VM and then check the dns information, the modifications are not overwritten.
# cat /etc/resolv.conf
# Generated by NetworkManager
search searchdomain1.com searchdomain2.com
nameserver 1.1.1.1
Test Veision: 22.1
How reproducible:
Modify dns search domains, reboot
Steps to Reproduce:
1. nmcli con modify 'System eth0' +ipv4.dns-search example.com
2. systemctl reboot
Actual results:
$ grep example.com /etc/resolv.conf
[No result]
Expected results:
$ grep example.com /etc/resolv.conf
search example.com
Re-applying networking every boot is the expected behavior. It worked this way in the past for Ubuntu but was inconsistently applied across distros. It is now consistent across distros, but it does represent a change in behavior for those that weren't on Ubuntu distros. Because of how Azure wants their instances initialized, this behavior can't be reverted upstream. However, there shouldn't have been an expectation of changes to these files persisting. At the top of /etc/sysconfig/ network- scripts/ ifcfg-eth0, it even says
"# Created by cloud-init on instance boot automatically, do not edit."
Without knowing your distro/networking tools, I can't know the best way to workaround the issue, but most tools should provide a way of manually specifying a search domain. For example, when using systemd-resolved, you should be able to add search domains to /etc/systemd/ resolved. conf or /etc/systemd/ resolved. conf.d/ . Beyond that, is there a problem with your [3] option you mentioned?