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

OPENVPN RESTART SERVICE WITH CRON / OPENVPN REINICIAR SERVIÇO COM CRON

Scheduled Pinned Locked Moved OpenVPN
8 Posts 3 Posters 932 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.
  • R
    rafaelvilelacosta94
    last edited by Nov 30, 2022, 2:19 AM

    I have the following problem.

    some users at home office when they connect to the VPN the connection does not enter, but when I go to the service in pfsense and restart it, the user manages to connect.

    I would like a very simple solution, I am a beginner in pfsense so that cron restarts the service at least once a day at 11PM.

    Can anyone help?


    Estou com o seguinte problema.

    alguns usuários em home office quando vão se conectar a VPN a conexão não entra, porém quando vou no serviço no pfsense e reinicio o mesmo, o usuário consegue se conecta.

    Gostaria de uma solução bem simples, sou iniciante no pfsense para que o cron faça um restart no serviço pelomenos 1 vez no dia ás 11PM.

    Alguem pode ajudar?

    R 1 Reply Last reply Nov 30, 2022, 2:53 AM Reply Quote 0
    • R
      rcoleman-netgate Netgate @rafaelvilelacosta94
      last edited by rcoleman-netgate Nov 30, 2022, 7:59 AM Nov 30, 2022, 2:53 AM

      @rafaelvilelacosta94 said in OPENVPN RESTART SERVICE WITH CRON / OPENVPN REINICIAR SERVIÇO COM CRON:

      when I go to the service in pfsense and restart it, the user manages to connect.

      What does the VPN server log say? Also is this OpenVPN, IPsec, Wireguard, or some other VPN server? I can move this into a topic specifically for your situation.

      Ryan
      Repeat, after me: MESH IS THE DEVIL! MESH IS THE DEVIL!
      Requesting firmware for your Netgate device? https://go.netgate.com
      Switching: Mikrotik, Netgear, Extreme
      Wireless: Aruba, Ubiquiti

      1 Reply Last reply Reply Quote 0
      • R rcoleman-netgate moved this topic from General pfSense Questions on Nov 30, 2022, 7:59 AM
      • R
        rafaelvilelacosta94
        last edited by Nov 30, 2022, 11:20 AM

        I couldn't see the log at the time, but regardless, I wanted a restart of the openvpn service every night. how to do it in a simple way

        1 Reply Last reply Reply Quote 0
        • R
          rafaelvilelacosta94
          last edited by Dec 1, 2022, 12:25 AM

          Can someone give a simple step by step on how to run this openvpn restart?

          G 1 Reply Last reply Dec 1, 2022, 10:42 AM Reply Quote 0
          • G
            Gertjan @rafaelvilelacosta94
            last edited by Gertjan Dec 1, 2022, 10:45 AM Dec 1, 2022, 10:42 AM

            @rafaelvilelacosta94

            Install the pfSense cron package.
            Now you can see all the cron tasks, and add others.

            When I open two console (SSH actually for me) and in the first I goto menu option 8, and use this command :

            tail -f /var/log/openvpn.log
            

            and in the other I enter (command line also, option 8) :

            /etc/rc.openvpn
            

            I can see that my openvpn server gets restarted.
            I'm not using openvpn clients, so I could not test that part.

            Now it's time to study 'cron syntax' add add your own cron task.

            edit :

            I never had to restart my openvpn server.
            Are your users use an IP address - and is it correct ?
            Are they use a host name ? and if so, it 'points' to the correct IP address ?
            Can you see them trying in the openvpn server log, and why is there a fail ?

            No "help me" PM's please. Use the forum, the community will thank you.
            Edit : and where are the logs ??

            R 1 Reply Last reply Dec 1, 2022, 11:55 AM Reply Quote 1
            • R
              rafaelvilelacosta94 @Gertjan
              last edited by Dec 1, 2022, 11:55 AM

              @gertjan in the authentication logs normally.

              What has happened is that in some isolated cases the client cannot connect and I don't have a log at the moment to simulate this situation.

              I can only really see if it happens at the time, however I go and restart OPENVPN from the graphical part and it connects again.

              I just would like to know how by command line I restart openVPN that's all, I'm new with pfsense.

              My questions are:

              1° Which command to stop, start, restart openvpn via command line.

              2° How is the command to be inserted so that I can schedule the restart of openvpn.

              If you can help me I would be grateful.

              G 1 Reply Last reply Dec 1, 2022, 1:34 PM Reply Quote 0
              • G
                Gertjan @rafaelvilelacosta94
                last edited by Gertjan Dec 1, 2022, 1:37 PM Dec 1, 2022, 1:34 PM

                @rafaelvilelacosta94 said in OPENVPN RESTART SERVICE WITH CRON / OPENVPN REINICIAR SERVIÇO COM CRON:

                I go and restart OPENVPN from the graphical part and it connects again

                A OpenVPN server doesn't initiate a connection. It just 'listens'.
                OpenVPN clients, your home workers, initiate the connect.

                @rafaelvilelacosta94 said in OPENVPN RESTART SERVICE WITH CRON / OPENVPN REINICIAR SERVIÇO COM CRON:

                Which command to stop, start, restart openvpn via command line.

                As said :

                /etc/rc.openvpn
                

                I've tried the command.
                It restarted my OpenVPN server.
                Did you tried it for yourself ?

                @rafaelvilelacosta94 said in OPENVPN RESTART SERVICE WITH CRON / OPENVPN REINICIAR SERVIÇO COM CRON:

                2° How is the command to be inserted so that I can schedule the restart of openvpn

                As said earlier, install the cron pfSense package.

                Add this line :

                dd0a62ee-25f4-4a92-8af6-e8669bc20c95-image.png

                Still, you should solve the real problem.
                OpenVPN, like any other serveice running on your pfSense, will run for the eternity. No need to restart unbound, nginx, openvpn, etc etc.
                If you think this is needed, then the issue has to be found, and solved.
                I never found myself lock out of my OpenVPN connection, it always worked just fine for me.
                If my OpenVPN wouldn't work, I have to take the car, and go to my work, and check on site what the issue is. I prefer to stay in bed ^^
                If there was a ISP issue, the connection went down, then, yeah, OpenVPN would work. But not need to go on site, as .... there isn't an Internet access anyway, so nothing to 'repair' or solve.

                No "help me" PM's please. Use the forum, the community will thank you.
                Edit : and where are the logs ??

                1 Reply Last reply Reply Quote 0
                • R
                  rafaelvilelacosta94
                  last edited by Dec 1, 2022, 2:18 PM

                  @gertjan You were very objective.

                  Thank you very much,

                  As I'm starting in PFsense it doesn't cost anything to put this CRON to restart at night.

                  like I mentioned to you very strange, this happens to some person or other and expected.

                  It seems that OPENVPN stops listening to that user, then when I restart it through the GUI, the client connects, but like, there are others connected and everything is working normally.

                  But it's fixed, thanks a lot for your support.

                  1 Reply Last reply Reply Quote 0
                  8 out of 8
                  • First post
                    8/8
                    Last post
                  Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                    This community forum collects and processes your personal information.
                    consent.not_received