🚮 Truncate /etc/resolv.conf from kickstart

During the kickstart of the cloud image, NetworkManager writes an
/etc/resolv.conf that contains `nameserver 192.168.122.1`. This causes
boot delays with cloud-init since it does some early boot DNS
redirection tests before talking to the cloud's metadata service. On
some clouds/architectures, this delay is 15 seconds or more.

Truncate the /etc/resolv.conf so it can be replaced properly by
NetworkManager and cloud-init on the first boot.

Signed-off-by: Major Hayden <major@redhat.com>
This commit is contained in:
Major Hayden 2021-10-14 13:12:43 -05:00 committed by Neal Gompa
parent adf3ee6644
commit 32b03e0440

View File

@ -139,6 +139,11 @@ btrfs filesystem sync /
echo "Cleanup leftover networking configuration" echo "Cleanup leftover networking configuration"
rm -f /etc/NetworkManager/system-connections/*.nmconnection rm -f /etc/NetworkManager/system-connections/*.nmconnection
# Truncate the /etc/resolv.conf left over from NetworkManager during the
# kickstart. This causes delays in boot with cloud-init because the
# 192.168.122.1 DNS server cannot be reached.
truncate -s 0 /etc/resolv.conf
# Clear machine-id on pre generated images # Clear machine-id on pre generated images
truncate -s 0 /etc/machine-id truncate -s 0 /etc/machine-id