ovpn-admin/stop.d/secondary_ip_route.sh

6 lines
200 B
Bash

#!/usr/bin/env bash
set -ex
default_iface=$(ip route | grep default | awk '{print $5}')
iptables -t nat -I POSTROUTING -s "$OVPN_NET_SUBNET" -o "$default_iface" -j SNAT --to-source "$OVPN_PUBLIC_IP"