Solved

ppp server inactivity timeout

Posted on 1998-08-18
8
339 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

After running Ubuntu some time, you will be asked to download updates for fixing bugs and security updates. All the packages you download replace the previous ones, except for the kernel, also called "linux-image". This is due to the fact that w…
If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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