Openvpn server suspends routing during client-connect script

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Locked
yateya
OpenVpn Newbie
Posts: 3
Joined: Wed Jul 09, 2014 11:28 am

Openvpn server suspends routing during client-connect script

Post by yateya » Wed Jul 09, 2014 11:30 am

I have Openvpn server with multiple client. In the server configurations I use client-connect and client-disconnect script to notify external application on vpn server about connected/disconnected client.

Code: Select all

    client-connect /etc/openvpn/client_status.sh
    client-disconnect /etc/openvpn/client_status.sh
the content of the client_status script is like this:

Code: Select all

    #!/bin/bash
    cd `dirname $0` #switch to directory of client_status.sh
    /usr/local/bin/node client_status --mode=$script_type --ip=$ifconfig_pool_remote_ip --name=$common_name
    exit 0
which executes nodejs script (to serve some JSON apis). The problem started to appear when the script execution time became long (multiple seconds). During this multiple seconds all vpn routing is disabled!

What I did is to solve the porblem is to change script to fork the node process.

Code: Select all

 /usr/local/bin/node client_status --mode=$script_type --ip=$ifconfig_pool_remote_ip --name=$common_name &
(the ampersand at end of line).

Is this a bug in openvpn? I can't find any part in documentation which talk about this.

I am using OpenVPN 2.2.1 on ubuntu 12.04 64bit.

yateya
OpenVpn Newbie
Posts: 3
Joined: Wed Jul 09, 2014 11:28 am

Re: Openvpn server suspends routing during client-connect sc

Post by yateya » Wed Jul 09, 2014 2:20 pm

The problem is not the return value of the client-connect script, as you see it has

Code: Select all

exit 0
at the end of the script. The problem is the duration of the script.

yateya
OpenVpn Newbie
Posts: 3
Joined: Wed Jul 09, 2014 11:28 am

Re: Openvpn server suspends routing during client-connect sc

Post by yateya » Thu Jul 10, 2014 9:46 am

Thanks for your reply. I just want to emphasis that forking new process from the script actually solved the problem; Openvpn server now is not blocked during my client-connect script.

It seems that -as you said- openvpn stops everything (routing, accepting new clients, ...) during the exeution of the client-connect script.

Locked