I got a nice openvpn server configuration and today I was looking into logs and I just saw the Client Connect Date Time (ex: 15:00:02) its the same as the Client Disconnect Date Time (ex: 15:00:02).
This is bug and I can't figure out how to solve this.
Server.conf
Code: Select all
port 443
proto tcp
dev tun
user nobody
group nogroup
persist-key
persist-tun
keepalive 10 120
topology subnet
management localhost 5555
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
#push "dhcp-option DNS 168.63.129.16"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
push "redirect-gateway def1 bypass-dhcp"
dh none
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf
ecdh-curve prime256v1
tls-crypt tls-crypt.key 0
crl-verify crl.pem
ca ca.crt
cert SERVER_XXX.crt
key SERVER_XXX.key
auth SHA256
cipher AES-128-GCM
ncp-ciphers AES-128-GCM
tls-server
tls-version-min 1.2
tls-cipher TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
client-connect /etc/openvpn/scripts/connect.sh
client-disconnect /etc/openvpn/scripts/disconnect.sh
status /var/log/openvpn/status.log
verb 3
Code: Select all
#!/bin/sh
bytesReceived=$bytes_received
bytesSent=$bytes_sent
user=$common_name
duration=$time_duration
realIp=$trusted_ip
loginDate=$time_ascii
ipVpn=$ifconfig_pool_remote_ip
mysql -u swk -p'PASSWORD' -e "use DATABASE; INSERT INTO logsAuth (userIp, userPublicIp, userName, loginDate) VALUES ('$ipVpn', '$realIp', '$user', '$loginDate'); UPDATE users SET userIp = '$ipVpn', verified = '1' WHERE userName = '$user' ORDER BY ID DESC LIMIT 1;"
Code: Select all
#!/bin/sh
bytesReceived=$bytes_received
bytesSent=$bytes_sent
duration=$time_duration
logoutDate=$time_ascii
user=$common_name
mysql -u swk -p'PASSWORD' -e "use DATABASE; UPDATE logsAuth SET logoutDate = '$logoutDate', durationTime = '$duration', bytesSent = '$bytesSent', bytesReceived = '$bytesReceived' WHERE userName = '$user' ORDER BY ID DESC LIMIT 1;"
The duration time of a client session is right and working well. But the logout date its always the same as the login date, but how?
Mysql row log of client connect/disconnect
Code: Select all
ID userIp userPublicIp userName loginDate LogoutDate Duration Time bytesSent Bytes Received
6 10.8.0.2 83.240.X.X admin Tue Feb 18 16:56:57 2020 Tue Feb 18 16:56:57 2020 37 19629 16777
How can I solve this?
Thanks in advance,
Henrique