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

    OpenVPN Client Cascade

    Scheduled Pinned Locked Moved OpenVPN
    48 Posts 3 Posters 5.4k 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.
    • stephenw10S
      stephenw10 Netgate Administrator
      last edited by stephenw10

      I mean if you look at the states for port 1149 (:1149) on WAN you should only see the T3 client.

      Check the logs to see what the T2 client is doing. It should be trying to connect on the T3 client interface. If it isn't what is it doing? Did it error out trying to connect before T3 had connected and stop?

      Steve

      1 Reply Last reply Reply Quote 0
      • J
        John2893ax
        last edited by

        Sorry for the stupid questions, but are floating rules for t1 and t2 correct?

        Only the T3 server IP should be seen as an outbound connection on WAN.

        Does this refer to floating t2 rule or to a new one with t3?

        I mean if you look at the states for port 1149 (:1149) on WAN you should only see the T3 client.

        Here is the output:

        3dba7c21-6206-4c70-ada4-2288e24ecd8b-grafik.png

        556d22d9-48e9-489c-a370-181c71989fb6-grafik.png

        Check the logs to see what the T2 client is doing. It should be trying to connect on the T3 client interface.

        At Diagnostics-> States?

        95b8dcea-f476-4c15-a01c-ff0e44da7a4e-grafik.png

        The same is also for T3.

        Does that mean that all 3 tunnels run parallel and not tunnel through tunnel?

        1 Reply Last reply Reply Quote 0
        • J
          John2893ax
          last edited by John2893ax

          Edit:

          Different city clients seem to work better than a group of clients from one city.

          I currently have the following servers:

          Screenshot_2020-10-29 pfSense localdomain - VPN OpenVPN Clients.png

          When I restart pfSense, I get completely different results than when I start the servers manually.

          1. the 2 floating rules work

          Screenshot_2020-10-29 pfSense localdomain - Firewall Rules Floating.png

          1. T1 and T2 shows only ICMP protocol.

          Screenshot_2020-10-29 pfSense localdomain - Diagnostics States States.png

          Screenshot_2020-10-29 pfSense localdomain - Diagnostics States States(1).png

          1. The traffic goes through T3, but there is no internet connection

          When I manually restart the clients, the servers do not start again.

          1 Reply Last reply Reply Quote 0
          • J
            John2893ax
            last edited by

            Edit2:

            Maybe I have to set the routes manually in the OpenVPN client under "Remote Network(s)"?

            Like for example here?

            53c77d11-aa12-433b-91fb-15f4c08e5b25-grafik.png

            Screenshot_2020-10-29 pfSense localdomain - Diagnostics Routes.png

            But which settings would I then have to set for T3?

            677121fc-7c4f-449b-9f7a-dac83972f660-grafik.png

            1 Reply Last reply Reply Quote 0
            • stephenw10S
              stephenw10 Netgate Administrator
              last edited by

              Did you set the direction as OUT on those floating rules?

              Did you reset the state table or reboot since you added them?

              You have at least one state on WAN that should have been rejected by that outbound floating rule.

              You should not see any states on WAN foe OpenVPN tunnels except tunnel 3.

              The fact they are up means they are not running tunnel-in-tunnel as you say.

              Steve

              1 Reply Last reply Reply Quote 0
              • J
                John2893ax
                last edited by John2893ax

                Did you set the direction as OUT on those floating rules?

                Yes.

                Did you reset the state table or reboot since you added them?

                I always enabled "Reset the firewall state table" under Diagnostics/States/Reset States and pressed [Reset]. In any case I assumed that it would work. Only with a reboot the floating rules and the start of the tunnel sequence worked simultaneously.

                You should not see any states on WAN foe OpenVPN tunnels except tunnel 3.

                Without remote network(s) entries in the OpenVPN client I see all 3 servers under States/WAN. So they are not running tunnel in tunnel.

                But I have to test again if with remote network(s) only the third server is visible.

                1 Reply Last reply Reply Quote 0
                • J
                  John2893ax
                  last edited by

                  OK. Whether with or without remote network(s) makes no difference.

                  b3e92805-a2b8-4fd5-b461-43d9a72c9744-grafik.png

                  The rules in the image currently do the following after a reboot:

                  1. Under States/WAN I only see T3.

                  Screenshot_2020-10-29 pfSense localdomain - Diagnostics States States.png

                  1. Under States/T2 I see nothing.

                  2. Under States/T3 I see T1 and T2. I do not know if this is correct.

                  Screenshot_2020-10-29 pfSense localdomain - Diagnostics States States(1).png

                  1. There is no internet connection with floating rules.

                  Do I understand correctly that the rules must look like this?

                  • Under States/WAN I should see T3.
                  • Under States/T1 I should see T2.
                  • Under States/T2 I should see T3.
                  • Under States/T3 I should see WAN.

                  Would that be correct?

                  1 Reply Last reply Reply Quote 0
                  • stephenw10S
                    stephenw10 Netgate Administrator
                    last edited by

                    No. You should see~:

                    States on WAN - T3
                    States on T3 - T2
                    States on T2 - T1

                    So you need a floating outbound reject rule on T3 to reject the T1 destination. It should only be able to create states on T2.

                    Steve

                    1 Reply Last reply Reply Quote 0
                    • J
                      John2893ax
                      last edited by

                      @stephenw10 said in OpenVPN Client Cascade:

                      So you need a floating outbound reject rule on T3 to reject the T1 destination

                      Unfortunately I do not know how to configure this.
                      Also I don't know which rule should be at the top and which at the bottom.

                      1 Reply Last reply Reply Quote 0
                      • stephenw10S
                        stephenw10 Netgate Administrator
                        last edited by

                        The ordering is not important since this will be the only floating rule applied to the T3 interface.

                        Thinking about it you could just edit your existing floating rule for the T1 server destination and make it apply to WAN an T3 so can only ever open on T2.

                        Steve

                        1 Reply Last reply Reply Quote 0
                        • J
                          John2893ax
                          last edited by

                          It makes no difference whether with these rules

                          Screenshot_2020-10-30 pfSense localdomain - Firewall Rules Floating(1).png

                          or with these rules

                          Screenshot_2020-10-30 pfSense localdomain - Firewall Rules Floating.png

                          In both cases the T1 client is down and I have no internet connection.

                          Screenshot_2020-10-30 pfSense localdomain - Status OpenVPN.png

                          1 Reply Last reply Reply Quote 0
                          • stephenw10S
                            stephenw10 Netgate Administrator
                            last edited by

                            But it does prevent the T1 connection coming up in the wrong place?

                            It just fails entirely?

                            Steve

                            1 Reply Last reply Reply Quote 0
                            • J
                              John2893ax
                              last edited by

                              @stephenw10 said in OpenVPN Client Cascade:

                              But it does prevent the T1 connection coming up in the wrong place?

                              Yes.

                              It just fails entirely?

                              I do not know how to check it.

                              Under OpenVPN Log always says after reboot:

                              Oct 31 18:29:10 	openvpn 	28024 	write UDPv4: Permission denied (code=13)
                              Oct 31 18:29:10 	openvpn 	28024 	write UDPv4: Permission denied (code=13)
                              Oct 31 18:29:11 	openvpn 	28024 	write UDPv4: Permission denied (code=13)
                              Oct 31 18:29:11 	openvpn 	28024 	write UDPv4: Permission denied (code=13)
                              Oct 31 18:29:12 	openvpn 	28024 	write UDPv4: Permission denied (code=13)
                              Oct 31 18:29:12 	openvpn 	28024 	write UDPv4: Permission denied (code=13)
                              Oct 31 18:29:13 	openvpn 	28024 	write UDPv4: Permission denied (code=13) 
                              

                              I have:
                              States on WAN-T3
                              States on T3-T2
                              States on T2-nothing

                              T3-T1 is no longer present.

                              I can T1 no longer restart manually.

                              1 Reply Last reply Reply Quote 0
                              • stephenw10S
                                stephenw10 Netgate Administrator
                                last edited by

                                Permission denied like that usually means the firewall is preventing it. Which either means it's trying to start on WAN or T3 and getting blocked or the rules are incorrectly blocking it on T2.

                                If it's the former I'm not really sure what we can do from there. There doesn't appear to be any way to set a specific outbound interface for it to use when that interface is dynamic.

                                Since you know the destination IPs here you could set a route to each on the correct client.
                                So try adding it as a remote network (/32). I.e. add the T1 server IP as a remote network on the T2 client. That should add a route to it and the T1 client should then use it.

                                Steve

                                1 Reply Last reply Reply Quote 0
                                • J
                                  John2893ax
                                  last edited by

                                  When I add T1 server IP as a remote network on the T2 client, the following happens:

                                  • After reboot T1 stays down.

                                  Screenshot_2020-11-01 pfSense localdomain - Status OpenVPN.png

                                  • The message "write UDPv4: Permission denied (code=13)" remains.

                                  But I can manually restart the OpenVPN client order T3->T2->T1. The internet connection is available after that.

                                  If I add T1 server IP as remote network on the T2 client and if I add T2 server IP as remote network on the T3 client, the following happens:

                                  • After reboot all 3 OpenVPN clients are online, but "Local Address" of T1 and T2 is set to (pending).

                                  Screenshot_2020-11-01 pfSense localdomain - Status OpenVPN(1).png

                                  • The message "write UDPv4: Permission denied (code=13)" remains.

                                  But the internet connection is not available. I have to restart the sequence T3->T2->T1 manually.

                                  In both cases (after reboot and after manual restart) I see~:

                                  States on WAN - T3
                                  States on T3 - T2
                                  States on T2 - T1

                                  Also in both cases, I had to deactivate "Don't pull routes" in the OpenVPN client to make it work.

                                  What else can I do?

                                  1 Reply Last reply Reply Quote 0
                                  • J
                                    John2893ax
                                    last edited by

                                    @stephenw10

                                    I still have some questions, just to get it right.

                                    The specification of interfaces in the OpenVPN client secures the order, so that the traffic only goes via T1->T2->T3, right?

                                    The specification of floating rules determines the routing order, right?

                                    The specification of remote network(s) in the OpenVPN client additionally determines the routing order?

                                    But there is no way to determine which client is started first and which client is started last, right? Because after a reboot the internet connection does not work, but after a manual client restart it works.
                                    If this is the case, how could I solve it?
                                    If pfSense offers no other possibilities to solve the problem, would a script be able to restart the order of the OpenVPN clients?

                                    1 Reply Last reply Reply Quote 0
                                    • J
                                      John2893ax
                                      last edited by

                                      Edit:

                                      @stephenw10 said in OpenVPN Client Cascade:

                                      There is a chance it will just work fine since if, for example, tunnel 3 went down when it came back up it would restart tunnel 2 since that is running on it. That in turn would restart tunnel 1.

                                      That did not work for me.

                                      If T3 stopped, then T2 and T1 stopped, but restarting the clients did not work. Would it be possible that I would have to activate something extra for that?

                                      1 Reply Last reply Reply Quote 0
                                      • stephenw10S
                                        stephenw10 Netgate Administrator
                                        last edited by

                                        Indeed the problem is that OpenVPN just chooses whatever source it wants .

                                        So the firewall rules are to prevent it trying to use the wrong interface.

                                        The remote networks add routes to the system when the clients connect for the client inside that which makes openvpn use it.

                                        Steve

                                        1 Reply Last reply Reply Quote 0
                                        • J
                                          John2893ax
                                          last edited by John2893ax

                                          First of all, thanks for the great support @stewenw10!

                                          What should such a script be able to do if the OpenVPN clients are to be started in the correct order?

                                          I am still willing to pay 300 € for a script.

                                          1 Reply Last reply Reply Quote 0
                                          • stephenw10S
                                            stephenw10 Netgate Administrator
                                            last edited by

                                            It's hard to say. It might take some work here because all the existing scripts in pfSense would be trying to bring up the connections normally. If they are defined normally at least.

                                            The issue we need to overcome is preventing an inner tunnel client trying to start intil the outter tunnel is up. I have hoped they might do that anyway when they are on that interface but that doesn't appear to be the case.
                                            Something like the code that prevents OpenVPN starting on a CARP VIP when it's not master for example.

                                            Currently we are just blocking it from connecting by rejecting the states. Which should then allow it to come up when the outer tunnel connects and adds a route. But apparently that is insufficient. The client may need to restart to come up using the new route, which should happen anyway since the interface it's running on changes state but....

                                            Steve

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