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

Email Notification - OpenVPN Client Connect (Common Name)

OpenVPN
20
138
39.1k
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.
  • S
    Stewart @Gertjan
    last edited by Sep 8, 2021, 7:28 PM

    @gertjan said in Email Notification - OpenVPN Client Connect (Common Name):

    @stewart said in Email Notification - OpenVPN Client Connect (Common Name):

    kinda old

    Nothing changed.

    I only mentioned it because I'm always wary of necroposting and people getting upset. I'm sure it isn't the scripts themselves. Even if I have client-connect and client-disconnect call the same script the delay is still there. Would it matter if the OpenVPN server is set to Remote Access (SSL/TLS + User Auth) and authenticated by the Active Directory?

    G 1 Reply Last reply Sep 9, 2021, 7:26 AM Reply Quote 0
    • G
      Gertjan @Stewart
      last edited by Sep 9, 2021, 7:26 AM

      @stewart said in Email Notification - OpenVPN Client Connect (Common Name):

      Even if I have client-connect and client-disconnect call the same script the delay is still there.

      I was using the same file for the connect / disconnect event, but @bingo600 has a point - see above.
      The OpenVPN connect and disconnect are instantaneously for me.

      I'm using myself SSL/TLS only.
      Authentication (using AD) only happens when the user logs in.

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

      S 1 Reply Last reply Sep 9, 2021, 1:31 PM Reply Quote 0
      • S
        Stewart @Gertjan
        last edited by Sep 9, 2021, 1:31 PM

        @gertjan

        I'm using different scripts for each event but tried it with the same script to rule it out.

        1 Reply Last reply Reply Quote 0
        • S
          Stewart
          last edited by Sep 9, 2021, 8:03 PM

          Progress! I've found that if I add
          explicit-exit-notify
          to the client then it populates immediately. I guess that without it then it's waiting for a timeout period before it disconnects the session.

          Since we have a lot of clients out there already, is there a way to add this to the VPN server config? Or does it have to be manually entered into every client? I've tried adding into the server Custom Options but it doesn't work.

          G J 2 Replies Last reply Sep 10, 2021, 7:20 AM Reply Quote 0
          • G
            Gertjan @Stewart
            last edited by Sep 10, 2021, 7:20 AM

            @stewart said in Email Notification - OpenVPN Client Connect (Common Name):

            Progress! I've found that if I add
            explicit-exit-notify
            to the client then it populates immediately.

            Client ?
            These are OpenVPN server 'custom' command options.
            At least, they are in the context of this forum thread.
            You can see the doc here : https://build.openvpn.net/man/openvpn-2.5/openvpn.8.html

            You are using OpenVPN 2.5.x, right ? And UDP tunnnels ?

            @stewart said in Email Notification - OpenVPN Client Connect (Common Name):

            I've tried adding into the server Custom Options but it doesn't work.

            As above, see again :

            login-to-view

            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
            • J
              JeGr LAYER 8 Moderator @Stewart
              last edited by Sep 10, 2021, 7:30 AM

              @stewart said in Email Notification - OpenVPN Client Connect (Common Name):

              Progress! I've found that if I add
              explicit-exit-notify
              to the client then it populates immediately. I guess that without it then it's waiting for a timeout period before it disconnects the session.

              It is. For UDP clients you have to wait your configured timeout period (normally ~60-90s) for the disconnect script to get executed as the server doesn't see the client disconnecting. Explicit-exit-notify on the client fixes that by alerting the server of the clients disconnect wish.

              Don't forget to upvote 👍 those who kindly offered their time and brainpower to help you!

              If you're interested, I'm available to discuss details of German-speaking paid support (for companies) if needed.

              G 1 Reply Last reply Sep 10, 2021, 7:43 AM Reply Quote 1
              • G
                Gertjan @JeGr
                last edited by Sep 10, 2021, 7:43 AM

                @jegr Aha !! I get it.
                I was disconnecting manually my client, by sliding the on/off button in the client while testing.
                That probably makes the sending a "connection down" to the server, so there were no delays for me doing such a test.

                When the client looses the connection because of bad data reception (Wifi or data carrier like 4G5G) then the server would apply a wait period before it fires a "client-disconnect" cmd.

                @JeGr Thanks for making that clear.

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

                J 1 Reply Last reply Sep 10, 2021, 7:57 AM Reply Quote 0
                • J
                  JeGr LAYER 8 Moderator @Gertjan
                  last edited by Sep 10, 2021, 7:57 AM

                  @gertjan said in Email Notification - OpenVPN Client Connect (Common Name):

                  I was disconnecting manually my client, by sliding the on/off button in the client while testing.

                  Yes, but without explicit-exit-notify UDP clients don't inform the server of their disconnect. So the server just stops getting traffic, waits for the tiemeout/keepalive time and then internally de-registers the client as unavailable/disconnected and runs the script.
                  TCP clients don't have that problem because of TCP (d'uh! ;)) and explicit-exit-notify brings that to UDP - but with its own problems (e.g. mixed style multi-configs with udp&tcp remote statements for automatic fallback etc. aren't possible ATM).

                  As I did a bit of an updated version of that script for noplan, I tested around that myself and could see that behavior every time. One just has to be patient :)

                  Cheers
                  \jens

                  Don't forget to upvote 👍 those who kindly offered their time and brainpower to help you!

                  If you're interested, I'm available to discuss details of German-speaking paid support (for companies) if needed.

                  G S 2 Replies Last reply Sep 10, 2021, 8:22 AM Reply Quote 0
                  • G
                    Gertjan @JeGr
                    last edited by Sep 10, 2021, 8:22 AM

                    @jegr said in Email Notification - OpenVPN Client Connect (Common Name):

                    Yes, but without explicit-exit-notify UDP clients don't inform the server of their disconnect

                    See above what I have in the custom options.
                    My connection plain vanilla : is UDP based, port 1194 etc.

                    I connect, I wait 20+ seconds, and then I slide the connection connection on my iPhone - OpenVPN Connect App to off, I see this line immediately in the pfSense OpenVPN server log :

                    login-to-view

                    You can clearly see the 25 seconds delay.

                    gmail also notifies me immediately on both events.

                    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
                    • S
                      Stewart @JeGr
                      last edited by Sep 10, 2021, 1:13 PM

                      @jegr said in Email Notification - OpenVPN Client Connect (Common Name):

                      @gertjan said in Email Notification - OpenVPN Client Connect (Common Name):

                      I was disconnecting manually my client, by sliding the on/off button in the client while testing.

                      Yes, but without explicit-exit-notify UDP clients don't inform the server of their disconnect. So the server just stops getting traffic, waits for the tiemeout/keepalive time and then internally de-registers the client as unavailable/disconnected and runs the script.
                      TCP clients don't have that problem because of TCP (d'uh! ;)) and explicit-exit-notify brings that to UDP - but with its own problems (e.g. mixed style multi-configs with udp&tcp remote statements for automatic fallback etc. aren't possible ATM).

                      As I did a bit of an updated version of that script for noplan, I tested around that myself and could see that behavior every time. One just has to be patient :)

                      Cheers
                      \jens

                      My problem with being patient is that while waiting no other script will launch. So if someone connects or disconnects within that 90 second window (or whatever that window may be) the scripts don't launch. At least, that's what it appears is happening. I don't see a reason why it would be that way, though.

                      N 1 Reply Last reply Sep 13, 2021, 12:23 PM Reply Quote 0
                      • N
                        noplan @Stewart
                        last edited by Sep 13, 2021, 12:23 PM

                        @stewart said in Email Notification - OpenVPN Client Connect (Common Name):

                        while waiting no other script will launch. So if someone connects or disconnects within that 90 second window (or whatever that window may be) the scripts don't launch.

                        r u sure ?
                        cuz we don't see it ... have tested after reading your post ... can't confirm it.
                        brNP

                        S 1 Reply Last reply Sep 13, 2021, 1:29 PM Reply Quote 0
                        • S
                          Stewart @noplan
                          last edited by Sep 13, 2021, 1:29 PM

                          @noplan said in Email Notification - OpenVPN Client Connect (Common Name):

                          @stewart said in Email Notification - OpenVPN Client Connect (Common Name):

                          while waiting no other script will launch. So if someone connects or disconnects within that 90 second window (or whatever that window may be) the scripts don't launch.

                          r u sure ?
                          cuz we don't see it ... have tested after reading your post ... can't confirm it.
                          brNP

                          Maybe it's because I'm using the same user over and over to test? When I connect the first time the log gets generated (I have the script writing to a log file instead of emailing). After that, I can connect and disconnect and no other lines are written to the log file. Not even the first disconnect gets written. If I wait until after the disconnect line gets written then I can connect and the line gets logged.

                          N A 2 Replies Last reply Sep 13, 2021, 1:46 PM Reply Quote 0
                          • N
                            noplan @Stewart
                            last edited by Sep 13, 2021, 1:46 PM

                            @stewart

                            sounds interesting

                            a) use a 2nd user
                            b) connect with user 1
                            c) connect with user 2 when user 1 is connected
                            d) disconnect user 1
                            e) shortly after done d) disconnect user 2

                            both users are written in your file ?

                            be so kind and show us logFile and script
                            brNP

                            S 1 Reply Last reply Sep 13, 2021, 2:13 PM Reply Quote 0
                            • A
                              Armstrong @Stewart
                              last edited by Sep 13, 2021, 2:08 PM

                              @stewart

                              Are you perhaps experiencing the same thing I was in this post https://forum.netgate.com/post/897352 ?

                              The disconnect lags well behind the actual disconnection.

                              S 1 Reply Last reply Sep 13, 2021, 2:14 PM Reply Quote 0
                              • S
                                Stewart @noplan
                                last edited by Sep 13, 2021, 2:13 PM

                                @noplan said in Email Notification - OpenVPN Client Connect (Common Name):

                                @stewart

                                sounds interesting

                                a) use a 2nd user
                                b) connect with user 1
                                c) connect with user 2 when user 1 is connected
                                d) disconnect user 1
                                e) shortly after done d) disconnect user 2

                                both users are written in your file ?

                                be so kind and show us logFile and script
                                brNP

                                I'll get a second pc up and running to test with. It'll take a few.

                                S 1 Reply Last reply Sep 13, 2021, 3:12 PM Reply Quote 0
                                • S
                                  Stewart @Armstrong
                                  last edited by Sep 13, 2021, 2:14 PM

                                  @armstrong said in Email Notification - OpenVPN Client Connect (Common Name):

                                  @stewart

                                  Are you perhaps experiencing the same thing I was in this post https://forum.netgate.com/post/897352 ?

                                  The disconnect lags well behind the actual disconnection.

                                  Yes and no. Yes, I'm experiencing it and it can be resolved by adding explicit-exit-notify to the client. No, in that the issue I'm dealing with is that during that delay it seems like no scripts are running.

                                  N 1 Reply Last reply Sep 13, 2021, 2:52 PM Reply Quote 0
                                  • N
                                    noplan @Stewart
                                    last edited by Sep 13, 2021, 2:52 PM

                                    for me this whole case is pretty interesting
                                    because we're using this script like a ton of admins too to get information on the openVPN usage
                                    and noOne except @JeGr (as always 🤡 ) was looking for

                                    but without explicit-exit-notify UDP clients don't inform the server of their disconnect

                                    so plz keep us posted with all the details you got
                                    NP

                                    S 1 Reply Last reply Sep 15, 2021, 5:21 PM Reply Quote 0
                                    • S
                                      Stewart @Stewart
                                      last edited by Sep 13, 2021, 3:12 PM

                                      @stewart said in Email Notification - OpenVPN Client Connect (Common Name):

                                      @noplan said in Email Notification - OpenVPN Client Connect (Common Name):

                                      @stewart

                                      sounds interesting

                                      a) use a 2nd user
                                      b) connect with user 1
                                      c) connect with user 2 when user 1 is connected
                                      d) disconnect user 1
                                      e) shortly after done d) disconnect user 2

                                      both users are written in your file ?

                                      be so kind and show us logFile and script
                                      brNP

                                      I'll get a second pc up and running to test with. It'll take a few.

                                      I can confirm that the logging only affects that account. I simulated with a second PC. Had it connect and then disconnect. While waiting, I had the first machine connect and disconnect. It shows all of the logs as expected. It seems the lack of processing is limited to that one account.

                                      N 1 Reply Last reply Sep 13, 2021, 3:58 PM Reply Quote 0
                                      • N
                                        noplan @Stewart
                                        last edited by Sep 13, 2021, 3:58 PM

                                        @stewart

                                        strange...

                                        But good news for us that everything is works as expected

                                        1 Reply Last reply Reply Quote 0
                                        • viktor_gV
                                          viktor_g Netgate
                                          last edited by Sep 15, 2021, 11:44 AM

                                          You can create a feature request for this:
                                          https://docs.netgate.com/pfsense/en/latest/development/feature-requests.html

                                          N 1 Reply Last reply Sep 15, 2021, 11:56 AM Reply Quote 0
                                          91 out of 138
                                          • First post
                                            91/138
                                            Last post
                                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.