Ensure NetworkManager doesn't override /etc/resolv.conf

Until now, whenever NetworkManager gets reloaded/restarted/lease
refresh, it would override the /etc/resolv.conf file with the
nameservers and related it gets from the network.

This patch ensures this won't happen ever again.

Change-Id: I92bc12b8f712e28962d24dd6474cfce22b81222c
This commit is contained in:
Cédric Jeanneret 2022-11-23 15:11:44 +01:00
parent 020653d041
commit 368bb77ee3

View File

@ -159,6 +159,18 @@ set -e
echo 'nameserver 127.0.0.1' > /etc/resolv.conf
EOF
# Configure NetworkManager to not manage /etc/resolv.conf
if [ -d /etc/NetworkManager/conf.d ]; then
cat <<EOF |python3
import configparser
p = configparser.SafeConfigParser()
p.set('main', 'rc-manager', 'unmanaged')
with open('/etc/NetworkManager/conf.d/rc-manager.conf', 'w') as fh:
p.write(fh)
EOF
fi
# openSUSE doesn't have an iptables service, so apply the iptables rules at boot
if [[ "${DISTRO_NAME}" =~ (opensuse) ]] ; then
cat >>$rclocal <<EOF