From e3fe8b05bf79e973542b4c7e3d6292745b433d21 Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Mon, 21 May 2018 00:58:24 -0500 Subject: [PATCH] Improve workaround - Specify "left=" in ipsec.conf for servers with 'src' in default route - Ref: https://github.com/libreswan/libreswan/issues/177 --- vpnsetup.sh | 3 +-- vpnsetup_centos.sh | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vpnsetup.sh b/vpnsetup.sh index 2e00b2f..576f361 100755 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -281,8 +281,7 @@ conn xauth-psk also=shared EOF -# Workaround for Raspberry Pi -if uname -m | grep -qi '^arm'; then +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}') 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 23d8a3a..1923142 100755 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -262,6 +262,11 @@ conn xauth-psk also=shared 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}') + check_ip "$PRIVATE_IP" && sed -i "s/left=%defaultroute/left=$PRIVATE_IP/" /etc/ipsec.conf +fi + # Specify IPsec PSK conf_bk "/etc/ipsec.secrets" cat > /etc/ipsec.secrets <