FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 07-09-2008, 03:47 PM
Robert Moskowitz
 
Default Need basic PPPoE startup help

I need basic PPPoE startup help.

adsl-start DID bring up my PPPoE link (ppp0) to my ISP over eth0 via the
DSL modem/bridge. My IPv4 CIDR block is routing and Shorewall is doing
the firewalling.


But shorewall has to be started after ppp0 is up and working. For now
this means running shorewall restart (or start?). Shorewall 4.2 will
have a way to restart shorewall without recompiling, I learned on the
their list.


In /etc/sysconfig/network-scripts/ifcfg-ppp0 I have:

BOOTPROTO=dialup
NAME=DSLppp0
DEVICE=ppp0
TYPE=xDSL
ONBOOT=no

Should ONBOOT be changed to yes, or is there some startup script that I
should add the


/sbin/adsl-start ppp0

command line followed with the shorewall restart command?

I am away at IEEE 802 plenary meeting next week, and I need this to be
automated in case of system glitches.


Also sometimes the Speedstream just stops forwarding datagrams.
Supposedly if it overheats. This requires a power recycle for the
speedstream (and my ISP will not use anything else for the modem
services). I suspect this will glich the PPPoE connection as well, so I
will need some sort of watchdog and a restart of ppp0 and Shorewall.
Attached is a rather large script of a user that I picked up on the
Shorewall list for some Linux distro. I am NOT a script reader, let
alone writer. Should I use this (how would I modify it for Centos and a
ppp0 interface) and where would I place it to run as needed?


================================================== =====

#!/usr/bin/perl -w

#THIS SCRIPT CREATED BY EJM (alias Erik Mundall) IN ORDER TO MAINTAIN A
CONSTANT CONNECTION WITH THE TWO
#PPPOE ADSL LINES WHICH HAVE PROVEN TO BE UNRELIABLE/UNSTABLE. 15 APRIL
2008

#
#THIS PROGRAM NEEDS TO FOLLOW THE FOLLOWING ROUTINE IN ORDER TO MAINTAIN
CONNECTIVITY OF THE TWO PPPOE LINES

#AND TO SHARE THE INTERNET LOAD ACROSS THOSE AND ACROSS THE STATIC LINE
#
#THE STATIC SHOULD NEVER FAIL. THIS SCRIPT IS INTENDED TO ADDRESS ONLY
THE INSTABILITY OF THE TWO PPPOE

#LINES, AND WILL DO NOTHING FOR THE STATIC LINE IF IT SHOULD FAIL.
#
#
#STEP ONE: THE PROGRAM SHOULD IDENTIFY THE LINE(S) THAT ARE DOWN, IF
ANY, AND ISOLATE THEM.
#STEP TWO: THE PROGRAM SHOULD RECONFIGURE AND RESTART SHOREWALL TO
MATCH THE LINES THAT ARE UP.
#STEP THREE: THE PROGRAM SHOULD FOCUS ON RESTORING THE DROPPED PPPOE
LINE(S).
#STEP FOUR: THE PROGRAM MUST REPEAT STEP TWO ONCE STEP THREE HAS
SUCCEEDED.


###############################################
# REQUIRED VARIABLES. THESE MUST BE SET PROPERLY!!!
our $admin_email =q`your_email_address@your_domain_name.com`;
our $domain_name = "your_domain_name.com";
our $GATEWAY_1 = 'x.x.x.x'; #GATEWAY OF PPP0 LINE
our $GATEWAY_2 = 'x.x.x.x'; #GATEWAY OF PPP1 LINE
our $IPADDRESS_1 = 'x.x.x.x'; #STATIC IP ADDRESS OF PPP0 LINE (ASSIGNED
BY ISP)
our $IPADDRESS_2 = 'x.x.x.x'; #STATIC IP ADDRESS OF PPP1 LINE (ASSIGNED
BY ISP)


our $DEBUG=1; #SET THIS TO 1 FOR DEBUGGING, 0 TO TURN DEBUGGING OFF
our $DEBFILE='/var/log/ppp/debug.log'; #THE /var/log/ppp DIRECTORY MUST
EXIST FOR THE DEBUG FILE
our $logfile='/var/log/ppp/maint.log'; #THE /var/log/ppp DIRECTORY MUST
EXIST FOR LOGGING.


###############################################
# BELOW THIS LINE, NOTHING MORE SHOULD NEED TO BE CONFIGURED.
our @ifconf = ();
our @iprout = `/sbin/ip route`;
our $p1;
our $p2;
our $ppp0=0;
our $ppp1=0;
our $FAILED='FALSE';
our $FAIL='TRUE';
our $attempt=0;
our $date=';
our @data=();
our @updata=();
our @log=();
our @total_log=();
our $cur_day=0;
our $cur_month=0;
our $cur_year=0;
our $late_day=0;
our $late_month=0;
our $late_year=0;
our
%months=(Jan,1,Feb,2,Mar,3,Apr,4,May,5,Jun,6,Jul,7 ,Aug,8,Sep,9,Oct,10,Nov,11,Dec,12);

our $start_time=`/bin/date`;
our $stop_time;

#############################################
### SAFEGUARD AGAINST MULTIPLE PROCESSES! ###
#############################################
our @pslist = `/bin/ps auxw`;
our $line=';
our $scripts=0;

foreach $line(@pslist) {
if ($line=~s/(ppp-line-maintenance.pl)/$1/) { #THIS SCRIPT MUST
NOT BE RENAMED, OR IF IT IS, THIS LINE MUST BE ADJUSTED ACCORDINGLY!!!!

$scripts++;
if ($DEBUG==1) {print "Line:$line
Scripts:$scripts
" };
};
};
if ($scripts<=2) { #CONTINUE THIS SCRIPT IF ONLY ONE OCCURRENCE (THIS
ONE) OF THIS SCRIPT IN CURRENT PROCESS LIST



#############
### BEGIN ###
#############
if ($DEBUG==1) {open DLOG, ">$DEBFILE" or die "Cannot open debugging
file!
"};



&ping1;
&ping2;
&checkdowned;
&trimlog;

if ($DEBUG==1) {close DLOG};

} #END 'CONTINUE SCRIPT'

sleep 2;

exit;


################################################## ################################################## ##
### SUBROUTINES ###
###################

sub ping1 {
$p1=`/bin/ping -c 3 $GATEWAY_1`;
if ($p1=~s/100\%spacketsloss//) {$p1='DOWN'};
if ($p1=~s/unreachable//) {$p1='DOWN'};
if ($DEBUG==1) {print DLOG "p1:$p1
"};
return $p1;
};

sub ping2 {
$p2=`/bin/ping -c 3 $GATEWAY_2`;
if ($p2=~s/100\%spacketsloss//) {$p2='DOWN'};

if ($p2=~s/unreachable//) {$p2='DOWN'};
if ($DEBUG==1) {print DLOG "p2:$p2
"};
return $p2;
};


sub trimlog {
################
### TRIM LOG ###
################
# THIS PRUNES THE LOG FILE TO JUST THE PREVIOUS THREE MONTH PERIOD.
open DATA, "<$logfile" or die "Cannot read PPP maint log file!
";
@data = <DATA>;
close DATA;
$date = `/bin/date`;
#$cur_month =
(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[(localtime)[4]];

$cur_month = (localtime)[4];
$cur_year = (localtime)[5]; $cur_year+=1900;
$cur_day = (localtime)[3];

#PPP Check: Wed Jan 30 09:20:01 CST 2008 [sample from log]

foreach $line(@data) {
if ($line=~m/PPPsCheck:sw{3}s(w{3})s(d{2}).{14}(d{4})/) {
$late_month=$months{$1}; $late_day=$2; $late_year=$3;
if ( ($late_year==$cur_year) && (
(($cur_month-$late_month)>=3) && ($late_day<=$cur_day) ) ) {@updata=()}
elsif ( ($late_year<$cur_year) && (
(($late_month-$cur_month)<=9) && ($late_day<=$cur_day) ) ) {@updata=()}

else { push @updata, $line }
} else { push @updata, $line };
}
open DATA, ">$logfile" or die "Cannot write PPP maint log file!
";
print DATA @updata;
close DATA;
################### END TRIM LOG
};

##############################
### Check for Downed Lines ###
##############################

sub checkdowned {
while ($FAIL eq 'TRUE') {
@ifconf=();
@ifconf = `/sbin/ifconfig`;
$FAIL='FALSE';

while (@ifconf) {
$line=shift @ifconf;
if ($line=~m/ppp0/) {
if ($DEBUG==1) {print DLOG "PPPO:$ppp0 "};

$ppp0=1;
if ($DEBUG==1) {print DLOG "PPPO:$ppp0 "};

$line=shift @ifconf;
if ($line=~m/$IPADDRESS_1/) {$ppp0+=2};
if ($DEBUG==1) {print DLOG "PPPO:$ppp0 "};
$line=shift @ifconf;
if ($line=~m/UP /) {$ppp0+=4};
if ($DEBUG==1) {print DLOG "PPPO:$ppp0
"};
};
if ($line=~m/ppp1/) {
if ($DEBUG==1) {print DLOG "PPP1:$ppp1 "};
$ppp1=1;
if ($DEBUG==1) {print DLOG "PPP1:$ppp1 "};
$line=shift @ifconf;
if ($line=~m/$IPADDRESS_2/) {$ppp1+=2};
if ($DEBUG==1) {print DLOG "PPP1:$ppp1 "};
$line=shift @ifconf;
if ($line=~m/UP /) {$ppp1+=4};
if ($DEBUG==1) {print DLOG "PPP1:$ppp1
"};
print $line
};
}

$attempt++;
if ($DEBUG==1) {print "ATTEMPT: $attempt
"};
if ($FAILED eq 'TRUE') {push @log, "Attempt#:$attempt > PPP0:$ppp0
PPP1:$ppp1
"};


if ($ppp0<7) {
if ($DEBUG==1) {print "$ppp0: Restarting ppp0 line by ifdown/ifup
commands...
"};

system("/sbin/ifdown ppp0");
sleep 3;
system("/sbin/ifup ppp0");
};
if ($ppp1<7) {
if ($DEBUG==1) {print "$ppp1: Restarting ppp1 line by ifdown/ifup
commands...
"};

system("/sbin/ifdown ppp1");
sleep 3;
system("/sbin/ifup ppp1");
};
if ($FAILED eq 'TRUE') {
push @log, `/bin/date`."
";
push @log, @iprout."

";
open LOG, ">>$logfile";
print LOG @log;
close LOG;
}
push @total_log, @log;
@log=();

my $testppp0=ping0;
my $testppp1=ping1;
if ($DEBUG==1) {print "testppp0: $testppp0 testppp1:$testppp1
"};
if (($testppp0 eq 'DOWN') || ($testppp1 eq 'DOWN')) { $FAIL='TRUE' };
if ($FAIL eq 'TRUE') {$FAILED='TRUE'};
if ($DEBUG==1) {print DLOG "FAIL:$FAIL
"};


if ($FAILED eq 'TRUE') {

system("/etc/init.d/shorewall", "restart");
system("/etc/init.d/snmpd restart");
open LOG, ">>$logfile" or die "Cannot open PPP maint log file!
";
print LOG @log;
close LOG;
push @total_log, @log;
$stop_time=`/bin/date`;

################################################## ################################################## #####
#NOW, SEND AN EMAIL OR CAUSE AN ERROR SO THAT CRON WILL EMAIL THE
SYSADMIN A NOTICE OF THIS NECESSITY!!!

system("/bin/mail -t <<EOF
To: $admin_email
From: pppoe-maintenance@$domain_name
Subject: PPPoE Dropped Connection Restored!



A PPPoE Connection was dropped or was lost. It should now be restored.
The restoration of the line began at:


$start_time -- and finished at -- $stop_time.

Here is the log from this process:

@total_log

END OF REPORT.

EOF
");
################################################## ################################################## ########

} else {

open LOG, ">>$logfile" or die "Cannot open PPP maint log file!
";
print LOG "PPP Check: ".`/bin/date`;
close LOG;
}; #END IF FAILED
} #END WHILE FAIL

print "SUCCEEDED AFTER $attempt ATTEMPTS!
";
} #END SUB CHECKDOWNED


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 03:12 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org