Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 3 down vote accepted

I would realize this with a simple cron job


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

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

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

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

Your Answer


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.