ansible-roles/vpn/bridge/templates/ifupdown.d/20-routes

38 lines
1.1 KiB
Plaintext
Raw Normal View History

2023-08-10 16:34:04 +02:00
#!/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")
{% if vpn_bridge_routing_table is defined %}
2023-08-13 23:47:03 +02:00
/usr/sbin/ip -4 rule add dev ${IFACE} table {{ vpn_bridge_routing_table }}
/usr/sbin/ip -6 rule add dev ${IFACE} table {{ vpn_bridge_routing_table }}
2023-08-10 16:34:04 +02:00
2023-08-13 23:47:03 +02:00
/usr/sbin/ip -4 rule add dev ${IFACE} to {{ local_inet_network }} table main priority 1
/usr/sbin/ip -6 rule add dev ${IFACE} to {{ local_inet6_network }} table main priority 1
2023-08-10 16:34:04 +02:00
{% endif %}
;;
"post-up")
;;
"pre-down")
;;
"post-down")
{% if vpn_bridge_routing_table is defined %}
2023-08-13 23:47:03 +02:00
/usr/sbin/ip -6 rule del dev ${IFACE} to {{ local_inet6_network }} table main priority 1
/usr/sbin/ip -4 rule del dev ${IFACE} to {{ local_inet_network }} table main priority 1
2023-08-10 16:34:04 +02:00
2023-08-13 23:47:03 +02:00
/usr/sbin/ip -6 rule del dev ${IFACE} table {{ vpn_bridge_routing_table }}
/usr/sbin/ip -4 rule del dev ${IFACE} table {{ vpn_bridge_routing_table }}
2023-08-10 16:34:04 +02:00
{% endif %}
;;
esac