# PF - Rewriting Just Destination Port



## FreeBSoD (Jun 26, 2013)

In iptables, you can rewrite a connection's destination port while preserving it's address (like so "REDIRECT --to-port X"). Is this not possible with PF? I've read and re-read about redirection in pf.conf(5), but it seems that the "rdr" directive _requires _you to rewrite the destination address, while only providing _port_ preservation.

If possible, how can I get FP to rewrite _just_ the port?


----------



## SirDice (Jun 27, 2013)

FreeBSoD said:
			
		

> I've read and re-read about redirection in pf.conf(5), but it seems that the "rdr" directive _requires _you to rewrite the destination address, while only providing _port_ preservation.


No, it can change the port too.



> rdr   The packet is redirected to another destination and *possibly a different port.*



However, you cannot "bounce" packets back out the same interface they came in on.



> Redirections cannot reflect packets back through the interface they arrive on, they can only be redirected to hosts connected to different interfaces or to the firewall itself.


----------



## throAU (Jun 27, 2013)

Presumably, one can get around that by creating an alias interface and bouncing them back out that interface?


----------

