OpenVPN added script to log log

Source: Internet
Author: User
Tags chmod log log
OpenVPN Increase the script for logging user log
Cat connect.sh
#!/bin/bash

time= ' Date +%f '
if [-f/etc/openvpn/log/openvpn_$time.log];then touch
  / Etc/openvpn/log/openvpn_$time.log
  echo "' Date ' +%f%h:%m:%s ' User $common _name trust_ip $trusted _ip is login, REMOTE_IP is $ifconfig _pool_remote_ip, Mask is $route _netmask_1 ">>/etc/openvpn/log/openvpn_$time.log
Else
  touch/etc/openvpn/log/openvpn_$time.log
  echo "' Date ' +%f%h:%m:%s ' User $common _name trust_ip $trusted _ip is LOGIN,REMOTE_IP is $ifconfig _pool_remote_ip, Mask is $route _netmask_1 ">>/etc/openvpn/log/openvpn_$time.log
fi
OpenVPN Increase the number of scripts that log users out of login log
Cat disconnect.sh 
#!/bin/bash

time= ' Date +%f '
if [-f/etc/openvpn/log/openvpn_$time.log];then
  Touch/etc/openvpn/log/openvpn_$time.log
  echo "' Date ' +%f%h:%m:%s ' User $common _name trust_ip $trusted _ip is LOGOUT,REMOTE_IP is $ifconfig _pool_remote_ip, Mask is $route _netmask_1 ">>/etc/openvpn/log/openvpn_$time.log
  else
  touch/etc/openvpn/log/openvpn_$time.log
  echo "' Date ' +%f%h:%m:%s ' User $common _name trust_ip $ TRUSTED_IP is logout,remote_ip are $ifconfig _pool_remote_ip, Mask is $route _netmask_1 ">>/etc/openvpn/log/openvpn _$time.log
fi
Modify OpenVPN Configuration
Vim server.conf
client-connect/etc/openvpn/connect.sh
client-disconnect/etc/openvpn/disconnect.sh
Service OpenVPN Restart
chmod 755  /etc/openvpn/connect.sh
chmod  755/etc/openvpn/ disconnect.sh
View Log
Cat Log/openvpn_2017-07-11.log 
2017-07-11 14:10:34 User test trust_ip 116.231.149.194 is Logout,remote_ip is  10.8.8.5, Mask is 255.255.255.0
2017-07-11 14:10:34-User test trust_ip 116.231.149.194 is Login,remote_ip is 10.8.8.5 Mask is 255.255.255.0

Starter: http://thedream.blog.51cto.com/6427769/1946317

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.