From owner-freebsd-net@FreeBSD.ORG Thu Apr 10 14:10:29 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AEAE537B401 for ; Thu, 10 Apr 2003 14:10:28 -0700 (PDT) Received: from thalia.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id C89C943F93 for ; Thu, 10 Apr 2003 14:10:26 -0700 (PDT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-a137.otenet.gr [212.205.215.137]) by thalia.otenet.gr (8.12.9/8.12.9) with ESMTP id h3ALAE72013102; Fri, 11 Apr 2003 00:10:16 +0300 (EEST) Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.9/8.12.9) with ESMTP id h3ALAEKD097836; Fri, 11 Apr 2003 00:10:14 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.12.9/8.12.9/Submit) id h3AL0CKs084911; Fri, 11 Apr 2003 00:00:12 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 11 Apr 2003 00:00:12 +0300 From: Giorgos Keramidas To: Sashikiran Rachakonda Message-ID: <20030410210012.GA84656@gothmog.gr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: cc: freebsd-net@freebsd.org Subject: Re: Question Regarding IP Alias X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Apr 2003 21:10:30 -0000 On 2003-04-10 12:27, Sashikiran Rachakonda wrote: > > Hi,i have a question regarding the IP Alias. If i bind my interface to 2 > ip addresses say > > 1) ifconfig xl0 add w.x.y.z netmask 255.255.255.0 > 2) ifconfig xl0 add p.q.r.s netmask 255.255.0.0 > > Is there a way that i can force the packets coming-out of this > interface to have ipSrc = p.q.r.s and not w.x.y.z. My question is is > there a way that you can tell the interface to have the IPsrc set to > the one we want to, for all packets coming out of this interface. The default IP address that is used for packets that aren't explicitly set to something different is the first address of the interface, IIRC. 'First' here being something that depends heavily on the order of the ifconfig commands and the running kernel's code. Instead of relying on factors like this that you cannot control reliably, your programs should explicitly bind() a sockaddr_in structure with the p.q.r.s address. Then all outgoing packets of that socket will have the correct address. - Giorgos