You have to write one small shell script which ping a test IP and if it seems unreachable switch to the different gateway. Schedule such script to launch after every minute or so with the help of cron execution command .
Code:
#!/bin/bash
GW1="192.168.10.254"
GW2="192.168.55.254"
TSTIP="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
Bookmarks