用py写的,把日志写到数据库里面,剩下的由管理员操作
由于没有空查看,先复制下来,有空自己试验,修改
Hi all,
I'm tearing my hair out at this at the moment. I have set up a OpenVPN
server to serve as a vpn-gateway to my network
In the config i've defined a client-connect and a client-disconnect script.
When a client connects the client-connect script is run. When that client
disconnects the client-disconnect script is run.
The connect-script works al the time. But the disconnect-script only works
once since the openvpn service is started. After that the log says it
failed exit status 1.
But the weird thing is the scripts are almost the same. One puts a record
in the openvpn.connect table of a Mysql-database the other puts a record
in the openvpn.disconnect table.
Does any of you have the same problem. I tested with openvpn-2.0_rc6 and
openvpn-2.0_rc13.
For your reference i'll put my config and scripts below:
server config:
++++++++++++++++++++
user openvpn
group openvpn
local 192.168.111.111
port 1194
proto udp
dev tap0
persist-tun
keepalive 10 60
comp-lzo
management 127.0.0.1 1195 /etc/openvpn/management.passwd
management-log-cache 1000
mode server
tls-server
ifconfig-pool 192.168.111.112 192.168.111.140 255.255.255.0
max-clients 20
client-connect /etc/openvpn/connect
client-disconnect /etc/openvpn/disconnect
push "dhcp-option DOMAIN mydom.tld"
push "dhcp-option DNS 192.168.111.100"
push "dhcp-option WINS 192.168.111.110"
push "route-gateway 192.168.111.101"
ca /etc/openvpn/cacert.pem
cert /etc/openvpn/OVPN-cert.pem
key /etc/openvpn/OVPN.key
crl-verify /etc/openvpn/crl.pem
tls-auth /etc/openvpn/ta.key 0
dh /etc/openvpn/dh1024.pem
verb 4
status /var/openvpn/openvpn.stat
status-version 1
daemon
++++++++++++++++++++
connect:
++++++++++++++++++++
#! /usr/bin/env python
import MySQLdb,posix,time;
now = time.time()
time = int(now)
# posix.environ['common_name']
# posix.environ['trusted_ip']
# posix.environ['ifconfig_pool_remote_ip']
# posix.environ['ifconfig_pool_netmask']
# posix.environ['local_port']
# posix.environ['trusted_port']
db=MySQLdb.connect(host="localhost",
user="ovpn",
passwd="ovpnpasswd",
db="openvpn")
c = db.cursor()
c.execute("INSERT INTO connect (time, common_name, remote_ip,
pool_remote_ip, pool_netmask, local_port, remote_port) VALUES (%s, %s, %s,
%s, %s, %s,
%s)",(tijd,posix.environ['common_name'],posix.environ['trusted_ip'],posix.environ['ifconfig_pool_remote_ip'],posix.environ['ifconfig_pool_netmask'],posix.environ['local_port'],posix.environ['trusted_port']))
++++++++++++++++++++
disconnect:
++++++++++++++++++++
#! /usr/bin/env python
import MySQLdb,posix,time;
now = time.time()
time = int(now)
# posix.environ['common_name']
# posix.environ['trusted_ip']
# posix.environ['ifconfig_pool_remote_ip']
# posix.environ['ifconfig_pool_netmask']
# posix.environ['local_port']
# posix.environ['trusted_port']
# posix.environ['bytes_sent']
# posix.environ['bytes_received']
db=MySQLdb.connect(host="localhost",
user="ovpn",
passwd="ovpnpasswd",
db="openvpn")
c = db.cursor()
c.execute("""INSERT INTO disconnect (tijd, common_name,
remote_ip, pool_remote_ip, pool_netmask,
local_port, remote_port, bytes_sent, bytes_received) VALUES (%s,
%s, %s,
%s, %s, %s, %s, %s, %s)""",(tijd,posix.environ['common_name'],
posix.environ['trusted_ip'],posix.environ['ifconfig_pool_remote_ip'],
posix.environ['ifconfig_pool_netmask'],
posix.environ['local_port'],posix.environ['trusted_port'],
posix.environ['bytes_sent'],posix.environ['bytes_received']))
++++++++++++++++++++
A piece of log:
++++++++++++++++++++
Feb 15 12:45:17 titan openvpn[10829]: John_Doe/111.133.111.117:1448
[John_Doe] Inactivity timeout (--ping-restart), restarting
Feb 15 12:45:17 titan openvpn[10829]: John_Doe/111.133.111.117:1448
SIGUSR1[soft,ping-restart] received, client-instance restarting
Feb 15 12:45:17 titan openvpn[10829]: client-disconnect command failed:
shell command exited with error status: 1
++++++++++++++++++++
I hope one of you can help me sort this out.
Cheers,
Patrick
____________________________________________
Openvpn-users mailing list
Openvpn-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/openvpn-users