What happens when "Save" is clicked on OpenVPN client?



  • I have a client connecting just fine and running fine.  Sometimes the tunnel gets flaky, lots of ping drops and slow speeds.  I've tried lots of things when this happens but by far the one thing that works is opening the client and clicking Save.  I'm wondering what happens in Pfsense when Save is clicked?  I'd like to script something so I need something that can run from a command line.

    I've tried taking down the tunnel interface manually with:
    /sbin/ifconfig vpnc3 down
    /sbin/ifconfig vpnc3 up

    I've tried resetting all networking with:
    /etc/rc.d/netif restart vpnc4 && /etc/rc.d/routing restart

    and I've tried restarting openvpn with:
    echo "" | php -q



  • I was able to figure out a script to replicate the behavior that occurs when the save button is clicked on the client.  This is a little bash script for those who need to restart a client cleanly (i lose 1 ping during the restart).  Save this as a .sh file, chmod +x that file and add it to cron or trigger it however you would like.  I'd like to somehow trigger this by an Apinger Down event, but I don't know how to do that.  Can anyone help with that?

    #Determine the PID of the running client (assumes there is only one)
    clientpid=$(pgrep -lf /openvpn/client | awk '{print $1}')
    
    #Collect path of openvpn and client
    openvpnpath=$(pgrep -lf /openvpn/client | awk '{print $2}')
    clientpath=$(pgrep -lf /openvpn/client | awk '{print $4}')
    
    #Kill client process
    kill $clientpid
    
    sleep 2
    
    #Restart the Client
    $openvpnpath --config $clientpath
    

Log in to reply