LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-11-2005, 03:42 PM   #1
rubella
Member
 
Registered: Sep 2005
Location: Europe
Distribution: debian sarge
Posts: 65

Rep: Reputation: 15
detect lost ppp connection


hey folks!

i make a connection with the company through a pptp connection. They have the server, i'm the client... sometimes, i loose my connection (every 4 days). i don't know why...

does someone has a script (cron?) to detect when connection has been lost and to reconnect over ppp?

now, i use 'pon companyname' to connect and use ifconfig to check connectivity...
thx!
 
Old 12-11-2005, 09:31 PM   #2
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
It'd be pretty trivial to throw together a small shell script which could be called from cron to check the network status, I've used fping (www.fping.com ) to do pretty much this same thing (can't use normal ping on this one as we need (preferably) an easy way to get the results back to the shellscript..fping does this nicely

Install fping, then create a shell script:
Code:
#!/bin/bash

HOST="xxx.xxx.xxx.xxx" # <=IP of the server you're connecting to

if fping $HOST; then
exit
else
pon companyname
fi
Save and chmod +x the file and stick it somewhere, run it from crontab however often you need....
 
Old 12-12-2005, 01:58 AM   #3
uberNUT69
Member
 
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578

Rep: Reputation: 30
I suggest you take a look at /etc/ppp/options.
Specifically, these options:
persist
maxfail
holdoff

Here's a nice description:
http://www.linux.com/guides/nag2/x7297.shtml

You can put these options in the relevant peers file
rather than specifying it globaly in 'options'.
 
Old 12-12-2005, 03:13 AM   #4
rubella
Member
 
Registered: Sep 2005
Location: Europe
Distribution: debian sarge
Posts: 65

Original Poster
Rep: Reputation: 15
hey guys, thx for the solutions!
the persist option was allready there in my peers file, i add the other ones too!
maxfail 0
holdoff 20

to be sure this goddamn connection never goes down again, i'll apply previous script to my cron...
 
Old 12-12-2005, 03:59 AM   #5
uberNUT69
Member
 
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578

Rep: Reputation: 30
Watch out for your call costs with maxfail=0!!!
 
Old 12-12-2005, 04:16 AM   #6
uberNUT69
Member
 
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578

Rep: Reputation: 30
You might want to grep your syslog to find out why it's hanging up.
Is it server timeout, hangup on inactivity ... ?
You might find, as your persist option was already set
that maxfail was defaulting to 10 and that
10 x (max session time) = ~4 days ???

With maxfail=0, for example, a problem at their end would mean constant
redials (until you're poor )
 
Old 12-12-2005, 05:27 AM   #7
iceman47
Senior Member
 
Registered: Oct 2002
Location: Belgium
Distribution: Debian, Free/OpenBSD
Posts: 1,123

Rep: Reputation: 47
if everthing else fails, add this to crontab (crontab -e as root)
0 * * * * poff <provider> && pon <provider>

this will terminate $ reinitialize the ppp connection every day @ 00:00, change crontab to your liking

...or you could use a script like this:
Code:
#!/usr/bin/perl
# $iptocheck is the remote ip of the tunnel, we can safely assume if this isn't available
# in the ip list, the tunnel isn't there either.

$iptocheck = "192.168.1.1/32";

$rc = system('ip a | grep '.$iptocheck.' 2>&1> /dev/null');
if ($rc eq 0)
{
        $date=`date`;
        chomp($date);
        `echo '$date -> ok' >> <logfile>`;
}
else
{
        `/usr/bin/poff <provider>`;
        `/usr/bin/pon <provider>`;
        $date=`date`;
        chomp($date);
        `echo '$date -> tunnel gone' >> <logfile>`;
}
Note: don't forget to supply the full path for pptp in /etc/ppp/peers/<provider>.

Last edited by iceman47; 12-12-2005 at 05:28 AM.
 
Old 12-12-2005, 05:40 AM   #8
rubella
Member
 
Registered: Sep 2005
Location: Europe
Distribution: debian sarge
Posts: 65

Original Poster
Rep: Reputation: 15
Iceman, this one is so cool! thx mate, i owe you a beer!

Ubernut: it's a free connection... and for you a beer too
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to detect lost socket connection sasha_baranov Programming 4 02-16-2005 11:46 PM
ppp connection aps_rewa Linux - Networking 0 05-20-2004 04:39 AM
ppp connection help LUXX Linux - Newbie 4 11-14-2003 01:06 AM
ppp connection very slow tjpick Linux - Networking 2 10-26-2003 01:20 AM
ppp connection link explorer Linux - Distributions 4 04-20-2003 07:33 AM


All times are GMT -5. The time now is 01:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration