Send custom environment variable to OVPN server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dzboot02
    Junior Member
    • Sep 2024
    • 2

    Send custom environment variable to OVPN server

    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:


    Code:
    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:


    Code:
    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.

    Am I missing something? [The documentation][1] is not clear about it either.

    Any help is much appreciated.


    [1]: https://openvpn.net/community-resour...r-openvpn-2-6/
  • dzboot02
    Junior Member
    • Sep 2024
    • 2

    #2
    After a lot of trials and error, I made it work:


    Code:
    setenv UV_TEST test
    setenv UV_TEST2 test2
    setenv SERVERID sid
    push-peer-info

    Pay attention that third variable `SERVERID`, did not make it to the script. Meaning that variables should start with `UV_` for this to work. Thanks OpenVPN documentation for this.

    Comment

    Working...
    😀
    😂
    🥰
    😘
    🤢
    😎
    😞
    😡
    👍
    👎