Configure 2 gateways on a freebsd box for 2 interfaces

Christopher Cowart ccowart at rescomp.berkeley.edu
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 192.168.0.1 255.255.255.0
> The second interface: 10.228.44.1 255.255.255.0
> The gateway for the first interface must be 192.168.0.254 and the second
> interface must be 10.228.44.254
> 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 10.228.44.254 ip from 10.22.44.1 to not 10.22.44.0/24

Then you can leave the default_gateway as 192.168.0.254.

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 : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20080910/df09e063/attachment.pgp


More information about the freebsd-questions mailing list