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

How to kill clients from the server side.

Scheduled Pinned Locked Moved OpenVPN
25 Posts 7 Posters 7.3k 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.
  • N Offline
    Naicc
    last edited by Jun 12, 2015, 11:00 AM

    Hi, I’m trying to find a way to kill connection from the Pfsense side.  I tried to use “inactive” command, but idle clients seem to transmit packets all the time even when users are not using workstations. Also tried to play with “ping-restart” and “ping-exit”. Is there a way to stop client from re-connecting when I press “kill client connection”? When someone forgets to close the session from home workstation and then trying to connect from different location I can’t do anything. Thanks.

    1 Reply Last reply Reply Quote 0
    • D Offline
      doktornotor Banned
      last edited by Jun 12, 2015, 11:08 AM

      Block the IP in firewall?

      1 Reply Last reply Reply Quote 0
      • N Offline
        Naicc
        last edited by Jun 12, 2015, 11:17 AM

        @doktornotor:

        Block the IP in firewall?

        That is very "dirty" solution to the problem imo. There is another reason I would like to do it, currently I have rang of 9 IP addresses assigned for OpenVPN and when people forget to disconnect there is no "space" for other users.

        1 Reply Last reply Reply Quote 0
        • D Offline
          doktornotor Banned
          last edited by Jun 12, 2015, 11:28 AM

          We, so raise the limit to more than 9? Really dunno which miracle solution are you expecting. You cannot disable the user itself obviously when your concern is that they cannot connect from another place.

          1 Reply Last reply Reply Quote 0
          • N Offline
            Naicc
            last edited by Jun 12, 2015, 11:42 AM

            Sorry, I don't understand your aggressive post. There is a reason for number of connections, rising that number is not a solution but workaround. I can do that but first I would like to find a better way to do it. If it exists.

            1 Reply Last reply Reply Quote 0
            • D Offline
              doktornotor Banned
              last edited by Jun 12, 2015, 11:51 AM

              Since, as you already determined, your allegedly "inactive" clients are not really inactive and they keep reconnecting anyway. So, you can either block the traffic, or disable the user account or whatever depending on what kind of authentication you are using. So, you dislike the former and cannot do the latter since your goal is not disabling the user. You also do not want to raise the number of allowed connections either for unspecified reason.

              So - open a window and scream "It suxxxxxxxx!!!"…

              1 Reply Last reply Reply Quote 0
              • N Offline
                Naicc
                last edited by Jun 12, 2015, 12:13 PM

                I can see how you manage to have an average 5 posts per day… ::)

                What I don't want to do is:

                • rise the number of connection
                • disable users
                • block the traffic in firewall

                What I want to do is:

                • prevent clients from reconnecting, when killed from gui.

                I have no idea why inactive user is generating traffic, I've tested it, you can connect to VPN, lock the workstation, go for a beer and "Bytes Sent/Bytes Received" keep growing.

                1 Reply Last reply Reply Quote 0
                • J Offline
                  johnpoz LAYER 8 Global Moderator
                  last edited by Jun 12, 2015, 12:28 PM

                  so you kill the connection in gui, so why would the remote client not just reconnect?

                  So you kill the client, when do you want them to be able to reconnect?  Ever, in 24 hours - what?

                  What sort of connections does the client create through the vpn?  Window clients are noisy by nature, they will always be sending stuff out of their interfaces normally.  Do they have mapped drives, there will be discovery stuff like SSDP, announcements for computer browsing service, etc.  how much traffic are you seeing on these "idle" connections?

                  An intelligent man is sometimes forced to be drunk to spend time with his fools
                  If you get confused: Listen to the Music Play
                  Please don't Chat/PM me for help, unless mod related
                  SG-4860 25.07 | Lab VMs 2.8, 25.07

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    Naicc
                    last edited by Jun 12, 2015, 12:55 PM

                    If I could I'd like them never reconnect automatically, ideally user would have to press reconnect or log in again. I just tested, clean installation of Windows, no mapped drive:

                    Connected Since             Bytes Sent         Bytes Received
                    Fri Jun 12 13:42:28 2015        1.83 MB                     270 KB

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      stephenw10 Netgate Administrator
                      last edited by Jun 12, 2015, 12:57 PM

                      I'm not really sure what you could do here. Anything you do to block the client connecting  is going to stop them connecting again which is what you want to avoid.
                      You could perhaps use scheduled rules to block specific clients at night for example. OR scheduling in the authentication maybe.
                      I assume you want to be able to somehow disconnect the VPN such that the users then need to manually reconnect? That sounds like it might be a setting on the client side, disable 'auto-reconnect' or similar. It might cause more problems than it's worth though.  ;)

                      Edit: You answered some of that while I was typing!

                      Steve

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        heper
                        last edited by Jun 12, 2015, 2:30 PM

                        you could try to insert the following in your client configs (it might prevent credentials from being cached and might theoretically stop auto-reconnects)

                        
                        auth-nocache
                        
                        
                        1 Reply Last reply Reply Quote 0
                        • N Offline
                          Naicc
                          last edited by Jun 12, 2015, 2:51 PM

                          OK, I found the solution, that was my lack of knowledge I suppose. What I did:

                          • edited server1.conf and removed "keepalive 10 30"
                          • pushed "ping-exit 10" to the clients

                          Now after 10 seconds from pressing "kill client connection" I can see "connection to XXX was terminated" on the user worksation.

                          1 Reply Last reply Reply Quote 0
                          • C Offline
                            cmb
                            last edited by Jun 12, 2015, 3:17 PM

                            @Naicc:

                            • edited server1.conf and removed "keepalive 10 30"

                            Don't do that. It'll be overwritten, and that part is unnecessary for the ping-exit.

                            @Naicc:

                            • pushed "ping-exit 10" to the clients

                            Now after 10 seconds from pressing "kill client connection" I can see "connection to XXX was terminated" on the user worksation.

                            That works, though it'll potentially be an annoyance for users in that it won't reconnect on its own if there is a temporary loss of connectivity. Not a big deal if the clients are behind reliable Internet connections, but could be very annoying if some of those users are at a hotel or coffee shop or something where connectivity may be a bit spotty from time to time.

                            1 Reply Last reply Reply Quote 0
                            • N Offline
                              Naicc
                              last edited by Jun 12, 2015, 3:29 PM

                              What do you mean by "overwritten"? I just added it back and client is restarting connection on it's own as before. I've tried ping-exit on its own first place but it wasn't working. So I created this thread. As for second part we have 2 servers one for mobile users with 30+ concurrent connections.

                              1 Reply Last reply Reply Quote 0
                              • S Offline
                                stephenw10 Netgate Administrator
                                last edited by Jun 14, 2015, 12:36 PM

                                The conf file is created by the webgui php scripts whenever you make changes to the OpenVPN server. So if you edit the conf file directly any changes you make to it will be lost the next time you make a change via the webgui.
                                Try to use the advanced settings box in the webgui to make any changes that aren't directly covered. Though I'm unsure quite how you might make this particular change if it's already included.

                                Steve

                                1 Reply Last reply Reply Quote 0
                                • N Offline
                                  Naicc
                                  last edited by Jun 15, 2015, 8:43 AM

                                  So is there no way to permanently remove 'keepalive' from the server side? I rarely make changes to OpenVPN settings, I would have to remember to hash that line every time, it's not perfect but doable.

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    doktornotor Banned
                                    last edited by Jun 15, 2015, 8:45 AM

                                    /etc/inc/openvpn.inc

                                    1 Reply Last reply Reply Quote 0
                                    • N Offline
                                      Naicc
                                      last edited by Jun 15, 2015, 9:18 AM

                                      I guess I could just add # to "$conf .= "keepalive 10 60\n";" to minimize risk of breaking it. Thanks doktornotor ;)

                                      1 Reply Last reply Reply Quote 0
                                      • D Offline
                                        doktornotor Banned
                                        last edited by Jun 15, 2015, 9:28 AM

                                        You'd better use //

                                        1 Reply Last reply Reply Quote 0
                                        • N Offline
                                          Naicc
                                          last edited by Jun 15, 2015, 10:06 AM

                                          I was thinking about something like that:

                                          $conf .= "#keepalive 10 60\n";

                                          So it would be "delivered" to config in offline state?

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