ansible-roles/vpn/wireguard/templates/ifupdown.d/20-routes-client

28 lines
714 B
Bash
Executable File

#!/usr/bin/env bash
if [ ${MODE} == "start" ]
then
set -ue
elif [ ${MODE} == "stop" ]
then
set -u
else
echo "$(basename ${0}): mode must be one of either 'start' or 'stop'" 1>&2
exit 1
fi
case ${PHASE} in
"pre-up")
;;
"post-up")
/usr/sbin/ip -4 route add default dev ${IFACE} table {{ vpn_wireguard_routing_table }}
/usr/sbin/ip -6 route add default dev ${IFACE} table {{ vpn_wireguard_routing_table }}
;;
"pre-down")
/usr/sbin/ip -6 route del default dev ${IFACE} table {{ vpn_wireguard_routing_table }}
/usr/sbin/ip -4 route del default dev ${IFACE} table {{ vpn_wireguard_routing_table }}
;;
"post-down")
;;
esac