select default outgoin IP for adapter with multiple ips, may be bug

Georgi Iovchev freebsd at pulsar.bg
Wed Mar 16 13:31:28 UTC 2011


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,
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.

Georgi Iovchev



More information about the freebsd-net mailing list