how to setup automated PPPoE failover on Linux?

SilverNodashi

Expert Member
Joined
Oct 12, 2007
Messages
3,337
Hi all,

I have an OpenSuse 10.2 server (client doesn't want to upgrade, why fix it when it aint broke?) using PPPoE to connect to an ADSL modem, which works fine. I would like to setup a second PPPoE account as backup, but need to be able to automatically switch to the backup one when the primamary one fails, either due to authentication problems (i.e. radius issues with ISP) or cap used up (at which point it should fallback to a second ADSL account which has sufficient cap) The later is normally more the case which we need, i.e. the client runs out of cap at the 27th / 28th / 29th of the month, and it doesn't really make sence to purchase another 1GB CAP if I have another account which has sufficient CAP available, and they only need 100-200MB to see them through the month.

Any suggestions?
 

ruan567

Senior Member
Joined
Feb 8, 2006
Messages
710
Well I suppose you could set up a shell script that pings one or more internet sites to check for traffic - analyse the output with awk, and then if the link is down invoke another script to dial up the second account? Or am I missing something here?
 

ponder

Honorary Master
Joined
Jan 22, 2005
Messages
92,823
Just thinking about this now but I'm pretty sure that when your adsl gets capped you still retain your dynamic IP and the route stays up, failing and being capped does not yield the same symptoms. This and the dynamic IP makes things tricky. If it was static and the route failed (or got poisoned) it would be pretty simple to implement.

Will probably need scripts as suggested by ruan567. You could also have both links configured and active and then use a script to poison or delete the default route and create a new one.

http://linux-ip.net/html/index.html
http://lartc.org/
 
Last edited:

Nod

Honorary Master
Joined
Jul 22, 2005
Messages
10,057
Write a script where you ping a international site, something like:
Code:
ping -c 3 www.google.com >/dev/null && echo OK
This will send 3 requests, and only return "OK" if successful. If not successful, you'll get nothing back.
Code:
LINK_UP=`ping -c 3 www.google.com >/dev/null && echo OK`
if [ $LINK_UP -eq "OK" ]
then
    echo "Link Ok."
else
    echo "Swap Links"
fi
You can thus assign the output to a variable, and then check this variable, and do something according to that, like stopping the current pppoe connection, and starting the second one. You can also put a date in there so that you can go back to the first link when the new month starts.
 

RSkeens

Expert Member
Joined
Jan 5, 2007
Messages
1,647
Assuming you can't authenticate when the cap runs out will make this easy. You can schedule the script below as a cron job during desired check intervals:

Code:
#!/bin/bash
PATH=$PATH:/sbin

if [ "`ifconfig | grep ppp0`" == '' ]
then
sudo ifdown ppp1
sudo ifup ppp1
fi
 
K

kingrob

Guest
Just give them the uername and password to type into the router's config page, or get them a ADSL account with more bandwidth. Sorted. :)
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,475
Why don't you get an account that can auto topup? That would sort the cap problem.
 
Top