> I just think about the file in /etc/cloud/cloud.cfd.d/network_xx.cfg, we can ask users disable network in the file, but that maybe cause other issues, e.g. can not set new network configs automatic via cloud-init.
How about adding users' manually network config to the file /etc/cloud/cloud.cfd.d/network_xx.cfg?
Both of these options probably won't work in a cloud environment as the cloud is providing network information that cloud-init needs to know to setup networking correctly. It could be possible to do that after first boot, but as you say, any networking changes from the cloud would likely leave the instance in an unreachable state.
> And there are indeed some workarounds to persist the specific DNS manually config, option[3] is also works, but is this recommended workaround for customers in this scenario?
It depends on the tooling available to your machine, but yes, this is one of the persistent ways to make such a change, at least until dhclient is no longer supported. The other way is to use the systemd-resolved configuration file if it being used in your configuration.
Do either of these cloud-configs work for you?
Using systemd-resolved:
#cloud-config
write_files:
- path: /etc/systemd/resolved.conf.d/dns_servers.conf
content: |
[Resolve]
DNS=1.1.1.1
Domains=example.com
owner: root:root
permissions: '0o644'
encoding: text/plain
append: false
defer: false
> I just think about the file in /etc/cloud/ cloud.cfd. d/network_ xx.cfg, we can ask users disable network in the file, but that maybe cause other issues, e.g. can not set new network configs automatic via cloud-init. cloud.cfd. d/network_ xx.cfg?
How about adding users' manually network config to the file /etc/cloud/
Both of these options probably won't work in a cloud environment as the cloud is providing network information that cloud-init needs to know to setup networking correctly. It could be possible to do that after first boot, but as you say, any networking changes from the cloud would likely leave the instance in an unreachable state.
> And there are indeed some workarounds to persist the specific DNS manually config, option[3] is also works, but is this recommended workaround for customers in this scenario?
It depends on the tooling available to your machine, but yes, this is one of the persistent ways to make such a change, at least until dhclient is no longer supported. The other way is to use the systemd-resolved configuration file if it being used in your configuration.
Do either of these cloud-configs work for you? resolved. conf.d/ dns_servers. conf example. com
Using systemd-resolved:
#cloud-config
write_files:
- path: /etc/systemd/
content: |
[Resolve]
DNS=1.1.1.1
Domains=
owner: root:root
permissions: '0o644'
encoding: text/plain
append: false
defer: false
Using dhclient: dhclient. conf
#cloud-config
write_files:
- path: /etc/dhcp/
content: |
append domain-search "example.com";
append domain-name-servers 1.1.1.1;
owner: root:root
encoding: text/plain
append: true
defer: false