Solved

ppp server inactivity timeout

Posted on 1998-08-18
8
347 Views
Last Modified: 2013-12-05
I am running pppd-2-2 on Linux 2.0.34, Slackware. How can I
automatically log off and disconnect a user who has no activity for 10 minutes?
0
Comment
Question by:pjoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 

Author Comment

by:pjoo
ID: 1586483
Adjusted points to 200
0
 
LVL 1

Expert Comment

by:bryanjones
ID: 1586484
By killing their PID number through a script.

Here is the begining of the script that you need to create.

who -u | awk '{print $6 , $7}'  -- if the $6 is more than 10 minutes then kill -5 $7
0
 

Author Comment

by:pjoo
ID: 1586485
This will disconnect a user after being connected for x minutes even if the user is actively using the connection. who and
ps shows how long someone has been connected not their
period of inactivity when connected ia ppp. who shows a ppp user as being idle from the moment they connect and the idle time increments from the moment they connect
0
Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

 
LVL 1

Accepted Solution

by:
rocca earned 200 total points
ID: 1586486
We has this same problem and a friend suggested a simple solution which works great.  Just set the inactivity registers in your modem (no changes at all to your PPP setup).  Not all modems support inactivity, but 99% of them do.  For us it was:

AT\T15&W0

.to set a 15 minute timeout.
0
 

Author Comment

by:pjoo
ID: 1586487
Does anyone know about anything in the ppp configuration that specifically
addresses such timeouts? Timeouts are implemented by almost all ISP's
and I really don't think they use the modem timeout.
0
 
LVL 1

Expert Comment

by:rocca
ID: 1586488
Most of the terminal server's have timeout's built into their configuration settings. (such as the USR racks, Livingston, etc) However I have not found anything in the Linux stock PPP server.  There might be a hack out there for it, hmm, sounds like a good project. :-)
0
 
LVL 1

Expert Comment

by:rocca
ID: 1586489
Oh, one other thought.  You could always do it using a setup with greping out the TX/RX packet stats on the output of ifconfig every ten minutes and comparing with the last results to determine idle modems.  Sounds like more work than it's worth though...
0
 
LVL 1

Expert Comment

by:rocca
ID: 2247417
It appears the script got deleted from the history somehow, here is a repost:

#!/usr/bin/perl

# Copyrighted 1999, Peter Rocca <peter@rocca.org>
# Freely usable in commercial and non-commercial environments,
# provided the above copyright remains unaltered.
#
# Legal stuff:
#
# THE AUTHOR ASSUMES NO RESPONSIBILITY FOR ANY BEHAVIOUR
# EXHIBITED BY THIS PROGRAM NOR PROVIDES ANY CLAIMS, OTHER
# THAN TO SAY IT WORKED ON HIS SYSTEM. USERS OF THIS PROGRAM
# ASSUME ALL RISKS AND LIABILITIES.
#
# How to implement:
#
# Run "idlekill kill" in your root's cron however often you
# want to check for idles, for example, if you want to limit
# to 10 minutes idle, then run this program every 10 minutes.
# Please note that the actually idle time may vary upto 2x
# the run rate (if the person goes idle a minute after the
# first check, then the second check reported usage in the
# first period, and on the third check it would disconnect)
#
# How to configure:
#
# This was a quick script made available to the public and
# therefore the configuration is not nicely set at the top
# of the program. Things to check to ensure it works, is
# to make sure you set the $LogLevel to the syslog setting
# you want to log to, check the paths for 'ifconfig', 'ps',
# 'finger', 'kill', 'logger' as found below and also either
# create /usr/local/modems as a directory, or change the
# paths where referenced.

use strict;

my $LogLevel = "local6.info";
my ($x, $Line, $IP, $RX, $TX, $Interface, %Data, %New);

# Load last run statistics
if(open(DATA,"/usr/local/modems/idlekill.dat")) {
  while(<DATA>) {
    chomp;
    ($IP,$TX,$RX) = split(":",$_);
    $Data{$IP} = $TX . ":" . $RX;
  };
  close(DATA);
};

# Determine the PPP interfaces that are up and read their statistics
my @Lines = `/sbin/ifconfig`;
for($x=0; $x<scalar(@Lines); $x++) {
  $Line = $Lines[$x];
  chomp $Line;
  if($Line =~ m/P-t-P:([^ ]*)/) { $IP = $1; }
  elsif($Line =~ m/TX packets:(\d*)/) { $TX = $1; }
  elsif($Line =~ m/RX packets:(\d*)/) { $RX = $1; }
  elsif($Line =~ m/^(ppp\d*)/) { $Interface = $1; }
  elsif($IP) {
    $Line =~ s/ //g;
    if(length($Line)<1) {
      $New{$IP} = $TX . ":" . $RX;
      # If previous stats match our current stats...
      if($Data{$IP} eq $New{$IP}) {
        # Determine the PID of the process
        my ($PID) = split(" ",`ps -ax | grep $IP | grep -v grep`);
        if(!$PID) {
          if(open(FILE,"/var/run/$Interface.pid")) {
            $PID = <FILE>;
            close(FILE);
            chomp $PID;
          };
        };
        if($PID > 0) {
          # Only actually kill the process if 'kill' is a parameter
          if($ARGV[0] =~ m/kill/i) {
            my $Res = `finger | grep $IP`;
            chomp $Res;
            while( $Res =~ s/  / /g ) {};
            $Res .= " $PID";
            system("logger -p $LogLevel -t idlekill \"$Res\"");
            system("kill -9 $PID");
          } else {
            print "No activity on $IP, pid=$PID.\n";
          };
        } else {
          print "Unable to determine PID for $IP (Interface $Interface)\n";
        };
      };
      # Reset for next interface
      $IP = "";
    };
  };
};

# Write new statistics to the data file
if(open(DATA,">/usr/local/modems/idlekill.dat")) {
  foreach $IP (sort keys %New) {
    $Line = join(":",$IP,$New{$IP});
    print DATA "$Line\n";
  };
  close(DATA);
};
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question