ansible-roles/vpn/bridge/templates/ifupdown.d/00-interface

35 lines
902 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")
/usr/sbin/ip link add ${IFACE} type bridge
/usr/sbin/ip link set dev ${IFACE} type bridge forward_delay 0
/usr/sbin/sysctl -q -w net.ipv6.conf.${IFACE}.autoconf=0
/usr/sbin/ip -4 address add {{ vpn_bridge_inet_address }}/{{ vpn_bridge_inet_prefixlen }} dev ${IFACE}
/usr/sbin/ip -6 address add {{ vpn_bridge_inet6_address }}/{{ vpn_bridge_inet6_prefixlen }} dev ${IFACE} nodad
;;
"post-up")
;;
"pre-down")
;;
"post-down")
/usr/sbin/ip -6 address flush dev ${IFACE}
/usr/sbin/ip -4 address flush dev ${IFACE}
/usr/sbin/ip link delete dev ${IFACE}
;;
esac