unreachable switch to the other gateway.
Schedule this script to run every minute or so from cron.
#!/bin/bashThis script requires that both your ISP's are pre-configured and are
GW1="192.168.10.254"
GW2="192.168.55.254"
TESTIP="192.71.220.10" # Any reliable Internet ip that responds to ping.
CURGW=`/sbin/route -n |awk '/^0.0.0.0/ {print $2 }'`
if ping -w2 -c3 $TESTIP >/dev/null 2>&1; then
echo "Active ISP is Ok."
else
if [ "$CURGW" = "$GW1" ]; then
NEWGW="$GW2"
else
NEWGW="$GW1"
fi
/sbin/route del default
/sbin/route add default gw $NEWGW
fi
not messing with your routing table when connected/disconnected,
esp. PPP is know to be quite unpolite when dealing with routes.
You probably want some sort of test to see if the new path is
working as well. Other concerns may be iptables/tc reloading
and stuff like that.
No comments:
Post a Comment