From 33452242a1a8e2955eb1b0416c9d614062792843 Mon Sep 17 00:00:00 2001 From: Nyr Date: Sun, 21 Jan 2018 18:21:53 +0100 Subject: [PATCH] Fix system resolvers option for environments running systemd-resolved --- openvpn-install.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 0b87c65..ee420ca 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -272,8 +272,15 @@ ifconfig-pool-persist ipp.txt" > /etc/openvpn/server.conf # DNS case $DNS in 1) + # Locate the proper resolv.conf + # Needed for systems running systemd-resolved + if grep -q "127.0.0.53" "/etc/resolv.conf"; then + RESOLVCONF='/run/systemd/resolve/resolv.conf' + else + RESOLVCONF='/etc/resolv.conf' + fi # Obtain the resolvers from resolv.conf and use them for OpenVPN - grep -v '#' /etc/resolv.conf | grep 'nameserver' | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | while read line; do + grep -v '#' $RESOLVCONF | grep 'nameserver' | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | while read line; do echo "push \"dhcp-option DNS $line\"" >> /etc/openvpn/server.conf done ;;