pptp vpn Record user login and traffic information ( turn )

This question has puzzled me for a long time , Finally in the pppd Of man In the document , Found a trail . stay man Medium SCRIPTS There's a series of parameters under , among PEERNAME Is the login user name , And in /etc/ppp/ip-up and /etc/ppp/ip-down Just record it in it ,

Find out ip-up When called, there are command line parameters ,$6 Is the user ip, So in ip-up It's hand-made echo The order was written , Count as pptpd More complete log , There's time in it , There are sources ip, There's a user name , There are assigned ppp Of ip etc.

stay /etc/ppp/ Under the new ip-up and ip-down And add execution permissions
stay ip-up Add the following

#!/bin/sh
echo "##################################" >> /var/log/pptpd.log
echo "Now User $PEERNAME is connected!!!" >> /var/log/pptpd.log
echo "##################################" >> /var/log/pptpd.log
echo "time: `date -d today +%F_%T`" >> /var/log/pptpd.log
echo "clientIP: $6" >> /var/log/pptpd.log
echo "username: $PEERNAME" >> /var/log/pptpd.log
echo "device: $1" >> /var/log/pptpd.log
echo "vpnIP: $4" >> /var/log/pptpd.log
echo "assignIP: $5" >> /var/log/pptpd.log

stay ip-down Add the following

#!/bin/sh
echo "#####################################" >> /var/log/pptpd.log
echo "Now User $PEERNAME is disconnected!!!" >> /var/log/pptpd.log
echo "#####################################" >> /var/log/pptpd.log
echo "time: `date -d today +%F_%T`" >> /var/log/pptpd.log
echo "clientIP: $6" >> /var/log/pptpd.log
echo "username: $PEERNAME" >> /var/log/pptpd.log
echo "device: $1" >> /var/log/pptpd.log
echo "vpnIP: $4" >> /var/log/pptpd.log
echo "assignIP: $5" >> /var/log/pptpd.log
echo "connect time: $CONNECT_TIME s" >> /var/log/pptpd.log
echo "bytes sent: $BYTES_SENT B" >> /var/log/pptpd.log
echo "bytes rcvd: $BYTES_RCVD B" >> /var/log/pptpd.log
sum_bytes=$(($BYTES_SENT+$BYTES_RCVD))
sum=`echo "scale=2;$sum_bytes/1024/1024"|bc`
echo "bytes sum: $sum MB" >> /var/log/pptpd.log
ave=`echo "scale=2;$sum_bytes/1024/$CONNECT_TIME"|bc`
echo "average speed: $ave KB/s" >> /var/log/pptpd.log

Transferred to
http://www.07net01.com/storage_networking/pptpvpnjiluyonghudengluheliuliangxinxi_12317_1346294607.html

pptp Record more related articles about user login log

  1. IOS Development record user login status ,ios Development user login

    IOS Development record user login status ,ios Development user login It was mentioned in the last blog CoreData For data persistence ,CoreData The configuration and use steps of are quite complicated . But familiar with CoreData After the process of using ,CoreDa ...

  2. RabbitMQ Actual combat scene ( One ): Record user operation log asynchronously

    In traditional project development, business process is in serial mode , Executed the module 1—> modular 2–> modular 3 And we know that , This execution process actually has certain disadvantages for the whole program , There are several main points : (1) The waiting time for the execution response of the whole process is relatively long ; ...

  3. IOS Development record user login status

    It was mentioned in the last blog CoreData For data persistence ,CoreData The configuration and use steps of are quite complicated . But familiar with CoreData After the process of using ,CoreData It's still very easy to use . What we want to talk about today is how to record the login of our users ...

  4. springAOP Record user operation log

    The project has been developed , Need to add user operation log , It's not realistic to go back to Canada , So use springAOP It's more appropriate to complete . Annotation tool class : @Retention(RetentionPolicy.RUNTIME) @Tar ...

  5. Spring aop+ Custom annotations uniformly log user behavior

    Write it at the front This article does not cover too much Spring aop Introduction to basic concepts and basic usage , Based on the actual scene use . scene We usually have such a need : Print the specific parameters of the background interface request , Print the final response result of the interface request , And record which user is in what ...

  6. ssm The project records user operation log and exception log

    With the help of online references , Write down the experience of recording operation log !! I use it ssm Project use aop Log : It's used here aop Tangent point of and Custom annotation method : 1. Set up the data table : The fields of database records are : journal id . Operator . operation ...

  7. Record user login information , Do you use PHP How to achieve

    For beginners PHP beginners , Maybe it's difficult . I suggest you take a look at PHP in session The basic meaning of , Friends in need can choose to refer to . Let's take a concrete code example , For your detailed introduction PHP in session To record users ...

  8. Spring AOP Using annotation to record user operation log

    Last method : Core logging method package com.migu.cm.aspect; import com.alibaba.fastjson.JSON; import com.migu.cm.do ...

  9. use jsp Of application Write a record of the number of users who log on to the website

    </head><body><%int i = 0;Object number = application.getAttribute("num");if ...

Random recommendation

  1. C# Divide Chinese and English strings according to the specified length

    There is a need recently : Characters of different lengths sent by players , Need to adapt the number of rows . The initial idea is simple , Directly get the number of characters, average number of lines , recycling string.substring() Just cut . But obviously , Because of the general font , Chinese display width is generally ...

  2. Long article papi、 Mimon 、 After Luo Pang , Where are the opportunities for content entrepreneurship

    One . A year of content app dead , Content lives forever ! 2016 year , The painting style of entrepreneurial circle changes suddenly , I was still arguing yesterday java and PHP Who's the better tech guys . Still dreaming of being the second Steve Jobs product to change the world . Still fooling around with O2O Small bosses sweeping traditional industries ...

  3. linux Next mysql Foundation from installation to basic use

    stay LINUX Lower installation MYSQL # Installation package required ( In order ) libdbi-devel--2.1 libdbi--2.1 libdbi-drivers- perl-DBI-.el5 perl-DBD- ...

  4. JavaScript Throne : On the sword in seven frames

    JavaScript Throne : On the sword in seven frames A week ago ,Throne of JS The conference was held in Toronto , This should be the most anticipated and different conference I have ever attended . According to the official website of the conference : Load the entire page , And then again “ Progressive enhancement ” To add dynamic behavior ...

  5. sax( Used for processing XML Event driven push model ) Analyze the example

    SAX analysis Java The procedure is as follows : import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.SAXParser; impor ...

  6. Quickly build your own database ——mongodb

    In order to simulate a real project online , It has the functions of both front-end and back-end databases , I chose mongodb As database support for the project , Here's something to share mongodb My experience and lessons . mongoddb install Install... Locally Directly through the official website ...

  7. To speed up the compser install and update Methods

    To speed up the compser install and update Methods : Can enter the composer Domestic mirror inside for reference Here are the changes composer.json File to implement ( stay json Add the following code at the end of the configuration ) " ...

  8. reStructuredText File grammar simple learning

    reStructuredText  It's an extension called .rst In plain text , Through a specific interpreter , The ability to output content in text to a specific format 1. Chapter title The head of the chapter is made up of lines ( There can also be online ) And a title with punctuation , One of them is ...

  9. windows How to work with virtual machines linux share

    virtual machine linux And widows Host file sharing Use the shared directory function of the virtual machine Use vmware(vmware workstation 5) Next shared folders Function realization vmware in host And g ...

  10. 【IDEA】【1】 preparation

    1, Official website (https://www.jetbrains.com/idea/) 2, SkyDrive address ( by ideaIU-2018.2.5) link :https://pan.baidu.com/s/1oLgY_Pb ...