link failover
i have a centos gw server where i have 3 nic card. eth0 for LAN, eth1 for ISP1 and eth2 for ISP2. my plan is to use ISP2 when ISP1 is down. i made following script:
#!/bin/bash
myHost="67.147.160.76"
while true
do
ifconfig eth1 up
ifconfig eth2 down
count=$(ping -c1 $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $count -eq 0 ]; then
# 100% failed
ifconfig eth1 down
ifconfig eth2 up
else
ifconfig eth2 down
ifconfig eth1 up
fi
sleep 1000
done
_____________________________
the script is working but when it enables eth2 my users cannot browse net.
please help me.
|