Navigation

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

    [SOLVED] Restart OpenVPN via Cron Every Night

    OpenVPN
    4
    7
    4927
    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.
    • A
      archedraft last edited by

      Hello, I have 2 OpenVPN servers setup and 2 OpenVPN clients setup. I would like cron to restart ovpnc2 cleint interface every night but I only would like that this interface to restart. Is there a command only target that one openvpn client?

      I found this command listed but I would guess that it restarts all the open servers and cleints?

      #!/usr/local/bin/php -q

      1 Reply Last reply Reply Quote 0
      • jimp
        jimp Rebel Alliance Developer Netgate last edited by

        Here's the easiest way:

        First find the server you need to restart:

        : ps uxawww | grep openvpn
        root    25984 0.0  0.9 13496  4340  ??  Ss  Thu06PM  0:09.08 /usr/local/sbin/openvpn –config /var/etc/openvpn/server1.conf
        root    32393  0.0  0.9 13496  4492  ??  Ss  Thu06PM  0:01.75 /usr/local/sbin/openvpn –config /var/etc/openvpn/server2.conf

        Then run this script to restart just that one

        : /usr/local/sbin/pfSsh.php playback svc restart openvpn server 1

        Starting the pfSense shell system…............

        Attempting to issue restart to openvpn service...

        openvpn has been restarted.

        Note that only server 1 restarted:

        : ps uxawww | grep openvpn
        root    32393  0.0  0.9 13496  4492  ??  Ss  Thu06PM  0:01.75 /usr/local/sbin/openvpn –config /var/etc/openvpn/server2.conf
        root    32933  0.0  0.9 13496  4624  ??  Ss    4:18PM  0:00.00 /usr/local/sbin/openvpn –config /var/etc/openvpn/server1.conf

        1 Reply Last reply Reply Quote 1
        • A
          archedraft last edited by

          Perfect! Thanks jimp!

          1 Reply Last reply Reply Quote 0
          • J
            Jim Coogan last edited by

            While this was a great solution for my open VPN problem it made Avahi restart on pfsense even though it wasn't bound to openvpn interfaces and this caused homekit on ios / mac to often show accessories (in a different vlan and relying on avahi) as inaccessible for 20 + seconds after a restart upon first trying to use home app.

            B 1 Reply Last reply Reply Quote 0
            • B
              Bambos @Jim Coogan last edited by

              @jim-coogan today i had OpenVPN service stopped after ISP restart (disconnection on WAN), and stay stopped for 12 hours. I had to go on-site to press start service again.

              Is there any way to cron restart services from pfsense ?

              J 1 Reply Last reply Reply Quote 1
              • J
                Jim Coogan @Bambos last edited by

                @bambos yeah there is a cron package you can add in the package manager and then like this 2nd post here describes you can set it up to restart on whatever schedule you want.

                B 1 Reply Last reply Reply Quote 0
                • B
                  Bambos @Jim Coogan last edited by

                  @jim-coogan thank you my friend. seems watchdog is easier package for that purpose, allows to monitor active services by selection and monitors, restarts, and notify without commands. Looks like a good start. Thank you for your comments.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post

                  Products

                  • Platform Overview
                  • TNSR
                  • pfSense
                  • Appliances

                  Services

                  • Training
                  • Professional Services

                  Support

                  • Subscription Plans
                  • Contact Support
                  • Product Lifecycle
                  • Documentation

                  News

                  • Media Coverage
                  • Press
                  • Events

                  Resources

                  • Blog
                  • FAQ
                  • Find a Partner
                  • Resource Library
                  • Security Information

                  Company

                  • About Us
                  • Careers
                  • Partners
                  • Contact Us
                  • Legal
                  Our Mission

                  We provide leading-edge network security at a fair price - regardless of organizational size or network sophistication. We believe that an open-source security model offers disruptive pricing along with the agility required to quickly address emerging threats.

                  Subscribe to our Newsletter

                  Product information, software announcements, and special offers. See our newsletter archive to sign up for future newsletters and to read past announcements.

                  © 2021 Rubicon Communications, LLC | Privacy Policy