IPv6 Source Address Selection

Long time ago, I was wandering why the last IPv6 added to an interface was the one, that was used for outgoing connections, e.g. for SSH. Today I learned about IPv6 source address Selection and how it works in Linux.

Linux implements RFC 3484, “Default Address Selection for Internet Protocol version 6 (IPv6)”.

If you do not want extra addresses to be used for outgoing connections, you can prevent this by adding and extra parameter to the ip command:

ip -6 addr add 2001:db8::42/64 dev eth0 preferred_lft 0

If you’re already added the address to the interface, you can change it later:

ip -6 addr change 2001:db8::42/64 dev eth0 preferred_lft 0

References

IPv6 Source Address Selection on Linux
IPv6 Source Address Selection on Ubuntu