diff options
Diffstat (limited to 'etc/opennhrp-script')
-rwxr-xr-x | etc/opennhrp-script | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/etc/opennhrp-script b/etc/opennhrp-script new file mode 100755 index 0000000..8d5e2d3 --- /dev/null +++ b/etc/opennhrp-script @@ -0,0 +1,38 @@ +#!/bin/sh + +case $1 in +interface-up) + ip route flush proto 42 dev $NHRP_INTERFACE + ip neigh flush dev $NHRP_INTERFACE + ;; +peer-register) + ;; +peer-up) + if [ -n "$NHRP_DESTMTU" ]; then + ARGS=`ip route get $NHRP_DESTNBMA from $NHRP_SRCNBMA | head -1` + ip route add $ARGS proto 42 mtu $NHRP_DESTMTU + fi + echo "Create link from $NHRP_SRCADDR ($NHRP_SRCNBMA) to $NHRP_DESTADDR ($NHRP_DESTNBMA)" + racoonctl establish-sa -w isakmp inet $NHRP_SRCNBMA $NHRP_DESTNBMA || exit 1 + racoonctl establish-sa -w esp inet $NHRP_SRCNBMA $NHRP_DESTNBMA gre || exit 1 + ;; +peer-down) + echo "Delete link from $NHRP_SRCADDR ($NHRP_SRCNBMA) to $NHRP_DESTADDR ($NHRP_DESTNBMA)" + if [ "$NHRP_PEER_DOWN_REASON" != "lower-down" ]; then + racoonctl delete-sa isakmp inet $NHRP_SRCNBMA $NHRP_DESTNBMA + fi + ip route del $NHRP_DESTNBMA src $NHRP_SRCNBMA proto 42 + ;; +route-up) + echo "Route $NHRP_DESTADDR/$NHRP_DESTPREFIX is up" + ip route replace $NHRP_DESTADDR/$NHRP_DESTPREFIX proto 42 via $NHRP_NEXTHOP dev $NHRP_INTERFACE + ip route flush cache + ;; +route-down) + echo "Route $NHRP_DESTADDR/$NHRP_DESTPREFIX is down" + ip route del $NHRP_DESTADDR/$NHRP_DESTPREFIX proto 42 + ip route flush cache + ;; +esac + +exit 0 |