Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

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

    Scheduled Pinned Locked Moved OpenVPN
    2 Posts 1 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      ckraimer
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • C
        ckraimer
        last edited by

        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
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.