From owner-freebsd-net@FreeBSD.ORG Mon Feb 18 21:42:45 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E0FEC16A469 for ; Mon, 18 Feb 2008 21:42:45 +0000 (UTC) (envelope-from toasty@dragondata.com) Received: from tokyo01.jp.mail.your.org (tokyo01.jp.mail.your.org [204.9.54.5]) by mx1.freebsd.org (Postfix) with ESMTP id AB54F13C4D3 for ; Mon, 18 Feb 2008 21:42:45 +0000 (UTC) (envelope-from toasty@dragondata.com) Received: from mail.your.org (server3-a.your.org [64.202.112.67]) by tokyo01.jp.mail.your.org (Postfix) with ESMTP id 30C402AD545F; Mon, 18 Feb 2008 21:42:44 +0000 (UTC) Received: from pool011.dhcp.your.org (pool011.dhcp.your.org [69.31.99.11]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.your.org (Postfix) with ESMTP id 72ABCA0A44F; Mon, 18 Feb 2008 21:42:43 +0000 (UTC) Message-Id: From: Kevin Day To: Nick Barnes In-Reply-To: <38308.1203368454@thrush.ravenbrook.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Date: Mon, 18 Feb 2008 15:42:43 -0600 References: <38308.1203368454@thrush.ravenbrook.com> X-Mailer: Apple Mail (2.919.2) Cc: freebsd-net@freebsd.org Subject: Re: Multiple default routes on multihome host X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Feb 2008 21:42:46 -0000 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