diff --git a/wireguard-install.sh b/wireguard-install.sh index 97db97a..fbc5719 100644 --- a/wireguard-install.sh +++ b/wireguard-install.sh @@ -110,13 +110,13 @@ new_client_dns () { 1|"") # Locate the proper resolv.conf # Needed for systems running systemd-resolved - if grep -q "127.0.0.53" "/etc/resolv.conf"; then + if grep -q '^nameserver 127.0.0.53' "/etc/resolv.conf"; then resolv_conf="/run/systemd/resolve/resolv.conf" else resolv_conf="/etc/resolv.conf" fi # Extract nameservers and provide them in the required format - dns=$(grep -v '#' "$resolv_conf" | grep nameserver | grep -E -o '[0-9]{1,3}(\.[0-9]{1,3}){3}' | xargs | sed -e 's/ /, /g') + dns=$(grep -v '^#\|^;' "$resolv_conf" | grep '^nameserver' | grep -oE '[0-9]{1,3}(\.[0-9]{1,3}){3}' | xargs | sed -e 's/ /, /g') ;; 2) dns="8.8.8.8, 8.8.4.4"