From owner-freebsd-questions@FreeBSD.ORG Mon Feb 21 20:55:48 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 43EE516A4CE for ; Mon, 21 Feb 2005 20:55:48 +0000 (GMT) Received: from lilzmailso02.liwest.at (lilzmailso02.liwest.at [212.33.55.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D0E543D31 for ; Mon, 21 Feb 2005 20:55:47 +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 1D3Kai-0007cA-Nt; Mon, 21 Feb 2005 21:55:40 +0100 From: Daniela To: "Ted Mittelstaedt" , "Jan Grant" Date: Mon, 21 Feb 2005 22:55:47 +0000 User-Agent: KMail/1.5.3 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200502212255.47929.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: Mon, 21 Feb 2005 20:55:48 -0000 On Saturday 19 February 2005 07:45, Ted Mittelstaedt wrote: > > -----Original Message----- > > From: owner-freebsd-questions@freebsd.org > > [mailto:owner-freebsd-questions@freebsd.org]On Behalf Of Daniela > > Sent: Tuesday, February 15, 2005 1:30 PM > > To: Jan Grant > > Cc: Alin-Adrian Anton; questions@freebsd.org > > Subject: Re: How do I set the source address on a multi-homed host? > > > > > 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? > > Daniela, > > I have a FreeBSD 4 system setup as a NAT router, (it's real name is > nat-rtr.freebsd-corp-net-guide.com) that has 2 interfaces, the inside > is 192.168.1.1, the outside is 65.75.197.130 > > This is in fact a real live system and I'm using it right now. > > I have several FreeBSD systems on the 192.168.1 network on the > inside, and several FreeBSD systems on the 65.75.197 network on the > outside. > > If I log into nat-rtr.freebsd-corp-net-guide.com (doesen't matter > what interface I connect to) and I initiate a Telnet session from > nat-rtr.freebsd-corp-net-guide.com to a system on the 192.168.1 network, > once I'm logged into that system, issuing a "w -n" command shows me > logged in from 192.168.1.1 > > If on the other hand I log into a FreeBSD system that is on the > 65.75.197 network, and issue a "w -n" command, then it shows me as > being logged in from 65.75.197.130 No, it doesn't work this way for me. I was trying something very similar, only that I was using SSH instead of telnet, and it always shows me logged in from my outside IP. I guess it has something to do with my NAT setup, because I have a rule to divert all traffic to port 8668, which is open on the outside interface. I inserted this rule a long time ago, and all I understand about it is that this is necessary to let the other clients access the net. > If your setup isn't doing this, then it's screwed. If it IS working > this way and you think there's something wrong, then it is you that > are screwed. :-) > > Could you confirm behavior one way or another - up until now the > explanations and your responses have been extremely fuzzy (open to > a number of different interpretations) > > Ted