74b6f9487c
Hetzner uses link-local addressing for their default IPv6 route, accordingly we should specify the device a route is associated with so that it will use the correct interface. Thanks to Devin Brown for reporting this issue.
46 lines
919 B
Bash
Executable file
46 lines
919 B
Bash
Executable file
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
[ -z "$IF_METRIC" ] && IF_METRIC="1"
|
|
[ -n "$IF_VRF_TABLE" ] && VRF_TABLE="table $IF_VRF_TABLE"
|
|
[ -n "$IF_VRF_MEMBER" ] && VRF_TABLE="vrf $IF_VRF_MEMBER"
|
|
[ -n "$IF_METRIC" ] && METRIC="metric $IF_METRIC"
|
|
|
|
addr_family() {
|
|
if [ "$1" != "${1#*[0-9].[0-9]}" ]; then
|
|
echo "-4"
|
|
elif [ "$1" != "${1#*:[0-9a-fA-F]}" ]; then
|
|
echo "-6"
|
|
else
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
configure_addresses() {
|
|
for i in $(ifquery -p address -i $INTERFACES_FILE $IFACE); do
|
|
addrfam=$(addr_family $i)
|
|
${MOCK} ip $addrfam addr $1 $i dev $IFACE
|
|
done
|
|
}
|
|
|
|
configure_gateways() {
|
|
for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do
|
|
addrfam=$(addr_family $i)
|
|
${MOCK} ip $addrfam route $1 default via $i $VRF_TABLE $METRIC dev $IFACE
|
|
done
|
|
}
|
|
|
|
[ -z "$VERBOSE" ] || set -x
|
|
|
|
case "$PHASE" in
|
|
up)
|
|
configure_addresses add
|
|
configure_gateways add
|
|
;;
|
|
down)
|
|
configure_gateways del
|
|
configure_addresses del
|
|
;;
|
|
*) exit 0 ;;
|
|
esac
|