Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Feb 2008 15:42:43 -0600
From:      Kevin Day <toasty@dragondata.com>
To:        Nick Barnes <Nick.Barnes@pobox.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: Multiple default routes on multihome host
Message-ID:  <DD058A40-C369-48F5-B123-2EAE53222A72@dragondata.com>
In-Reply-To: <38308.1203368454@thrush.ravenbrook.com>
References:  <38308.1203368454@thrush.ravenbrook.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Feb 18, 2008, at 3:00 PM, Nick Barnes wrote:

> I have a multi-home host: more than one IP address.  The addresses are
> in separate subnets but run over the same ethernet segment (this is a
> temporary situation while I switch an office network over from one
> network provider to another).
>
> I want packets from address A1 to be sent via gateway G1, but packets
> from address A2 to be sent via gateway G2.
>
> How do I do this?  Can I just have more than one default route?  I'm
> remote from the machine in question, so I don't want to tinker with
> the default route until I'm sure of the answer.

This isn't perfect, but if you have ipfw and IPFIREWALL_FORWARD in  
your kernel config (you also might need IPFIREWALL_FORWARD_EXTENDED  
depending on how old your OS is) you can do this:

route add default G1
ipfw add fwd G2 IP from A2 to any


The normal kernel routing kicks in for packets from A1 going to G1,  
but then ipfw overrides this for anything being sourced from A2 and  
forces it to go to G2.

-- Kevin





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DD058A40-C369-48F5-B123-2EAE53222A72>