[Why] We have added some nameservers to /etc/resolv.conf of rootfs, but this file will be overwritten when NetworkManager service starts.
[How] Add config option `dns=none` to /etc/NetworkManager/NetworkManager.conf.
[Reference] dns in NetworkManager.conf Set the DNS (resolv.conf) processing mode. default: The default if the key is not specified. NetworkManager will update resolv.conf to reflect the nameservers provided by currently active connections. dnsmasq: NetworkManager will run dnsmasq as a local caching nameserver, using a "split DNS" configuration if you are connected to a VPN, and then update resolv.conf to point to the local nameserver. none: NetworkManager will not modify resolv.conf.
Signed-off-by: Yu Chuan 13186087857@163.com --- tests/iso2rootfs | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/tests/iso2rootfs b/tests/iso2rootfs index cb077fa28b0f..cde1d12e4cd3 100755 --- a/tests/iso2rootfs +++ b/tests/iso2rootfs @@ -358,6 +358,9 @@ run_qcow2rootfs() config_dns_resolver() { echo "${config_rootfs}" | grep -qw 'dns' || return 0 + + grep "^dns=none" $config_file || sed -i '/^[main]/adns=none' "${ROOTFS_DES_DIR}/etc/NetworkManager/NetworkManager.conf" + cat <<-EOF > "${ROOTFS_DES_DIR}/etc/resolv.conf" nameserver 114.114.114.114 nameserver 8.8.8.8