Debian下IPv6设定主地址 Set primary IPv6 address under Debian Linux

Linux下选择IPv6主地址是按照一定规则来的 #RFC3484 (davidc)

  1. Prefer same address. (i.e. destination is local machine)
  2. Prefer appropriate scope. (i.e. smallest scope shared with the destination)
  3. Avoid deprecated addresses.
  4. Prefer home addresses.
  5. Prefer outgoing interface. (i.e. prefer an address on the interface we're sending out of)
  6. Prefer matching label.
  7. Prefer public addresses.
  8. Use longest matching prefix.

如果你有一个/64的段,并且为网卡分配了多个同段地址的时候,Linux会自动选择最后添加的地址作为主地址。

要设定个性化主地址,可以在添加非主地址的时候加上[lifetime]属性,将preferred_lft设为0。Linux将自动地把这些地址排除在主地址选择范围之外。

例:

1 ip addr -6 add xx:xx:xx:xx::8888/xx dev eth0 # 这个地址将包括在主地址选择中
2 ip addr -6 add xx:xx:xx:xx::A/xx dev eth0 preferred_lft 0 # 这个地址不会当做主地址


Works Cited:

1.  davidc, "IPv6 Source Address Selection on Linux" May 11, 2009, Retrieved from http://www.davidc.net/networking/ipv6-source-address-selection-linux

posted @ 2012-05-12 14:27  MeteorRain  阅读(307)  评论(0编辑  收藏  举报