NM resolve prepender: support appending a nameserver for systemd-resolved
FCOS 33 doesn't use NM to manage resolv.conf. Instead it uses systemd-resolved.
The script should not replace /etc/resolv.conf in this case, but instead create a dropin for systemd-resolved
@@ -52,14 +52,21 @@ contents:
"{{ onPremPlatformIngressIP . }}")
DOMAIN="{{.DNS.Spec.BaseDomain}}"
if [[ -n "$NAMESERVER_IP" ]]; then
+ source /etc/os-release
+ if [[ "$NAME" == "Fedora" ]]; then
+ echo "[Resolve]" > /etc/systemd/resolved.conf.d/60-kni.conf
+ echo "DNS=$NAMESERVER_IP" >> /etc/systemd/resolved.conf.d/60-kni.conf
+ echo "Domains=$DOMAIN" >> /etc/systemd/resolved.conf.d/60-kni.conf
+ else
>&2 echo "NM resolv-prepender: Prepending 'nameserver $NAMESERVER_IP' to /etc/resolv.conf (other nameservers from /var/run/NetworkManager/resolv.conf)"
sed -e "/^search/d" \
-e "/Generated by/c# Generated by KNI resolv prepender NM dispatcher script\nsearch $DOMAIN\nnameserver $NAMESERVER_IP" \
/var/run/NetworkManager/resolv.conf > /etc/resolv.tmp
- fi
# Only leave the first 3 nameservers in /etc/resolv.conf
sed -i ':a $!{N; ba}; s/\(^\|\n\)nameserver/\n# nameserver/4g' /etc/resolv.tmp
mv -f /etc/resolv.tmp /etc/resolv.conf
+ fi
+ fi
;;
*)
;;
