Hey im using FreeBSD 15.x with PF. So far my rules are working but i cant get any port forwarding to work. As i understood
i have to specify an "rdr" and after that an related pass rule. I tested the rules with logging and saw that the traffic in the log (blocked).
moving the block rule around doesnt resolve the problem.
/etc/pf.conf
Anchor: /etc/pf/nat_portforward.conf
Greets...
i have to specify an "rdr" and after that an related pass rule. I tested the rules with logging and saw that the traffic in the log (blocked).
Code:
07:29:16.264482 IP ********.49652 > 10.10.0.2.5101: Flags [S], seq 107083461, win 65535, options [mss 1380,nop,wscale 8,nop,nop,sackOK], length 0
moving the block rule around doesnt resolve the problem.
/etc/pf.conf
Code:
#################################
#### Packet Firewall Ruleset ####
#################################
###################
#### Variables ####
###################
ext_if="vtnet0"
int_if="{ vtnet1, vtnet2 }"
load anchor nat-portforward from "/etc/pf/nat_portforward.conf"
nonroute= "{ 0.0.0.0/8, 20.20.20.0/24, 127.0.0.0/8, 169.254.0.0/16,
172.16.0.0/12, 192.0.2.0/24, 192.168.0.0/16, 224.0.0.0/3,
255.255.255.255 }"
icmp_types = "{ 0, 3, 4, 8, 11, 12 }"
####################################
#### Options and optimizations #####
####################################
set loginterface $ext_if
set optimization aggressive
set block-policy drop
set skip on lo0
scrub on $ext_if all no-df fragment reassemble
#######################
#### NAT & Proxies ####
#######################
nat on $ext_if from !($ext_if:network) to any -> ($ext_if)
# FTP proxy
rdr on $int_if proto tcp from $int_if to any port 21 -> 127.0.0.1 port 8021
block in log on $ext_if all
anchor nat-portforward
################################
#### Rules inbound (int_if) ####
################################
Anchor: /etc/pf/nat_portforward.conf
Code:
####################################################
#### Packet Firewall Ruleset - NAT Port forward ####
####################################################
###################
#### Variables ####
###################
ext_if="vtnet0"
int_if="{ vtnet1, vtnet2 }"
# FTP proxy
rdr on $int_if proto tcp from $int_if to any port 21 -> 127.0.0.1 port 8021
rdr pass on $ext_if proto {tcp, udp } from any to any port 5101 -> 10.232.128.100 port 3389
rdr pass on $ext_if proto tcp from any to any port 25 -> 10.232.136.103
pass in quick on $ext_if inet proto {tcp, udp } from any to ($ext_if) port 5101 keep state
pass in quick on $ext_if proto tcp from any to any port { 25, 80, 443, 3389 } keep state
Greets...