From 55c2ebded69405886d4b5d064833d97f8abd6ee4 Mon Sep 17 00:00:00 2001 From: Davi Torres <73488542+davift@users.noreply.github.com> Date: Mon, 16 Sep 2024 19:39:41 -0400 Subject: [PATCH] Added capability to set custom DNS server --- openvpn-install.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 1abcb8e..b27b6dc 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -190,10 +190,23 @@ if [[ ! -e /etc/openvpn/server/server.conf ]]; then echo " 5) Quad9" echo " 6) AdGuard" read -p "DNS server [1]: " dns - until [[ -z "$dns" || "$dns" =~ ^[1-6]$ ]]; do + until [[ -z "$dns" || "$dns" =~ ^[1-7]$ ]]; do echo "$dns: invalid selection." read -p "DNS server [1]: " dns done + if [[ "$dns" == 7 ]]; then + read -p "Enter custom DNS server 1: " dns_custom_1 + until [[ "$dns_custom_1" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; do + echo "$dns_custom_1: invalid DNS server." + read -p "Enter custom DNS server 1: " dns_custom_1 + done + read -p "Enter custom DNS server 2: " dns_custom_2 + until [[ "$dns_custom_2" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; do + echo "$dns_custom_2: invalid DNS server." + read -p "Enter custom DNS server 2: " dns_custom_2 + done + fi + case "$dns" in 1|"") resolver='the current system resolvers'