ISP Fail Over Script
I used the [tag]ISP[/tag] [tag]failover[/tag] [tag]script[/tag] for my personal reference which I get an idea(modify) from Shorewall malling list
#!/bin/sh
#Purpose: If main ISP(Maxis) down then it
will automatic switch to second ISP(TMNET)
#Note: Please make sure this script run in the
cronjob every 5 minutes
#Tips: Use command "route -n" for checking
default gateway
ISP1=xx.xx.xx.xx
ISP2=xxx.xxx.xxx.xxx
switch_time()
{
/sbin/route del default
/sbin/route add default gw $ISP2
}
switch_maxis()
{
/sbin/route del default
/sbin/route add default gw $ISP1
}
if /bin/ping -c1 -q www.google.com >/dev/null 2>&1;
then
echo "MAXIS GATEWAY is alive"
/sbin/ip route show
exit 0
else
if /sbin/route -n | /bin/grep '^0.0.0.0' | /bin/grep
"$ISP1"; then
/sbin/ip route flush cache
switch_tm
/sbin/route -n
/bin/echo "ISP Switch to TMNET GATEWAY" |/bin/mail -s
"ISP switch to TMNET GATEWAY" alert@yourdomain.com
else
if /sbin/route -n | /bin/grep '^0.0.0.0' | /bin/grep "$ISP2"; then
/sbin/ip route flush cache
/sbin/route -n
/bin/echo "ISP Switch to MAXIS GATEWAY" |/bin/mail -s
"ISP switch to MAXIS GATEWAY" alert@yourdomain.com
switch_maxis
fi
fi
Possibly Related Posts:
- Set a Good Password Policy On SuSE Linux
- How To Check Which Port Is Listern or Open on Linux
- How To Force User Change Password At Next Login on Linux
- How to Disable CTRL-ALT-DEL shutdown key on Linux server
- Basic vmware-cmd VM Management tips
September 8th, 2006 at 4:47 pm
Dial-up connections only >.>
September 8th, 2006 at 7:17 pm
Hi Noor Hidayat, I used this script on “fixed IP address” in my Linux box.
July 16th, 2008 at 1:30 pm
just to let you know, missing a final fi at end of ur posted script =)