From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Lobato Date: Wed, 07 Feb 2007 23:52:03 +0000 Subject: Re: [LARTC] DGD patch not detecting dead gateway Message-Id: <45CA6623.8000703@gmail.com> List-Id: References: <7fe14e000701182100l5b1474eai853a0077c821a835@mail.gmail.com> In-Reply-To: <7fe14e000701182100l5b1474eai853a0077c821a835@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: lartc@vger.kernel.org Hi! Thank you for the script. I'm trying it. Well, I made a simple modification and would like to hear opnions. Until now, I just added one more TESTIP, so I'm pinging one IP for each link. Also I'm using the IP instead name address, and used the DNS IP of each provider for the ping. I made this because the ping to external sites (yahoo, google) is too slow here, mainly when the link is under heavy load. So I'm afraid it can try ping without success and "think" the link is down. Also, for don't get falses 'link down', did you tried to increase the number of 4 ping fails before replace the route? What do you think about? I appreciate suggestions, PS: although alteration be so simple, if someone want to see, tell me and I send a mail. Tom Lobato Manish Kathuria wrote: > The script is appended. It assumes that you have followed the steps as > described in nano.txt with or without applying the patches. Though it > appears to be very simplistic, its working great at a number of > locations. > > #!/bin/bash -x > > TESTIP=www.yahoo.com > CHECK=0 > ISPA=1 > ISPB=1 > LINKSTATUS=1 > COUNTA=0 > COUNTB=0 > EXTIF1=eth1 > EXTIF2=eth2 > GW12.16.1.1 > GW22.168.1.1 > W1=1 > W2=1 > > while : ; do > > ping -I $EXTIF1 -c 1 $TESTIP > /dev/null 2>&1 > RETVAL=$? > if [ $RETVAL -ne 0 ]; then > COUNTA=`expr $COUNTA + 1` > else > COUNTA=0 > fi > > if [ $COUNTA -ge 4 ]; then > ISPA=0 > else > ISPA=1 > fi > > ping -I $EXTIF2 -c 1 $TESTIP > /dev/null 2>&1 > RETVAL=$? > if [ $RETVAL -ne 0 ]; then > COUNTB=`expr $COUNTB + 1` > else > COUNTB=0 > fi > > if [ $COUNTB -ge 4 ]; then > ISPB=0 > else > ISPB=1 > fi > > > if [ $ISPA -eq 1 ]; then > if [ $ISPB -eq 1 ]; then > NEWSTATUS=1 > elif [ $ISPB -eq 0 ]; then > NEWSTATUS=2 > fi > elif [ $ISPA -eq 0 ]; then > if [ $ISPB -eq 1 ]; then > NEWSTATUS=3 > fi > fi > > case $LINKSTATUS in > > 1) if [ $NEWSTATUS -eq 2 ]; then > ip route replace default via $GW1 dev $EXTIF1 > elif [ $NEWSTATUS -eq 3 ]; then > ip route replace default via $GW2 dev $EXTIF2 > fi;; > > 2) if [ $NEWSTATUS -eq 1 ]; then > ip route del default > ip route replace default table 222 proto static \ > nexthop via $GW1 dev $EXTIF1 weight $W1\ > nexthop via $GW2 dev $EXTIF2 weight $W2 > elif [ $NEWSTATUS -eq 3 ]; then > ip route replace default via $GW2 dev $EXTIF2 > fi;; > > 3) if [ $NEWSTATUS -eq 1 ]; then > ip route del default > ip route replace default table 222 proto static \ > nexthop via $GW1 dev $EXTIF1 weight $W1\ > nexthop via $GW2 dev $EXTIF2 weight $W2 > elif [ $NEWSTATUS -eq 2 ]; then > ip route replace default via $GW1 dev $EXTIF1 > fi;; > > *) echo;; > > esac > > LINKSTATUS=$NEWSTATUS > sleep 10 > done > > Let me know if you can think of any improvements or modifications. > _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc