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 have to setup dead gateway detection on a linux box with three network interfaces. The only guides I have found so far on the topic imply patching the kernel, which we are not very keen to do. Is there any other way?

Thanks.

Edited to clarify

The 3 interfaces are: 1 Ethernet, 1 wifi and 1 3G modem. The wired is the main connection and the other two are for backup purposes, being the 3G modem the last resource.

High availability is not an issue as we can afford getting disconnected for short periods of time.

The box is at the same time client (sends data to a central server) and server (the central server can change its configuration) and makes public it's current IP by a dyndns-like mechanism.

At the end we will have hundreds of boxes reporting to one central server so the maintenance on the boxes should be as low as possible.

share|improve this question
    
Perhaps you could explain in more detail exactly what functionality you're looking for? –  Chopper3 Feb 1 '11 at 16:05
    
If you want to switch to another gateway after detection to avoid service interruption. Maybe, you can implement a high availability solution instead of dead gateway detection. –  Khaled Feb 1 '11 at 16:30
1  
Will dead gateway detection even be useful for you? As far as I understand DGD, is only useful at detecting a failure of the only the next hop. If the failure is beyond the gateway then DGD will do nothing for you. –  Zoredache Feb 1 '11 at 17:23
add comment

3 Answers

If gateway responds to ICMP requests, you may use ping:

ping -qc 4 $GATE1 > /dev/null

if [ "$?" -ne 0 ];
ping -qc 4 GATE2 > /dev/null
if [ "$?" -ne 0 ];
 ping -qc 4 $GATE3 > /dev/null
 if [ "$?" -ne 0 ];
  ip route del default;ip route add default via $GATE3
 else
  echo "Three gateway down!"
 fi
else
 ip route del default;ip route add default via $GATE2
fi

If gateway doesn't respond to ICMP requests, change "ping -qc 4" to "ping -qc 4 -I IP_OF_INTERFACE_TO_GATE_N 8.8.8.8"

share|improve this answer
add comment

Why not run rip or another routing protocol? That's exactly what they're designed for. Quagga runs on Linux (amongst others) and implements a number of these protocols very well.

In my own systems I use ucarp to manage a virtual IP and then advertise the virtual address as the gateway to my clients via DHCP. Then the real gateways use rip to decide what to actually do with packets they receive.

share|improve this answer
2  
This of course depends on your upstream providers supporting a routing protocol. –  Zoredache Feb 1 '11 at 17:13
1  
In my case the "upstream providers" are cheap ADSL modems, which also do RIP and when the WAN side drops don't advertise a gateway in their RIP messages any more. The real upstream provider(s) aren't involved. You can also do similar for PPP (oE or 3G dongles) which are terminated on the Linux box(es) - when the connection fails and the device drops the routes vanish too. –  Flexo Feb 1 '11 at 17:15
add comment

iproute2 has an "ip monitor" option that can monitors route state, and change them if necessary.

Never tried, but it doesn't look complicated and seems more usable that a script.

share|improve this answer
    
"ip monitor" uses a netlink socket to monitor changes to the routing table, not changes in gateway connectivity –  jdizzle Mar 6 at 18: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.