OPNsense Forum

English Forums => General Discussion => Topic started by: mts on September 26, 2023, 07:22:23 PM

Title: NAT portforward for complete subnet
Post by: mts on September 26, 2023, 07:22:23 PM
Hey guys,

I want to redirect a port for a complete subnet.
e.g.
10.10.0.4:1234->10.10.0.4:44444
10.10.0.8:1234->10.10.0.8:44444
10.10.0.10:1234->10.10.0.10:44444
...
So destination and target is always the same. Only the port is changed.
Is there a way to prevent many manual entries?

CU
mts
Title: Re: NAT portforward for complete subnet
Post by: Monviech (Cedrik) on September 26, 2023, 08:57:40 PM
How about:

Destination: 10.10.0.0/24
Destination port range: 1234-1234
Redirect target IP: 10.10.0.0/24
Redirect target port: 44444

Results in the following rule in pf:
@145 rdr on lan inet proto tcp from any to 10.10.0.0/24 port = 1234 -> 10.10.0.0/24 port 44444

Edit: I dont know if that works the way you expect it to work though, just verified that you can input that in the GUI. I dont know what the results will be.