### BASIC
ext_if="fxp0"
int_if="rtk0"
router="192.168.0.2"
### SHARE INTERNET
nat on fxp0 from rtk0:network to any -> (fxp0)
### REDIRECT SSH
#rdr log on $ext_if proto tcp from any to $ext_if port 4550 -> $router
#pass in on $ext_if inet proto tcp from any to $router port 4550
#pass out on $int_if inet proto tcp from any to $router port 4550
#rdr on $ext_if proto tcp from any to any port 4550 -> $router
#rdr on $ext_if proto udp/tcp from any to any port 4550 -> $router
rdr on $ext_if proto {udp, tcp} from any to any port 4550 -> $router
pass in on $ext_if proto {udp, tcp} from any to any port 4550 keep state
Does your NAT work in general? Do you have this in your /etc/rc.conf:batence said:Doesnt work anyway, I have inside a openbsd box with 4550 ssh port
gateway_enable="YES"
ext_if = re0
int_if = lo0 # dummy because this is a single NIC box
other_machine = 10.1.2.3
# --- redirect and tag
rdr on $ext_if proto tcp from any to any port 22 tag SSH -> $other_machine port 22
# --- EXTERNAL INTERFACE incoming
# rdr does not automagically pass the traffic
pass in quick on $ext_if tagged SSH
# --- INTERNAL INTERFACE outgoing
pass out quick on $int_if tagged SSH
[cmd=#] pfctl -vvnf rdr.test[/cmd]
ext_if = "re0"
int_if = "lo0"
other_machine = "10.1.2.3"
@0 rdr on re0 inet proto tcp from any to any port = ssh tag SSH -> 10.1.2.3 port 22
@0 pass in quick on re0 all flags S/SA keep state tagged SSH
@1 pass out quick on lo0 all flags S/SA keep state tagged SSH
rdr on $ext_if proto tcp from any to any port 22 tag APPROVED -> $other_machine port 22
rdr on $ext_if proto tcp from any to any port 80 tag APPROVED -> $webserver_1 port 80
pass in quick on $ext_if tagged APPROVED
pass out quick on $int_if tagged APPROVED