ifupdown-ng/executor-scripts/linux/static

38 lines
648 B
Text
Raw Normal View History

#!/bin/sh
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
done
}
case "$PHASE" in
up)
configure_addresses add
configure_gateways add
;;
down)
configure_gateways del
configure_addresses del
;;
*) exit 0 ;;
esac