From e7fef8d5126f31ac2d006d95380e860e0a8babd8 Mon Sep 17 00:00:00 2001 From: iBeech Date: Fri, 15 Jan 2021 17:26:54 +0000 Subject: [PATCH 1/2] Added support for multiple subnets to be passed to the LAN_NETWORK variable Allow the LAN_NETWORK to accept multiple subnets. This can be done using a comma-separated list. e.g. 192.168.3.0/24,192.168.4.0/24 --- startup.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/startup.sh b/startup.sh index 6696d9d..4bf7095 100644 --- a/startup.sh +++ b/startup.sh @@ -9,9 +9,17 @@ printf "${SURFSHARK_USER}\n${SURFSHARK_PASSWORD}" > vpn-auth.txt if [ -n ${LAN_NETWORK} ] then - DEFAULT_GATEWAY=$(ip -4 route list 0/0 | cut -d ' ' -f 3) - ip route add "${LAN_NETWORK}" via "${DEFAULT_GATEWAY}" dev eth0 - echo Adding ip route add "${LAN_NETWORK}" via "${DEFAULT_GATEWAY}" dev eth0 for attached container web ui access + splitSubnets=$(echo ${LAN_NETWORK} | tr "," "\n") + + for subnet in $splitSubnets + do + echo "[$subnet]" + + DEFAULT_GATEWAY=$(ip -4 route list 0/0 | cut -d ' ' -f 3) + ip route add "$subnet" via "${DEFAULT_GATEWAY}" dev eth0 + echo Adding ip route add "$subnet" via "${DEFAULT_GATEWAY}" dev eth0 for attached container web ui access + done + echo Do not forget to expose the ports for attached container we ui access fi openvpn --config $VPN_FILE --auth-user-pass vpn-auth.txt --mute-replay-warnings $OPENVPN_OPTS From a639e0d140ba700f61b1f17b11ae8feaba9b5eec Mon Sep 17 00:00:00 2001 From: iBeech Date: Fri, 15 Jan 2021 17:29:41 +0000 Subject: [PATCH 2/2] Update startup.sh --- startup.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/startup.sh b/startup.sh index 4bf7095..e7743c7 100644 --- a/startup.sh +++ b/startup.sh @@ -9,13 +9,12 @@ printf "${SURFSHARK_USER}\n${SURFSHARK_PASSWORD}" > vpn-auth.txt if [ -n ${LAN_NETWORK} ] then + DEFAULT_GATEWAY=$(ip -4 route list 0/0 | cut -d ' ' -f 3) + splitSubnets=$(echo ${LAN_NETWORK} | tr "," "\n") for subnet in $splitSubnets - do - echo "[$subnet]" - - DEFAULT_GATEWAY=$(ip -4 route list 0/0 | cut -d ' ' -f 3) + do ip route add "$subnet" via "${DEFAULT_GATEWAY}" dev eth0 echo Adding ip route add "$subnet" via "${DEFAULT_GATEWAY}" dev eth0 for attached container web ui access done