PF How to redirect packets by only changing the destination port

I'm using FreeBSD + PF to act as a NAT gateway for a project. As part of this, I need to redirect packets meant for port 8080 to port 80 but keep the original destination address the same. So far I have the rule rdr on $ext inet proto tcp from $localnet to any port 8080 -> xxx.xxx.xxx.xxx port 80 working for a specific IP address, but I want this to work for dynamically for any IP address. Is there anyway to do this using PF?
 
Can you give more information what are you trying to do?

You need destination IP address/pool in order to forward the traffic.
 
Can you give more information what are you trying to do?

You need destination IP address/pool in order to forward the traffic.


I'm using the destination port to determine how traffic is forwarded. Different destination ports will forward traffic to different subnets, but I ultimately want all the packets destination ports changed to port 80. I will not know the destination IP addresses beforehand. I would like to know if there is a PF rule that will allows me to keep the IP address the same but change the destination port. This is currently being done with a load balancer but I want to see if it is possible to use FreeBSD for this.
 
Back
Top