Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Mar 2011 14:11:03 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>
To:        Georgi Iovchev <freebsd@pulsar.bg>
Cc:        freebsd-net@freebsd.org
Subject:   Re: select default outgoin IP for adapter with multiple ips, may be bug
Message-ID:  <alpine.BSF.2.00.1103161409310.6104@ai.fobar.qr>
In-Reply-To: <1786430936.20110316151336@pulsar.bg>
References:  <1786430936.20110316151336@pulsar.bg>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1103161409310.6104>