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

Inbound Port Forward while keeping originating IP address (without NAT)?

Scheduled Pinned Locked Moved NAT
7 Posts 5 Posters 4.1k 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.
  • A
    aeleus
    last edited by Mar 28, 2017, 1:13 PM

    I set up a few inbound port forwarding rules for HTTP, SMTP and the like. They work. The issue is that when pfSense forwards the packet to the target server on the LAN, it translates the public IP address to its own LAN IP address. The internal, target server sees that traffic as coming from the pfSense box - not the internet.

    That works okay for HTTP traffic as pfSense adds the X-Forwarded-For (XFF) HTTP header field to identify the originating IP address. That allows the Web server to see from where the traffic is coming.

    For SMTP, there is no "X-Forward-For" mechanism. This is not good as the email server relies on the public IP address to make decisions on what clients to trust, IP blacklists, etc. All SMTP traffic now appears to be LAN traffic.

    Interestingly, OPNsense does the opposite. All inbound NAT appears to the target endpoint to come from the original public IP address. Downside: the target server must use that OPNsense box as its default gateway.

    When I used TMG firewall, each "publishing" rule could be set to appear to come from the firewall or the original public IP. I liked this approach as there are times when one approach is desired over the other.

    Is there a way to configure this behavior in pfSense?

    Thanks!

    Running pfSense 2.3.3-RELEASE-p1

    1 Reply Last reply Reply Quote 0
    • V
      viragomann
      last edited by Mar 28, 2017, 1:35 PM

      pfSense doesn't source-NAT on forwarded packets by default.

      Are you using a proxy or have you set a gateway in the internal interface settings?
      Otherwise check the outbound NAT settings. There shouldn't be any rule for internal interfaces if there are no particular reasons for this.

      1 Reply Last reply Reply Quote 0
      • K
        kpa
        last edited by Mar 28, 2017, 4:44 PM

        Yep, this sounds like a misconfiguration in the outbound NAT settings. By default the source address is left untouched by the port forwarding RDR rules, only the destination address is changed.

        1 Reply Last reply Reply Quote 0
        • A
          aeleus
          last edited by Mar 29, 2017, 1:02 AM

          Thanks  viragomann and kpa for pointing me in the right direction. The problem was indeed the outbound NAT rules. At some point, an outbound rule had been created for the SMTP server, and that was doing the NAT'ing on inbound port-forwarded traffic.

          Once I cleaned that up, the traffic now flows as expected. BTW, HTTP traffic is actually coming in via squid reverse proxy (not port forwarding) - that explains the "x-forward-for" header.

          As a bonus, I can now control which inbound ports are NAT'd and which are not.

          1 Reply Last reply Reply Quote 0
          • K
            Korn123
            last edited by Apr 3, 2017, 3:27 AM

            I do not understand the problem is when pfSense forwards the packet.

            เสียงไฮโล ไฮโล

            1 Reply Last reply Reply Quote 0
            • D
              Derelict LAYER 8 Netgate
              last edited by Apr 3, 2017, 4:35 AM

              Port forwards translate the destination address and/or port.

              Outbound NAT translates the source address and/or port.

              Chattanooga, Tennessee, USA
              A comprehensive network diagram is worth 10,000 words and 15 conference calls.
              DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
              Do Not Chat For Help! NO_WAN_EGRESS(TM)

              1 Reply Last reply Reply Quote 0
              • A
                aeleus
                last edited by Apr 3, 2017, 3:18 PM

                @Derelict:

                Port forwards translate the destination address and/or port.

                Outbound NAT translates the source address and/or port.

                It helped me to realize that "Outbound NAT determines how traffic leaving a pfSense system will be translated". That is, "outbound" from the pfSense system - not necessarily "outbound from the network". One can apply Outbound NAT rules to traffic that is "inbound" to the network (including Port Forward traffic).

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