Home
Help
Search
Login
Register
OPNsense Forum
»
Archive
»
22.1 Legacy Series
»
NAT reflection woes...
« previous
next »
Print
Pages: [
1
]
Author
Topic: NAT reflection woes... (Read 3169 times)
meyergru
Hero Member
Posts: 1680
Karma: 165
IT Aficionado
NAT reflection woes...
«
on:
June 05, 2022, 01:48:38 pm »
Well, yesterday, I had some bad experience using NAT reflection on port forwards...
I was trying to setup HAProxy when I noticed that my backend server could not be reached. This was strange, since I had disabled the port forward that I had for ports 80 and 443 to my main server.
After much trial and error, I narrowed this down to that my Opnsense could not reach the main server on ANY port, but could ping it. I gave the main server an additional IP and that worked. I was not aware of any firewall rule that could cause this, but after I disabled all packet filtering, I could access the ports again from my Opnsense.
Since I could not lay my fingers on anything specific by enabling all firewall logging, I suspected a NAT issue, because I still had some inbound WAN rules for my main server for other ports than 80 and 443. After I disabled them, all was fine.
I narrowed the problem down to one port forwarding rule which had a "mail" port alias with ports 143 and 587 in it and for which NAT reflection was enabled. The alias was used in both the port range and redirect target port. NAT reflection was enabled.
This rule had the side effect of blocking all ports on the destination server from the Opnsense itself. When I changed that to two separate rules for the ports, only the ports in the rules were affected.
So there are two problems with NAT reflection:
1. When you use a port forwarding rule with a port alias containing two ports and enabled NAT reflection, Opnsense cannot access any port on the target IP. There is surely a bug in how port aliases are handled there as all ports are affected and not only the ones in the alias.
2. Even when you do without port aliases and NAT reflection on a port forwarding rule to an IP X on only a single redirect target port Y, that specific combination of X:Y will not be reachable for your Opnsense box itself any more. While it is somehow intended to have NAT reflection for any incoming LAN traffic, it should never lead to the target port being masked from the Opnsense itself. To say the least, this is most unexpected and very difficult to find once you stumble on it, as there is no logging for NAT reflection.
These problems are only visible from the Opnsense box itself, as any other LAN clients usually reach the target X directly without Opnsense interfering, i.e. NAT reflection comes only into play when you access the external IP for X (and also, the port could be != Y).
«
Last Edit: August 22, 2022, 06:39:41 pm by meyergru
»
Logged
Intel N100, 4 x I226-V, 16 GByte, 256 GByte NVME, ZTE F6005
1100 down / 440 up
,
Bufferbloat A+
axsdenied
Full Member
Posts: 199
Karma: 9
Re: NAT reflection woes...
«
Reply #1 on:
June 07, 2022, 11:29:39 pm »
There have been numerous posts regarding aliases behaving differently in the latest builds. I believe it's being investigated.
For now are you able to manually port forward each port rather then using aliases? Does that still work?
Logged
OPNsense 24.7.7 running on:
Dell Optiplex 3050
Intel I5-7600 @ 3.5Ghz (4 Cores)
Intel I350-T4 Nic
8G DDR4
256G SSD
meyergru
Hero Member
Posts: 1680
Karma: 165
IT Aficionado
Re: NAT reflection woes...
«
Reply #2 on:
June 07, 2022, 11:39:42 pm »
Yes, it works with separate rules, as I wrote:
"When I changed that to two separate rules for the ports, only the ports in the rules were affected."
I reported the specific problem in the "aliases" thread - however, the 2nd problem with NAT reflection is unrelated to aliases: there seems to be no exception for the firewall itself on the reflection rule, so that it cannot reach the target on the original port (or more probably, get the answers back).
Logged
Intel N100, 4 x I226-V, 16 GByte, 256 GByte NVME, ZTE F6005
1100 down / 440 up
,
Bufferbloat A+
despised
Newbie
Posts: 6
Karma: 1
Re: NAT reflection woes...
«
Reply #3 on:
June 08, 2022, 12:50:33 am »
I had the same problem. Port forwarding rules were failing when I implemented them myself (anti-lockout rules).
This is what I changed to make them work (it's the firewall rules, not the port forward).
Create port forwarding rule (no redirect). (no tricks)
Create firewall rule, however add the following ->
1. Make the rule as you would.
2. Check allow options
3. Checkmark `SYN` in the `set` column
4. Checkmark `SYN` and `ACL` in the `out of` column.
5. Ensure `Keep State` is checked.
Without those additional elements
PROFIT. This took me ages to work out.
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
Archive
»
22.1 Legacy Series
»
NAT reflection woes...