在/etc/ppp/下新建ip-up和ip-down的脚本(本来就有)并且添加执行权限
在ip-up中加入以下内容
#!/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
在ip-down中加入以下内容
#!/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
然后service pptpd restart就好啦
在/var/log/pptpd.log就看到啦!