Policy routing with IPFW
David G. Andersen
danderse at cs.utah.edu
Thu Apr 15 14:22:42 PDT 2004
Stephen Gill just mooed:
> following:
>
> - All traffic sourced from Interface 1 (dc0) should go out gateway 1
> - All traffic sourced from Interface 2 (dc1) should go out gateway 2
> - All traffic destined to Interface 1 (dc0) should return out gateway 1
> - All traffic destined to Interface 2 (dc1) should return out gateway 2
>
> Gateway 1 is on dc0 and Gateway 2 is on dc1. I think you get the
> picture.
>
> Is this type of thing possible with IPFW? If not, is there any other
> module that would allow me to do this? I don't care how ugly it gets,
> just so long as it works.
sure.
options IPFIREWALL
options IPFIREWALL_FORWARD
As an example from a running system:
00100 allow ip from any to any via lo0
00500 allow ip from IP1 to IP1/IP1-netmask
00501 fwd IP1-GW ip from IP1 to any
00600 allow ip from IP2 to IP2/IP2-netmask
00601 fwd IP2-GW ip from IP2 to any
(where IP1-GW and IP2-GW are the next-hop routers for each
interface, obviously).
Works like a charm - I've got it running on quite a few machines.
The only downside to it sometimes is that you have to write some
script wrappers around things to get dynamic updates (e.g.,
ppp linkup scripts or dhcpd.conf running external scripts on route
changes).
-Dave
--
work: dga at lcs.mit.edu me: dga at pobox.com
MIT Laboratory for Computer Science http://www.angio.net/
I do not accept unsolicited commercial email. Do not spam me.
More information about the freebsd-security
mailing list