From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Largent Subject: Re: Gateway Switch script Date: Thu, 28 Aug 2003 08:36:33 -0400 Sender: linux-admin-owner@vger.kernel.org Message-ID: <3F4DF751.5000407@imagelinks.com> References: <1062066265.19990.19.camel@krishna.softprosys.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1062066265.19990.19.camel@krishna.softprosys.com> List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Murali Potla Cc: linux-admin You could use something like this, run out of cron. #!/bin/bash $DEF='192.168.1.1' $BACK='192.168.2.1' $CURRENT=`netstat -rn | grep "^0.0.0.0" | awk '{print $2}'` # if $DEF is current check and switch to backup if down if [ $CURRENT = $DEF ]; then ping -c1 -w5 $DEF if [ $? > 0 ]; then route del default gw $DEF route add default gw $BACK fi # else check the backup and switch to def if down else ping -c1 -w $BACK if [ $? > 0 ]; then route del default gw $BACK route add default gw $DEF fi fi This is totally untested so you milage may vary. Murali Potla wrote: > Hi, > > Does any body has a script to automatically switch the default gateway > between two IPs. ? > > I have two ISP connections. I want to switch between them when one is > down > > > Regards > Murali > > > - > To unsubscribe from this list: send the line "unsubscribe linux-admin" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- Jeff Largent ImageLinks, Inc.