Ini contoh script sederhana utk ngecek koneksi ke yahoo.com dan kalau RTO gateway dipindah ke koneksi satunya.
#!/bin/sh
#Scipt by harijanto@datautama.net.id
#Crazy idea from priyo@datautama.net.id
#Thanks
/sbin/route | grep default | grep 119.82.246.1
error=$?
echo $error
if [ $error = 0 ]
then
if a=`ping -q -c 1 -w 3 www.yahoo.com > /dev/null`
then
echo "Link Utama to International OK"
else
echo "Link Utama to International NOT OK"
/sbin/route add -net 0.0.0.0/0 gw 203.89.24.1
/sbin/route del -net 0.0.0.0/0 gw 119.82.246.1
fi
else
echo "Link Pake Backup Coba pindahin ke Link Utama Lagi"
/sbin/route add -net 0.0.0.0/0 gw 119.82.246.1
/sbin/route del -net 0.0.0.0/0 gw 203.89.24.1
if a=`ping -q -c 1 -w 3 www.yahoo.com > /dev/null`
then
echo "Link Utama to International Sudah OK"
else
echo "Link Utama to International Masih NOT OK CAPEDEH"
/sbin/route add -net 0.0.0.0/0 gw 203.89.24.1
/sbin/route del -net 0.0.0.0/0 gw 119.82.246.1
fi
fi
misal kasih nama /etc/checkyahoo.sh
terus script tersebut tinggal di crond per 10 menit di /etc/crontab
*/10 * * * * root /etc/checkyahoo.sh > /dev/null 2>&1
lalu restart crond:
service crond restart
jadi dech Fail Over Sederhana :p
Tidak ada komentar:
Posting Komentar