From f838fcfe12144835177563b54e97c1b9d7cfa032 Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Sun, 3 Jun 2018 23:24:37 -0500 Subject: [PATCH] Fix IP parsing - Fix parsing private IP on some systems such as Ubuntu 18.04 --- vpnsetup.sh | 2 +- vpnsetup_centos.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vpnsetup.sh b/vpnsetup.sh index 9be9d09..38c617c 100755 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -287,7 +287,7 @@ conn xauth-psk EOF if ip -4 route list 0/0 2>/dev/null | grep -qs ' src '; then - PRIVATE_IP=$(ip -4 route get 1 | awk '{print $NF;exit}') + PRIVATE_IP=$(ip -4 route get 1 | sed 's/ uid .*//' | awk '{print $NF;exit}') check_ip "$PRIVATE_IP" && sed -i "s/left=%defaultroute/left=$PRIVATE_IP/" /etc/ipsec.conf fi diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index 713f090..aa28ec3 100755 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -272,7 +272,7 @@ conn xauth-psk EOF if ip -4 route list 0/0 2>/dev/null | grep -qs ' src '; then - PRIVATE_IP=$(ip -4 route get 1 | awk '{print $NF;exit}') + PRIVATE_IP=$(ip -4 route get 1 | sed 's/ uid .*//' | awk '{print $NF;exit}') check_ip "$PRIVATE_IP" && sed -i "s/left=%defaultroute/left=$PRIVATE_IP/" /etc/ipsec.conf fi