I have a running OpenVPN server on Ubuntu 22.04.
Everything is working fine, but I want to log more info about connected devices to my server. I need to send some custom info about the device using my servers.
I successfully integrated client-connect
/client-disconnect
scripts, but I want to have more environment variables about the client's device to use in those scripts.
I tried to push these variables from the client config file like this:
push-peer-info
setenv IV_TEST="test1"
setenv UV_TEST="test2"
But I can't recover those variables from the script. In the logs, I can see some variables been transmitted:
2024-09-11 07:31:09 us=326572 192.168.175.1:49395 peer info: IV_VER=3.8.2connect3
2024-09-11 07:31:09 us=326583 192.168.175.1:49395 peer info: IV_PLAT=win
2024-09-11 07:31:09 us=326588 192.168.175.1:49395 peer info: IV_NCP=2
2024-09-11 07:31:09 us=326593 192.168.175.1:49395 peer info: IV_TCPNL=1
2024-09-11 07:31:09 us=326597 192.168.175.1:49395 peer info: IV_PROTO=990
2024-09-11 07:31:09 us=326601 192.168.175.1:49395 peer info: IV_MTU=1600
2024-09-11 07:31:09 us=326605 192.168.175.1:49395 peer info: IV_CIPHERS=xxxxxxxx
2024-09-11 07:31:09 us=326609 192.168.175.1:49395 peer info: UV_ASCLI_VER=3.4.4-3412
2024-09-11 07:31:09 us=326614 192.168.175.1:49395 peer info: UV_PLAT_REL= xxxxxx
2024-09-11 07:31:09 us=326618 192.168.175.1:49395 peer info: UV_UUID=xxxxxxxxxxx
2024-09-11 07:31:09 us=326635 192.168.175.1:49395 peer info: IV_GUI_VER=OCWindows_3.4.4-3412
2024-09-11 07:31:09 us=326638 192.168.175.1:49395 peer info: IV_SSO=webauth,crtext
2024-09-11 07:31:09 us=326641 192.168.175.1:49395 peer info: IV_HWADDR=xxxxxxxxxxx
2024-09-11 07:31:09 us=326645 192.168.175.1:49395 peer info: IV_SSL=OpenSSL_3.1.4_24_Oct_2023
But not the variables I have set.
Checking out the documentation we can see this:
EDIT1:
--push-peer-info : Push additional information about the client to server. The following data is always pushed to the server:
This implies that using --push-peer-info
, we can allow client to push additional custom variables, besides the default ones, but how to accomplish that?
EDIT2: I even tried overriding default variables and changing the order, no luck:
setenv IV_HWADDR="test1"
push-peer-info
Any help is much appreciated.
After a lot of trials and error, I made it work:
Pay attention that third variable
SERVERID
, did not make it to the script. Meaning that variables should start withUV_
for this to work. Thanks OpenVPN documentation for this.