diff --git a/ipsec/env.sh b/ipsec/env.sh index e1d2e84..05eb34a 100755 --- a/ipsec/env.sh +++ b/ipsec/env.sh @@ -14,3 +14,8 @@ LOCALIP="$LOCALPREFIX.0.0" LOCALMASK="/24" LOCALIPMASK="$LOCALIP$LOCALMASK" + +IP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1) +if [[ "$IP" = "" ]]; then + IP=$(wget -4qO- "http://whatismyip.akamai.com/") +fi diff --git a/ipsec/iptables-setup.sh b/ipsec/iptables-setup.sh index 76a700a..2902860 100755 --- a/ipsec/iptables-setup.sh +++ b/ipsec/iptables-setup.sh @@ -12,11 +12,6 @@ if [[ ! -e $IPTABLES ]] || [[ ! -r $IPTABLES ]] || [[ ! -w $IPTABLES ]]; then exit 1 fi -IP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1) -if [[ "$IP" = "" ]]; then - IP=$(wget -4qO- "http://whatismyip.akamai.com/") -fi - # backup and remove rules with $LOCALIP iptables-save > $IPTABLES.backup diff --git a/pptp/env.sh b/pptp/env.sh index e3c8a85..86ed6fb 100755 --- a/pptp/env.sh +++ b/pptp/env.sh @@ -12,3 +12,8 @@ LOCALIP="$LOCALPREFIX.0.0" LOCALMASK="/24" LOCALIPMASK="$LOCALIP$LOCALMASK" + +IP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1) +if [[ "$IP" = "" ]]; then + IP=$(wget -4qO- "http://whatismyip.akamai.com/") +fi diff --git a/pptp/iptables-setup.sh b/pptp/iptables-setup.sh index abc9be8..8ad51a7 100755 --- a/pptp/iptables-setup.sh +++ b/pptp/iptables-setup.sh @@ -12,11 +12,6 @@ if [[ ! -e $IPTABLES ]] || [[ ! -r $IPTABLES ]] || [[ ! -w $IPTABLES ]]; then exit 1 fi -IP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1) -if [[ "$IP" = "" ]]; then - IP=$(wget -4qO- "http://whatismyip.akamai.com/") -fi - # backup and remove rules with $LOCALIP iptables-save > $IPTABLES.backup