Debian下IPv6设定主地址 Set primary IPv6 address under Debian Linux
Linux下选择IPv6主地址是按照一定规则来的 #RFC3484 (davidc)
- Prefer same address. (i.e. destination is local machine)
- Prefer appropriate scope. (i.e. smallest scope shared with the destination)
- Avoid deprecated addresses.
- Prefer home addresses.
- Prefer outgoing interface. (i.e. prefer an address on the interface we're sending out of)
- Prefer matching label.
- Prefer public addresses.
- 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