Skip to content

Commit

Permalink
improve route storing reliability (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
eshork authored May 14, 2024
1 parent 417e7bf commit e7aa920
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion root/defaults/route-killswitch
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [[ $OVPN_KILLSWITCH == "true" || $OVPN_KILLSWITCH == "1" ]]; then
DEFAULT_GATEWAY_ORIG="/etc/openvpn/default_gateway.orig"
if [[ ! -f ${DEFAULT_GATEWAY_ORIG} ]]; then
echo "[OVPN_KILLSWITCH] Storing original default gateway within: ${DEFAULT_GATEWAY_ORIG}"
route | grep default | awk '{print $2}' > ${DEFAULT_GATEWAY_ORIG}
route -n | grep ^0.0.0.0 | grep -v tun | awk '{print $2}' > ${DEFAULT_GATEWAY_ORIG}
fi

echo "[OVPN_KILLSWITCH] Route-based killswitch enabled: dropping current default route & seeding remote VPN hosts"
Expand Down
6 changes: 3 additions & 3 deletions root/etc/s6-overlay/s6-rc.d/svc-mod-universal-openvpn/run
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ else
# this is placed here because we only want to do this once, when the container starts and the routes are fresh (ovpn won't mess with routes it didn't create)
if [[ $OVPN_SPLIT_PRIVATE == "true" || $OVPN_SPLIT_PRIVATE == "1" ]]; then
echo "OVPN_SPLIT_PRIVATE enabled: preserving default gateway for private network addresses"
route add -net 192.168.0.0/16 gw $( route | grep default | awk '{print $2}' )
route add -net 10.0.0.0/8 gw $( route | grep default | awk '{print $2}' )
route add -net 172.16.0.0/12 gw $( route | grep default | awk '{print $2}' )
route add -net 192.168.0.0/16 gw $( route -n | grep ^0.0.0.0 | grep -v tun | awk '{print $2}' )
route add -net 10.0.0.0/8 gw $( route -n | grep ^0.0.0.0 | grep -v tun | awk '{print $2}' )
route add -net 172.16.0.0/12 gw $( route -n | grep ^0.0.0.0 | grep -v tun | awk '{print $2}' )
fi

if [[ $OVPN_KILLSWITCH == "true" || $OVPN_KILLSWITCH == "1" ]]; then
Expand Down

0 comments on commit e7aa920

Please sign in to comment.