From owner-freebsd-net@FreeBSD.ORG Thu Mar 17 15:06:05 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 F0A291065672 for ; Thu, 17 Mar 2011 15:06:04 +0000 (UTC) (envelope-from freebsd@pulsar.bg) Received: from pulsar.bg (pulsar.bg [89.25.83.196]) by mx1.freebsd.org (Postfix) with ESMTP id AF2058FC0C for ; Thu, 17 Mar 2011 15:06:04 +0000 (UTC) Received: from [192.168.0.84] by pulsar.bg with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.74 (FreeBSD)) (envelope-from ) id 1Q0Em3-0009oE-7U for freebsd-net@freebsd.org; Thu, 17 Mar 2011 17:06:03 +0200 Date: Thu, 17 Mar 2011 17:06:11 +0200 From: Georgi Iovchev X-Priority: 3 (Normal) Message-ID: <1979209159.20110317170611@pulsar.bg> To: freebsd-net@freebsd.org In-Reply-To: References: <1786430936.20110316151336@pulsar.bg> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1251" X-Content-Filtered-By: Mailman/MimeDel 2.1.5 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: Thu, 17 Mar 2011 15:06:05 -0000 >>= ; 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 traf= fic. >> I expected that when I add XX.YY.95.1 as first IP and XX.YY.2.34 a= s second it will be ok. >> But the order does not matter - XX.YY.2.34 is always used as outgo= ing 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 def= ault 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 agai= n, >> 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 wond= er > 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 ad= apter >> 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 call= ed > bind. Another solution to try might be setfib(8). > /bz Thanks. But this is not a good solutio= n for me. I have tried the above example on FreeBSD 8.1-RELEASE box and the behaviour= is the same. May be it is kind of feature. Georgi Iovchev