I'm trying to setup some kind of reachability monitoring over l2l VPN for right openenwrt router using standard ping. where:
192.168.172.1 - right openwrt router
192.168.174.242 - left openwrt router
I'd like to achieve behavior like bellow:
send 10 icmp packets from left to right routers (via s2s VPN)
if packet lost more than 10-20% restart ipsec
if packet lost less than 10-20% exit scpir with level 0 (do nothing).
bellow my small script:
#!/bin/ash
/bin/ping -c10 -q 192.168.172.1 -I 192.168.174.242 > /dev/null
if [ $? -eq 0 ]
then
/usr/bin/logger "as for `date` RA VPN to home is up, gate is reachable"; exit 0
else
/usr/sbin/ipsec stop; /usr/sbin/ipsec stop; /usr/sbin/ipsec stop; sleep 1
/etc/init.d/ipsec start
/usr/bin/logger "as for `date` RA VPN to home was down !!!! tried to re-establish. !!!!"
fi
I'm hitting behavior like this:
if ping gets at least 1 of 10 packet lost, script exit with exit 1 status and ipsec resetting tunnel even it up and reachable.
/bin/ping -c4 -q 192.168.172.1 -I 192.168.174.242
as results VPN reloads couple times per hour...
I took a look at opkg repository, but unfortunately did not find something suitable for my situation..