If you use range on ports, then you loose control over dst-port → to-port mapping.
Apart from better readability you get by merging rules (subjective), there’s no big performance difference … if you have more or less default firewall setup which includes the usual chain=forward action=accept connection-state=established,related (and the action=fasttrack-connection variant) before these rules as the specific rules will only affect the initial packet of each connection.
I think the subject of the OP is different - one would expect that if you do not specify any to-ports value in a dst-nat rule, the destination port should remain unchanged, no matter whether the rule contains a match condition for dst-port or not.
Indeed the NAT documentation makes impression that if to-ports is not specified, then dst-port is not changed. From OPs tests I can only assume that there’s a bug in ROS regarding this …
We have had this discussion already. What I would like to see is one to one mapping of a range…
so if I have 2-5, as a range of dst prts, and put “too-ports” range as 12-15, then I would want 2–>12, 3–>13, 4–>14 and 5—>15 and so forth.
Do we not already assume that if we have a destination range of 2-5 WITHOUT to-ports entry that we are saying that any port between from 2-5 can be mapped to port 2-5 on the receiving server.
Is our expectation not, that incoming on port 2 go to port 2 on server and incoming on port 3 go to port 3 on incoming server… So it is not a stretch to define the to-ports with a range with a similar expectation!!!
Hmmm, okay just I have always used ranges successfully on zyxel and MT routers, as well a list of random ports separated by commas, never gave it much thought…
I only want to get the mapping with one-to-one port, not with shifted ports, the very basic NAT over a range of ports from a public IP to a private IP with UDP.
In an other test, I also set to-ports with the same range than dst-port have, but the result is the same, it doesn’t work.
dst-port is only a match condition, to-ports is only a pool of destination ports to use. There is no relationship between the two. So the issue must be something else (configuration, ROS version, CPU architecture).
Interesting sindy,
So if one has a range of ports 5-10 and you put in a pool of ports 5-10, are you saying the router could match 5–>10 and 6—>7 etc… you make it sound arbitrary.
Extrapolating, if one has a range of ports 5-10 and a pool of 25-30, are you saying that the router could match 5—>30 and 6—>27 etc…
What I am saying is that matching on original destination port and assignment of a new destination port are totally unrelated. If you do not specify any to-ports at all, the destination port is not changed; if you specify a port range in to-ports, one of ports in that range is chosen “randomly” (i.e. you cannot affect the choice). There is no mapping like "the third port in the dst-port range will be translated to the third port in the to-ports range.
Thanks, so are you also saying that the router may choose to randomly assign the same too port for every one of the incoming destination ports…
Do you have a copy of the code or something or is it just a theory ;-PP
Theory by Anne Elk!!! https://www.dailymotion.com/video/x2oh8ia