Gateway Switch script
am 28.08.2003 12:24:25 von Murali Potla
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
Re: Gateway Switch script
am 28.08.2003 14:36:33 von Jeff Largent
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.
-
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
Re: Gateway Switch script
am 28.08.2003 14:49:52 von Vitalie Cherpec
>
>
>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
>
>
You can set up your default route to be a multipath route. Then you
could use both connections simultaneously and continue to use the
other one if one is down. There is no need to switch default gateway
with a script. Your kernel will figure out when to stop using the dead
route and how to do NAT.
Check these urls:
http://lartc.org/howto/lartc.rpdb.multiple-links.html
http://www.ssi.bg/~ja/#routes
http://www.ssi.bg/~ja/nano.txt
Vitalie
-
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