Linux PPTPD limit single account session limit and login log (improved version)

Source: Internet
Author: User

Original http://www.cnblogs.com/niusys/p/4204360.html

Original one of the shortages has already been spat.

The result of this single-user implementation is that two people kicked to kick the ~~

The second is not clean after disconnection pptpd-users the following users ,

may cause users to log on after they Kill Drop the original PID,

if the PID already assigned to other processes. , the innocent process will be turned off.

improved the above two issues , and add the login log function to the Internet .


Vi/etc/ppp/auth-up

#!/bin/sh  # get the username/ppp line number from the  parameters    realdevice=$1    user=$2# create the  directory to keep pid files per user    test -d / var/run/pptpd-users |mkdir -p /var/run/pptpd-usersrestrict_mode=2#  mode 1  :#  if there is a session already for this user,  Terminate the old one#  mode 2 :#   prevent a new   login for same user    if [ -f /var/run/ pptpd-users/$USER  ]; then        case  $restrict _mode  IN             1)  kill -HUP   ' cat /var/run/pptpd-users/$USER ';;             2)  kill -HUP  ' cat  /var/run/$REALDEVICE. PID '  ;;             *)  : ;;         esac    fi

v I /etc/ppp/ip-up.local

#!/bin/sh# copy  the pid file of current user to /var/run/ pptpd-users  cp  "/var/run/$1.pid"   /var/run/pptpd-users/$PEERNAME  echo    "##################################"  >> /var/log/pptpd.logecho   "Now user   $PEERNAME  is connected!!! "  >> /var/log/pptpd.logecho   "##################################"  >>  /var/log/pptpd.logecho   "time:  ' date -d today +%f_%t '"  >> /var/ log/pptpd.logecho   "clientip: $6"  >> /var/log/pptpd.logecho   " username:  $PEERNAME " >> /var/log/pptpd.logecho  " device: $1 " >>  /var/log/pptpd.logecho   "Vpnip: $4"  >> /var/log/pptpd.logecho   "Assignip: $5"  >> /var/log/pptpd.log


Vi/etc/ppp/ip-down.local

#!/bin/shecho   "#####################################"  >> /var/log/pptpd.logecho    "now user  $PEERNAME  is disconnected!!!"  >> /var/log/pptpd.logecho   "#####################################"  >>  /var/log/pptpd.logecho   "time:  ' date -d today +%f_%t '"  >>  /var/log/pptpd.logecho   "clientip: $6"  >> /var/log/pptpd.logecho   " username:  $PEERNAME " >> /var/log/pptpd.logecho  " device: $1 " >>  /var/log/pptpd.logecho   "Vpnip: $4"  >> /var/log/pptpd.logecho   "Assignip: $5"  >> /var/log/pptpd.logecho   "connect time:  $CONNECT _ Time s " >> /var/log/pptpd.logecho  " bytes sent:  $BYTES _sent b "  >> /var/log/pptpd.logecho   "Bytes rcvd:  $BYTES _rcvd b " >> /var/log/pptpd.logsum_bytes=$ (($BYTES _sent+ $BYTES _RCVD)) sum= ' echo   ' scale=2; $sum _bytes/1024/1024 "|bc ' echo  " bytes sum:  $sum  mb "  >> /var/log/pptpd.logave= ' echo   ' scale=2, $sum _bytes/1024/$CONNECT _time "|BC ' echo    "average speed:  $ave  kb/s"  >> /var/log/pptpd.log rm -f   /var/run/pptpd-users/$PEERNAME


chmoda+x/etc/ppp/*

The process is as follows:

1. User login to determine if there is a/var/run/pptpd-users/user name file

2. If there is a smooth restart of this VPN user process, if the file is not created, the text contains the user process ID

3. ( selectable mode 1 or mode 2)

Mode 1 The old connection was kicked off , A new connection can be used

Mode 2 Log In First Session Stay Online , block logon after


Linux PPTPD limit single account session limit and login log (improved version)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.