pptpd PPP VPN LOG

vpn 服务,但通过last查看的时候,只有登录的IP信息,

 
无法查看VPN客户端登录的用户名,登录地址,断开时间等信息。
 
请同事写了两个脚本。用于记录登录信息及登出信息。记一下,以备后用
 
修改ip-up ,ip-down文件,增加以下内容(export PATH 行后面),将日志信息记录到
/var/log/pptpd.log文件 中
 
vim /etc/ppp/ip-up 

echo "" >> /var/log/pptpd.log 
echo "IP UP        \ 
    `date -d today +%F_%T`        \ 
$6        \ 
$PEERNAME        \ 
$1        \ 
$5" >> /var/log/pptpd.log
 
vim /etc/ppp/ip-down文件。ip-down写入pptpd.log与最后一个 ip-up进行配对,以方便查看
 
 

 

tac /var/log/pptpd.log | while read line 
do 
        _tmphead=$(echo $line | cut -d" " -f1,2) 
        _tmptime=$(echo $line | cut -d" " -f3) 
        _tmpuser=$(echo $line | cut -d" " -f5) 
        if [ "IP UP" = "$_tmphead" -a "$PEERNAME" = "$_tmpuser" ] 
        then 
                _rep_line="$line" 
                sed -i "s/$line/$_rep_line\nIP DOWN        \ 
`date -d today +%F_%T`        \ 
$6        \ 
$PEERNAME        \ 
$1        \ 
$5/" /var/log/pptpd.log 
                break 
        fi 
done

Last modified onSaturday, 05 January 2013 10:06

Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169
  • Published in VPN
  • Read 3156 times

Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
back to top