Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login
    Introducing Netgate Nexus: Multi-Instance Management at Your Fingertips.

    Managing firewall rules for NAT

    Scheduled Pinned Locked Moved NAT
    5 Posts 3 Posters 81 Views 3 Watching
    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.
    • R Offline
      recvfrom
      last edited by recvfrom

      I anticipate adding NAT port-forwarding for a growing set of isolated instances, say, up to 128, each using a disparate, non-contiguous set of ports. Each one will have a unique virtual IP address on the WAN interface mapped to a unique internal redirect target IP address in a range covered by a CIDR block, e.g., /25. What is the safest and most efficient way to add these without generating 100s of firewall rules (even if I need 100s of NAT rules)?

      Is it safe to add a firewall rule per destination port on the WAN interface for the internal target IP range/block and then slowly add the individual NAT rules (one per destination IP+port combination), while changing Filter rule association -> Add associated filter rule to None? The firewall rule references RFC-1918 addresses, but without individual NAT rules per redirect target it should not have any effect for unused address space/not-yet-deployed instances, or am I wrong?

      An alternative would be to add a firewall rule per port referencing an IP alias instead of a CIDR block, and slowly expand the alias. For example, create a sequence starting with: 1) a single /32; 2) convert to a /31; 3) use a /31 and a /32; 4) convert to a /30; 5) /30 and a /32; etc.

      Or should I not worry at all and let the firewall rules grow like a weed? :)

      Thanks in advance for any insight or advice!

      tinfoilmattT luckman212L 2 Replies Last reply Reply Quote 0
      • tinfoilmattT Offline
        tinfoilmatt LAYER 8 @recvfrom
        last edited by

        Is it safe to add a firewall rule per destination port on the WAN interface for the internal target IP range/block and then slowly add the individual NAT rules (one per destination IP+port combination), while changing Filter rule association -> Add associated filter rule to None?

        Yes. A single firewall rule is fine. No need to 'associate' firewall rules with NAT rules.

        block out log on { ix0 } inet from any to any
        block out log on { ix0 } inet6 from any to any

        R 1 Reply Last reply Reply Quote 1
        • luckman212L Online
          luckman212 LAYER 8 @recvfrom
          last edited by

          If you're using pfSense+, Nexus UI will generally make managing larger sets of rules faster.

          Also, you didn't say, but if you have the v4 address space available, 1:1 NAT could help reduce the number of outbound NAT rules and lower complexity.

          R 1 Reply Last reply Reply Quote 0
          • R Offline
            recvfrom @tinfoilmatt
            last edited by

            @tinfoilmatt thanks, I'll do it this way!

            1 Reply Last reply Reply Quote 0
            • R Offline
              recvfrom @luckman212
              last edited by

              @luckman212 I prefer port-specific NAT rules to minimize attack surfacea, and since it will only be about 5 with a CIDR block, it won't add much complexity.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Copyright 2026 Rubicon Communications LLC (Netgate). All rights reserved.
              Privacy Policy · Cookie Policy