Subject: Re: Which IPv6 address should it choose?
To: Chris Ross <cross+netbsd@distal.com>
From: David Young <dyoung@pobox.com>
List: tech-net
Date: 04/07/2005 01:08:45
On Wed, Apr 06, 2005 at 12:43:54PM -0400, Chris Ross wrote:
> 
>   Okay.  I have a NetBSD 2.0.x system.  If you add more than one IPv4
> address, the second an so-on become "alias"es.  I think this just 
> happens
> automatically as part of there being more than one address.  The first
> address (seen by ifconfig(8) as not an alias) is the one that's used 
> when
> packets are sourced.
> 
>   But, with IPv6, there is just a list of addresses.  No aliases, 
> really.  So,
> in this case, how do I make the kernel choose a particular address when
> it sources packets?
> 
>   In my case, I'm adding a static IPv6 address which is in the same 
> network
> as the EUI-64 address that's chosen from a router-advertisement.  But,
> it seems that the host is sourcing packets with this static address, 
> rather
> than with the EUI-64 address which I'd like it to use for anything I
> haven't manually tied to the static address.
> 
>   Anyone know how to do this?

I think that you can do it with

% route add -net destination nexthop -ifa <source-address>

(Let me know whether that works, I may need to do that myself someday!)

Also, it may help to read the comments in
src/sys/netinet6/in6_src.c:in6_selectsrc.  It would be nice if we had
man pages in_selectsrc(9) and in6_selectsrc(9), or else if ip(4) and
ip6(4) explained.

Dave

-- 
David Young             OJC Technologies
dyoung@ojctech.com      Urbana, IL * (217) 278-3933