Skip to content

Commit

Permalink
(Nyr#889) Adds Custom DNS Choice.
Browse files Browse the repository at this point in the history
  • Loading branch information
Retro64XYZ committed May 24, 2024
1 parent e4a9a31 commit 6785da1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions openvpn-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ if [[ ! -e /etc/openvpn/server/server.conf ]]; then
[[ -z "$ip_number" ]] && ip_number="1"
ip=$(ip -4 addr | grep inet | grep -vE '127(\.[0-9]{1,3}){3}' | cut -d '/' -f 1 | grep -oE '[0-9]{1,3}(\.[0-9]{1,3}){3}' | sed -n "$ip_number"p)
fi
# If $ip is a private IP address, the server must be behind NAT
# If $ip is a private IP address, the server must be behind NAT
if echo "$ip" | grep -qE '^(10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.|192\.168)'; then
echo
echo "This server is behind NAT. What is the public IPv4 address or hostname?"
Expand Down Expand Up @@ -190,11 +190,17 @@ if [[ ! -e /etc/openvpn/server/server.conf ]]; then
echo " 4) OpenDNS"
echo " 5) Quad9"
echo " 6) AdGuard"
echo " 7) Custom DNS"
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 your custom DNS server: " custom_dns
fi

echo
echo "Enter a name for the first client:"
read -p "Name [client]: " unsanitized_client
Expand Down Expand Up @@ -321,6 +327,9 @@ server 10.8.0.0 255.255.255.0" > /etc/openvpn/server/server.conf
echo 'push "dhcp-option DNS 94.140.14.14"' >> /etc/openvpn/server/server.conf
echo 'push "dhcp-option DNS 94.140.15.15"' >> /etc/openvpn/server/server.conf
;;
7)
echo "push \"dhcp-option DNS $custom_dns\"" >> /etc/openvpn/server/server.conf
;;
esac
echo 'push "block-outside-dns"' >> /etc/openvpn/server/server.conf
echo "keepalive 10 120
Expand Down

0 comments on commit 6785da1

Please sign in to comment.