Linux as backup (failover) machine

Kevin Buettner kev@primenet.com
Fri, 3 Nov 2000 19:08:15 -0700


On Nov 4,  8:11am, Ken Bowley wrote:

> I've been posed with a question, and I'm a little stumped...  please
> bear with me.
> 
> Problem:
> Make a Linux machine automatically kick in as a failover machine for
> http when the NT machine goes down.
> 
> Restrictions:
> Need to be able to monitor the NT box without installing anything
> extra on the NT machine.  Linux machine needs to be able to kick in
> automatically when the NT box goes down, and give control back to
> the NT box when it comes back up.  No access to installing any type
> of router/proxy between the NT and Linux box and the rest of the
> net.
> 
> Please send your ideas either directly to myself, or to the list if
> this problem is of interest to others.

First, I'm sure that there's some code already out there somewhere
for this, but it doesn't sound terribly difficult to implement from
scratch either.  (Maybe about five lines of Perl?)

Anyway, the NT box in pingable, right?

Set up a script which continuously pings the NT box; when the
pings stop coming back, do an ifconfig on your network interface
to the NT box's IP address.

The reqlinquishing control part is harder, but could be easily
solved if the NT machine had two network adapters; you could ping
the second one to know when to give up the NT machine's IP
address.

So... thinking about this some more, it'd probably be best if
both machines had two network cards.  Weird things happen
when two machines attempt to use the same IP address.

So here's how it'd look:

====+==+==============+==+========= Network
    |  |              |  |
   A| B|             C| D|
    |  |              |  |
   -+--+-           --+--+-    
  |  NT  |         | Linux |    
  --------         ---------    

Now suppose that NT is supplying its services via interface A and
that you want Linux to use C when it acts as the failover.

So...  start out with C disabled ("ifconfig eth0 down", or somesuch). 
Ping B via D.  When the pings stop coming back, do "ifconfig eth0 up ..."
Now, you continue to ping B from D, and when the pings resume, just
do "ifconfig eth0 down" again to allow the NT machine to take over
again.

It may be possible to make it work with a single NIC on the NT box,
but I have doubts about the reliability.  (But someone who knows
more about networking that I do might have some ideas.)

Note too that you can tighten the whole arrangement up by doing:

====+=================+============ Network
    |                 |   
   A|                C|   
    |                 |   
   -+-----         ---+----    
  |  NT  +----~----+ Linux |    
  -------- B     D ---------    

where the cable between B and D is a crossover cable.  That way too
you could assign B and D network addresses intended for private
networks (192.168.X.Y or 10.X.Y.Z).

Okay, so maybe it's around 25 lines of Perl.  (It sounds interesting
enough that I'm tempted to code it myself.)

Kevin