I’ve been struggling a bit with IPv6 source address selection. Normally, when you initiate a new connection, you only specify the destination address (or have DNS resolve the name to an address). The choice of the source address is usually left to the OS by setting it to :: (IPv6’s version of 0.0.0.0).

RFC 6724 specifies how this selection should happen. Karl Auer explains it in a bit less painful way on his blog. But sometimes I want to influence the chosen address: how can I twist these rules to match my wishes? Karl also has an interesting post on this. In summary, use any combination of:

  • Deprecate the addresses that you don’t want to use: ip addr change 2001:db8::1:1/128 dev tun preferred_lft 0
  • Make your own label to group addresses: ip addrlabel family
  • Use privacy extension addresses