From owner-freebsd-net@FreeBSD.ORG Wed Mar 16 14:11:39 2011 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 DED85106566B for ; Wed, 16 Mar 2011 14:11:38 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mx1.sbone.de (bird.sbone.de [46.4.1.90]) by mx1.freebsd.org (Postfix) with ESMTP id 92D278FC16 for ; Wed, 16 Mar 2011 14:11:38 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id C110B25D3888; Wed, 16 Mar 2011 14:11:06 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 6573B159AF68; Wed, 16 Mar 2011 14:11:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id TZxtSMOx6VGU; Wed, 16 Mar 2011 14:11:04 +0000 (UTC) Received: from nv.sbone.de (nv.sbone.de [IPv6:fde9:577b:c1a9:31::2013:138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 078D8159AF67; Wed, 16 Mar 2011 14:11:03 +0000 (UTC) Date: Wed, 16 Mar 2011 14:11:03 +0000 (UTC) From: "Bjoern A. Zeeb" To: Georgi Iovchev In-Reply-To: <1786430936.20110316151336@pulsar.bg> Message-ID: References: <1786430936.20110316151336@pulsar.bg> X-OpenPGP-Key: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-net@freebsd.org Subject: Re: select default outgoin IP for adapter with multiple ips, may be bug 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: Wed, 16 Mar 2011 14:11:39 -0000 On Wed, 16 Mar 2011, Georgi Iovchev wrote: > Hello. > I am having some troubles configuring adapter with multiple ips, > And I believe I have found a bug. > > The explanation is a bit long... Here it is: > > XX.YY.2.33/30 at ISPs side used as my default gw > XX.YY.2.34/30 at my side > I have network XX.YY.95.0/24 routed to me > > I dont have internet on XX.YY.2.34, but I have on XX.YY.95.0/24 > I am trying to configure adapter vlan199 conected to ISP > to use ip XX.YY.95.1 as default ip (src-address) for outgoing traffic. > I expected that when I add XX.YY.95.1 as first IP and XX.YY.2.34 as second it will be ok. > But the order does not matter - XX.YY.2.34 is always used as outgoing IP. > When I ping google.com .. I dont get replies, > but when I ping -S XX.YY.95.1 google.com - I get replies. > > Here is the only way that I have found to select XX.YY.95.1 as default outgoing address: > add XX.YY.95.1/32 on the adapter, > create static route to my default gw (XX.YY.2.34), > create default route, > add the other ip to the adapter. > > ifconfig vlan199 create > ifconfig vlan199 vlan 199 vlandev fxp0 > ifconfig vlan199 up > ifconfig vlan199 XX.YY.95.1/32 > route add -host XX.YY.2.33 -iface vlan199 > route add default XX.YY.2.33 > ifconfig vlan199 add XX.YY.2.34/30 > > But drawback is that I cannot achieve such order in rc.conf. > (add ip then routes then again ip) > The other problem is that if delete the default gw and add it again, > or change it to the same one, then the default outgoing ip resets to XX.YY.2.34. > > This is why I think that there is someting wrong, Right, the order you add IPs and routes shouldn't matter. I wonder why it does. > may be bug may be I am doing it wrong I dont know. > I have tried this on FreeBSD 8.2-RELEASE. > I believe on older freebsd versions the default outgoing ip for adapter > is the one at the top from ifconfig adapter. FreeBSD since 7.2 has been doing "more proper" source address selection for unbound outgoing connections. The solution is called bind. Another solution to try might be setfib(8). /bz -- Bjoern A. Zeeb You have to have visions! Stop bit received. Insert coin for new address family.