Skip to content

Commit 71929ca

Browse files
committed
Do not remove upstream DNS configuraton in cleanup
This PR changes the logic of host cleanup so that the upstream DNS configuration is not removed. This comes from the fact that by default dev-scripts configure NetworkManager to use dnsmasq with DHCP-provided DNS servers and removes the existing /etc/resolv.conf configuration. This causes problems in environments configured without DHCP with DNS servers configured manually without use of the NetworkManager. With this PR user can use `ADDN_DNS` variable to provide their own DNS servers that will be passed to the dnsmasq. At the same time when removing dev-scripts from the system, the backup of the original /etc/resolv.conf will be restored so that the initial system configuration is reverted.
1 parent e1dee2f commit 71929ca

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

host_cleanup.sh

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ if systemctl is-active --quiet NetworkManager; then
4040
else
4141
sudo systemctl restart NetworkManager
4242
fi
43+
mv /etc/resolv.conf.dev-scripts.backup /etc/resolv.conf
4344

4445
# There was a bug in this file, it may need to be recreated.
4546
# delete the interface as it can cause issues when not rebooting

utils.sh

+3
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ function write_pull_secret() {
587587
}
588588
589589
function switch_to_internal_dns() {
590+
# Create backup of the current resolv.conf in case user is using a manual configuration. This
591+
# file will be used in host_cleanup to revert the initial DNS configuration of the host.
592+
cp /etc/resolv.conf /etc/resolv.conf.dev-scripts.backup
590593
sudo mkdir -p /etc/NetworkManager/conf.d/
591594
ansible localhost -b -m ini_file -a "path=/etc/NetworkManager/conf.d/dnsmasq.conf section=main option=dns value=dnsmasq"
592595
if [ "$ADDN_DNS" ] ; then

0 commit comments

Comments
 (0)