Configure 2 gateways on a freebsd box for 2 interfaces

Christopher Cowart ccowart at
Wed Sep 10 19:01:05 UTC 2008

The Noob wrote:
> I have a small question.
> I have two interface in two vlans.
> The first interface
> The second interface:
> The gateway for the first interface must be and the second
> interface must be
> How can I configure them? In rc.conf we have just defaultrouter but we can't
> specify the interface.

I'm guessing you want the gateway to be chosen based on the source
address, correct? The kernel does not support routing based on the
source address.

I use ipfw and fwd rules to achieve this:

ipfw add fwd ip from to not

Then you can leave the default_gateway as

You might need IPFIREWALL_FORWARD in your kernel config. See ipfw(8).

Chris Cowart
Network Technical Lead
Network & Infrastructure Services, RSSP-IT
UC Berkeley
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
Url :

More information about the freebsd-questions mailing list