On 2014-10-01 16:10, Jeff wrote:
I have a very unreliable ISP (approximately 97% uptime). Many of the
times that they go
down, I'm connected and can ping within their limited network, but
can't get to the
"outside world". In these cases, I have an alternate slow speed
connection that I use.
Right now, I manually change the default route and use pfctl to invoke
an alternate
pf.conf file.
I'm thinking that OpenOSPF, BIRD or one of the other routing oriented
daemons might be a
way to automate switching back and forth.
Does anyone suggestions on effective ways to automate/manage this?
Thanks!
Jeff
Implementing a dynamic routing protocol will ensure the switch over but
would require either ISP cooperation or a server on the internet side.
the easiest way to achieve what you want is scripting default route
change.
Something like that should do the trick.
while true
do
route1=$(ping -I $INTERFACE_TO_ISP1 $ISP1_GATEWAY -c 1 | tail
-n2 | head -1 | grep -c "1 received")
route2=$(ping -I $INTERFACE_TO_ISP1 $ISP2_GATEWAY -c 1 | tail
-n2 | head -1 | grep -c "1 received")
routa=$(ip route | grep "default" | cut -d' ' -f3 | tr -d ' ')
if [ "$route1" != "1" ]
then
route del default
route add default gw $ISP2_GATEWAY
else
if [ "$routa" != "$ISP1_GATEWAY" ]
then
route del default
route add default gw $ISP1_GATEWAY
fi
fi
sleep $waittime //you may want to wait a bit between checks
done
Regards
Louis