# Policy Based Routing on FreeBSD



## mah454 (May 20, 2013)

In Linux*:*


```
iptables -t mangle -A PREROUTING -p tcp --dport 80 -s 10.10.10.0/24 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -p tcp --dport 8080 -s 20.20.20.0/24 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -p tcp -s 172.16.13.0/16 -j MARK --set-mark 1

ip rule add fwmark 1 table 100 
ip route add default via 192.168.0.1 dev eth2 table 100
```

How can *I* do that on FreeBSD*?* Note*:* I use pf for firewalling*.*


----------



## dpslavov (May 20, 2013)

PF is the right choice, take a look at route-to and reply-to in the man page (pf.conf(5)). You don't have to change the routing table.


----------

