I tried setting up rules to be applied for a particular gateway, but this didn't do what I thought it would... route that traffic over the interface.
Only seem to be able to setup routing based on network address. Is there a way to setup routes based on aliases?
It might work with gateway rules in firewall, but not with kernel routes
Possibly when using the route update mechanism. In my case, I needed to organize routing into a VPN tunnel for several subnets, and also use NAT to ensure that the user's IP was replaced with the client's VPN IP. I created an alias "subnets" and added it to the NAT firewall rules, and also when connecting to a VPN, a script is executed
#!/bin/bash
vpnIf="$1"
defIf="bridge1"
if [[ $(netstat -rn -f inet | egrep ^.*$1 | wc -l) -ge 1 ]]; then
VPN_NET=$(pfctl -t subnets -T show)
for ITEM in $VPN_NET
do
route add -net $ITEM -interface $vpnIf
done
route change -net 0.0.0.0/0 -interface $defIf
construct VPN_NET=$(pfctl -t subnets -T show)
allows you to pass the contents of the "subnets" alias to the script