Run script whe openvpn is disabled

  • I've tried to run a script when openvpn goes down, like:
    down '/var/etc/openvpn/'

    This script simple add a route, but openvpn logs show this warning:
    Failed running command (–up/--down): could not execute external program

    The script is executable, have no error and root is the owner.

  • Not sure if i understand what you are trying to do.
    What is your final goal?
    If you want to add a route when the tunnel goes down:

    Create a static route and add the same route as two higher-prioritised routes to the "custom commands" field.

    Add a static route for pointing to
    When the tunnel is up should be routed to the other side of the tunnel (tunnelsubnet
    –>custom commands:
    route; route

    in the routing table it would look like this:

    Destination Gateway Flags Refs Use Mtu Netif Expire UGS 0 0 1500 vr0 UGS 0 0 1500 tun0 UGS 0 0 1500 tun0

  • I want to add a route to an MPLS when openvpn goes down.
    Your explanation looks right, i was thinking, how the pfsense will route packets to (for example)if there is two route for the same subnet?
    then I remembered that routers use more especific route first.

    thank you GruensFroeschli, it's resolved for me, but i believe that others may try to call an script for other reasons and get same error, someone can explain why this happen?

  • I don't really know why you had problems. I never really needed up/down scripts on a pfSense yet.
    On linux i once had similar problems but they were actual bugs in OpenVPN itself which i solved by using a different version of OpenVPN.

Log in to reply