From 8d84eebd79fc8e5b0dcc78761fbc46e7fa7ac1ca Mon Sep 17 00:00:00 2001 From: Mohammad Parvin Date: Thu, 20 Oct 2022 23:37:03 +0300 Subject: [PATCH] add an option to use two option for detect public IP --- openvpn-install.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index c418d29..96cd8bc 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -227,8 +227,14 @@ function installQuestions() { echo "I need to know the IPv4 address of the network interface you want OpenVPN listening to." echo "Unless your server is behind NAT, it should be your public IPv4 address." - # Detect public IPv4 address and pre-fill for the user - IP=$(ip -4 addr | sed -ne 's|^.* inet \([^/]*\)/.* scope global.*$|\1|p' | head -1) + # If detect_from_net is not set detect the IP from the network + # Else use this command to detect ip: curl -s https://api.ipify.org + if [[ -z $DETECT_FROM_NET ]]; then + # Detect public IPv4 address and pre-fill for the user + IP=$(ip -4 addr | sed -ne 's|^.* inet \([^/]*\)/.* scope global.*$|\1|p' | head -1) + else + IP=$(curl -s https://api.ipify.org) + fi if [[ -z $IP ]]; then # Detect public IPv6 address