port based traffic redirection

Hello,
Can you help me with the following situation:
I have two internet service providers and I am trying to redirect all internal traffic who has destination port 80 or 443 to ISP1 and all the rest to ISP2.

Thanks in advance!
 
with IPFW you can do something like

Code:
ipfw add fwd $ISP1 ip from $internal_net to any 80 out
ipfw add fwd $ISP1 ip from $internal_net to any 443 out

Check ipfw(8) and handbook for more details
 
I'm assuming you're doing this on a router running BSD? I think pf with the route-to option should be able to do what you require.

Warning: totally untested pseudocode syntax ahead

Code:
pass in on $int_if route-to ($ext_if1 $ext_gw1) inet proto tcp from $lan_net to any port { 80, 443 } flags S/SA modulate state
pass in on $int_if route-to ($ext_if2 $ext_gw2) inet proto tcp from $lan_net to any port { !80, !443 } flags S/SA modulate state
pass in on $int_if route-to ($ext_if2 $ext_gw2) inet proto { udp, icmp } from $lan_net to any keep state
You need pass out rules as well, etc.
 
Back
Top