From owner-freebsd-questions@FreeBSD.ORG Tue Feb 15 19:30:38 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7639816A4DE for ; Tue, 15 Feb 2005 19:30:38 +0000 (GMT) Received: from lilzmailso02.liwest.at (lilzmailso02.liwest.at [212.33.55.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id C783443D5A for ; Tue, 15 Feb 2005 19:30:37 +0000 (GMT) (envelope-from dgw@liwest.at) Received: from cm248-169.liwest.at ([81.10.248.169] helo=[10.0.0.4]) by lilzmailso02.liwest.at with esmtp (Exim 4.24) id 1D18P5-0003fy-7g; Tue, 15 Feb 2005 20:30:35 +0100 From: Daniela To: Jan Grant Date: Tue, 15 Feb 2005 21:29:30 +0000 User-Agent: KMail/1.5.3 References: <200502112206.43267.dgw@liwest.at> <200502121505.20754.dgw@liwest.at> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200502152129.31091.dgw@liwest.at> cc: Alin-Adrian Anton cc: questions@freebsd.org Subject: Re: How do I set the source address on a multi-homed host? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: dgw@liwest.at List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2005 19:30:38 -0000 On Sunday 13 February 2005 09:37, Jan Grant wrote: > On Sat, 12 Feb 2005, Daniela wrote: > > Yes, this happens when I connect from my machine (which functions as a > > router with NAT to allow the other LAN machines connect to the internet) > > to another LAN machine. When the router establishes a connection to > > another point in the intranet, the source address used is my official IP, > > and not 10.0.0.1, which is the intranet IP of the router. > > In other words, I want the source address to be 10.0.0.1 on every > > outgoing connection where the destination is inside my intranet. > > Assuming you haven't munged the internal IP address to hide it, and with > all due deference to the FreeBSD "mechanism, not policy" mantra: no, you > don't want to do this. The 10.0.0.0/8 block of addresses is explicitly > for private use and is not routable on the internet. > > If your firewall is causing problems with this setup, you might need to > re-examine your firewall settings. > > Having said that: technically, you specify source addresses for > connections by calling bind(2) prior to calling connect(2). If you fail > to do this, the operating system will select a source IP address for > you. This'll often be the IP of the outgoing interface. Well, if the OS selects the source IP, can't I just modify the code that selects it? Will this work all the time, or just when the application lets the OS select an address for it? > Unless your particular application explicitly supports the selection of > source addresses, you're mostly out of luck. For instance, ping(8) > supports this (see the -S option). > > Cheers, > jan