Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am currently using a Linux box (CentOS 5.9) as my router. The router is multihomed and uses two ISP to connect to the internet. Internet traffic from the LAN is distributed through both the lines.

When a particular ISP connection goes down I had to manually route the traffic through the other ISP. What is the best way to detect a dead ISP gateway and route traffic through the alternate ISP connection?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

I would realize this with a simple cron job

#!/bin/sh

PING=$(ping $ETH0ISPGW -I eth0 -c1 -W5 | awk -F '[ /]*' '/rtt/ {print $8}')

if [ -z "$PING" ]; then
        echo "Line is dead"
        echo "do something"
else
        echo "everything ok"
        echo "$PING"
fi

If the line drops delete the specific rule , and let it send you an email, or something.

With a dedicated routing platform like pfSense, it would take care of multiple connections on its own. regardles of the configuration of the two lines (load balancing, backup ect.)

share|improve this answer
    
@Michael Kjörling Thank for editing :). I was not aware that editing of other users posts is posible :) –  Daywalker Aug 20 '13 at 11:57
    
It is possible, and in fact it is encouraged (link to help center) to edit (both questions and answers) on the Stack Exchange network when something can be improved. (Though one should be careful to not change too much; sometimes there's a fine line between when it's appropriate to edit an existing answer and when it's better to add another answer of your own.) –  Michael Kjörling Aug 20 '13 at 12:12
add comment

You could use route metrics.

 route add default gw $gw1 metric 1
 route add default gw $gw2 metric 2

in this way, if link 1 goes down, system will chose the secondary route. Not a balancer but a it should do the job. If you're looking for balancing too, i'd look to something hardware.

share|improve this answer
    
While this might be useful it will only work if the failure is on the directly connected link. It won't help if there is a failure upstream. For example if you have some kind of broadband internet with an external modem. The link will never go down, since the broadband modem is acting like a Ethernet Bridge/Switch. –  Zoredache Dec 5 '13 at 0:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.