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

    pfSense NAT rule to another pfSense

    NAT
    3
    12
    722
    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.
    • L
      lcs
      last edited by

      Setup:
      Two boxes with VPN tunnel between them. All resources accessible.

      VPS - 94.xx.xx.xx
      Local - 46.xx.xx.xx

      I have a mail server,currently accessible via open internet on port 25 on the pfsense.local (94.xx.xx.xx) and my idea is to close that tcp/25 and access the mail server via the VPS one (46.xx.xx.xx) via the VPN.
      Basically to use the VPS as an entry point.

      What I want to do :
      Traffic flow in : Internet -> VPS/TCP25 -> pfSense.local/TCP25 -> MailServer(10.16.22.15)/TCP25
      Traffic flow out : MailServer(10.16.22.15)/TCP25 -> pfSense.local/TCP25 -> VPS -> Internet

      I have the second part working. On the rule for the mail server I've defined a gateway and when testing with
      curl ifconfig.me I can see the traffic is going out from the VPS and I'm getting the corresponding addres (46.xx.xx)
      For some reason, I cannot work out the first part.
      I tried with the following Port Forward NAT rule: check the attached file
      Untitled.jpg

      Using that rule, when testing the port from public internet, I can see the traffic going to the VPS pfSense, then reaching the mail server via the pfSense local, but the result of the port test fails.
      On the packet capture I can see only tcp 0 reaching the mail server.
      I also tried using Outbound NAT on the pfSense.local with the idea of forwarding all traffic to the VPS pfSense, again no luck, the result of the port test again failed.

      Not sure what's going on and why. I have some concerns regarding asymmetric traffic, because from the traffic logs I see the mail server is trying to talk back to the port test website directly, and not via the VPS for some reason.

      Any help would be appreciated

      Bob.DigB V 3 Replies Last reply Reply Quote 0
      • Bob.DigB
        Bob.Dig LAYER 8 @lcs
        last edited by Bob.Dig

        @lcs What VPN. Form where is that screenshot. Why is that disabled.

        L 1 Reply Last reply Reply Quote 0
        • L
          lcs @Bob.Dig
          last edited by

          @Bob-Dig OpenVPN.
          It is disabled, because it's not working and there's no point to be active as of now.
          This NAT rule is on the VPS firewall

          1 Reply Last reply Reply Quote 0
          • Bob.DigB
            Bob.Dig LAYER 8 @lcs
            last edited by

            @lcs said in pfSense NAT rule to another pfSense:

            Not sure what's going on and why. I have some concerns regarding asymmetric traffic, because from the traffic logs I see the mail server is trying to talk back to the port test website directly, and not via the VPS for some reason.

            I would create a local rule which forces traffic towards port 25 out the VPN-Gateway.

            1 Reply Last reply Reply Quote 0
            • V
              viragomann @lcs
              last edited by

              @lcs
              On your home pfSense you have to assign an interface to the OpenVPN instance.

              Then go to Firewall > rules > OpenVPN, edit the pass rule and change the interface to the new instance interface.

              There must no pass rule on the OpenVPN tab match the incoming traffic from the VPS!
              If you're running further OpenVPN instances either limit the pass rules to the respective source IP ranges (e.g. tunnel network if applicable) or as well assign interfaces to the other instances and define your rules on the respective interface tab.

              L 1 Reply Last reply Reply Quote 0
              • L
                lcs @viragomann
                last edited by

                @viragomann I have an interface for the OpenVPN and I have a pass rule.
                I've mentioned in the first post, all resources accessible.
                When I do Diagnostics -> Test Port from the VPS to the local pfSense I can see the port open and accessible.
                But I cannot access the port from outside.

                V 1 Reply Last reply Reply Quote 0
                • V
                  viragomann @lcs
                  last edited by

                  @lcs said in pfSense NAT rule to another pfSense:

                  I have an interface for the OpenVPN and I have a pass rule.

                  Can you show it, please?

                  Remove or disable the SMTP port forwarding on WAN if you didn't this already.

                  Edit the pass rule and enable logging. Try to access your SMTP then and post the firewall log.

                  I've mentioned in the first post, all resources accessible.

                  Did not doubt on this.

                  L 1 Reply Last reply Reply Quote 0
                  • L
                    lcs @viragomann
                    last edited by

                    @viragomann From the VPS via the VPN Tunnel to the mail server
                    e546a597-bcd3-4787-a679-65e2f12616a6-image.png

                    NAT Rule on the VPS
                    8d1b88b5-aff6-483d-b009-c6167f4d7579-image.png

                    OpenVPN Allow rule on the pfSense.local
                    014960c3-7fe9-4715-9cda-87e3fdc34512-image.png

                    Local rule forwaring the outbound traffic to the VPS
                    ed4ada2f-08dc-4de2-be1d-6d672fbed9ec-image.png

                    When doing an external port test:
                    on the VPS I see hits
                    706c5625-d1e2-459e-b58e-dd4797b88ad1-image.png
                    On the packet CAP
                    0a2837fe-5571-43cd-8a54-25924a182510-image.png

                    On the local pfSense I also see hits, but from the IP of the port test website, not the VPS firewall
                    ab08a75c-01dd-4f41-ab26-7ce17550038e-image.png

                    And the packet cap from the local firewall
                    fa01b5e8-c4b1-401c-aff6-9b507d7442b1-image.png

                    V 1 Reply Last reply Reply Quote 0
                    • V
                      viragomann @lcs
                      last edited by

                      @lcs
                      I instructed you to remove all matching rules from the OpenVPN tab on the home pfSense. The communication would not work, if any pass rule there is matching the forwarded traffic!

                      L 1 Reply Last reply Reply Quote 0
                      • L
                        lcs @viragomann
                        last edited by

                        @viragomann You are correct. If there's a matching rule it's not working.
                        Why is that ?
                        When I disabled the matching rules it started working as expected.

                        V 1 Reply Last reply Reply Quote 0
                        • V
                          viragomann @lcs
                          last edited by

                          @lcs
                          With the forwarding from the VPS you have incoming traffic from public sources on a non-default gateway. So responses from your SMTP server have to be directed back to the VPS.

                          To achieve this, pfSense can tag incoming traffic with the "reply-to" (gateway). This is done by the filter rule, which allow the traffic in. Without this traffic would be sent out to the default gateway.
                          However, to apply the reply-to tag, pfSense has know, which gateway to reply for plausible reasons. pfSense use the the gateway, which is assigned to the interface, which the rule is defined on.
                          But OpenVPN is not a certain interface, it is an interface group indeed, including all OpenVPN instances. And firewall rules on interface groups have priority over rule on member interface. Therefore such rule are probed first.

                          L 1 Reply Last reply Reply Quote 1
                          • L
                            lcs @viragomann
                            last edited by

                            @viragomann Thanks for the clarification.
                            b8c9a9a8-d92d-4680-a378-b476b940536a-image.png

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