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

    Run script whe openvpn is disabled

    Scheduled Pinned Locked Moved OpenVPN
    4 Posts 2 Posters 1.8k 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.
    • K
      kelsen
      last edited by

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

      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.

      1 Reply Last reply Reply Quote 0
      • GruensFroeschliG
        GruensFroeschli
        last edited by

        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.

        eg:
        Add a static route for 10.0.0.0/24 pointing to 172.16.0.2
        When the tunnel is up 10.0.0.0/24 should be routed to the other side of the tunnel (tunnelsubnet 192.168.0.0/29)
        –>custom commands:
        route 10.0.0.0 255.255.255.128; route 10.0.0.128 255.255.255.128

        in the routing table it would look like this:

        IPv4
        Destination Gateway Flags Refs Use Mtu Netif Expire
        10.0.0.0/24 172.16.0.2 UGS 0 0 1500 vr0
        10.0.0.0/25 192.168.0.6 UGS 0 0 1500 tun0
        10.0.0.128/25 192.168.0.6 UGS 0 0 1500 tun0

        We do what we must, because we can.

        Asking questions the smart way: http://www.catb.org/esr/faqs/smart-questions.html

        1 Reply Last reply Reply Quote 0
        • K
          kelsen
          last edited by

          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 10.0.0.10 (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?

          1 Reply Last reply Reply Quote 0
          • GruensFroeschliG
            GruensFroeschli
            last edited by

            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.

            We do what we must, because we can.

            Asking questions the smart way: http://www.catb.org/esr/faqs/smart-questions.html

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.