diff --git a/entrypoint.sh b/entrypoint.sh index 7e8548e..08d5bd5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,12 @@ set -e +default_route_ip=$(ip route | grep default | awk '{print $3}') +if [[ -z "$default_route_ip" ]]; then + echo "No default route configured" >&2 + exit 1 +fi + configs=`find /etc/wireguard -type f -printf "%f\n"` if [[ -z "$configs" ]]; then echo "No configuration files found in /etc/wireguard" >&2 @@ -31,6 +37,11 @@ else ip6tables -I OUTPUT ! -o $interface -m mark ! --mark $(wg show $interface fwmark) -m addrtype ! --dst-type LOCAL $docker6_network_rule -j REJECT fi +if [[ "$LOCAL_NETWORK" ]]; then + ip route add $LOCAL_NETWORK via $default_route_ip + iptables -I OUTPUT -d $LOCAL_NETWORK -j ACCEPT +fi + shutdown () { wg-quick down $interface exit 0