I use Drut in systems that need Internet connectivity in LANs with multiple Routers routing through different uplinks. Drut is not a replacement for VRRP and VRRP is not a replacement for Drut, the same goes for tables ... blah ... blah ... it is easier to read what it does ...
#!/bin/bash #g0 2014 , http://ipduh.com/contact #drut.sh , Default RoUTe manager #Default Gateways MYGWS=("10.21.241.120" "10.21.241.121" "10.21.241.122" "10.21.241.123") #IP addresses to ping PONG=("8.8.8.8" "8.8.4.4") PING_COUNT=3 FAIL=0 ALTGW=0 SET_GW=`route -n |grep "^0.0.0" |awk '{print $2}'` for PIP in ${!PONG[*]};do if ! ping -c ${PING_COUNT} ${PONG[$PIP]} 1>/dev/null 2>/dev/null; then FAIL=`expr ${FAIL} + 1` fi done if [ ${FAIL} -eq 0 ]; then exit 0 else for GW in ${!MYGWS[*]}; do if [ " ${MYGWS[$GW]}" != "${SET_GW}" ]; then FAIL=0 route add default gw ${MYGWS[$GW]} route del -net 0/0 gw ${SET_GW} for PIP in ${!PONG[*]};do if ! ping -c ${PING_COUNT} ${PONG[$PIP]} 1>/dev/null 2>/dev/null; then FAIL=`expr ${FAIL} + 1` fi done [ ${FAIL} -eq 0 ] && exit 0 fi done exit 3 fi
Drut --Default RoUTe manager