All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Largent <jlargent@imagelinks.com>
To: Murali Potla <murali.potla@softprosys.com>
Cc: linux-admin <linux-admin@vger.kernel.org>
Subject: Re: Gateway Switch script
Date: Thu, 28 Aug 2003 08:36:33 -0400	[thread overview]
Message-ID: <3F4DF751.5000407@imagelinks.com> (raw)
In-Reply-To: <1062066265.19990.19.camel@krishna.softprosys.com>

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.


  reply	other threads:[~2003-08-28 12:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-28 10:24 Gateway Switch script Murali Potla
2003-08-28 12:36 ` Jeff Largent [this message]
2003-08-28 12:49 ` Vitalie Cherpec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F4DF751.5000407@imagelinks.com \
    --to=jlargent@imagelinks.com \
    --cc=linux-admin@vger.kernel.org \
    --cc=murali.potla@softprosys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.