宽带重新拨号会重新分配ipv6前缀,有的设备仍然优先使用旧的ip段,导致ipv6不能使用,可减小preferred_lifetime时间使旧的ip段快速失效。
openwrt dhcp提供preferred_lifetime参数设置preferred时间,需要将ra_useleasetime启用才有效,同时会将valid_lifetime修改为leasetime时间。
option leasetime '2h'
option ra_lifetime 1200
option ra_useleasetime '1'
option preferred_lifetime '10m'
odhcpd源码判断设置preferred_lifetime和valid_lifetime:
src/router.c
if (addr->preferred > (uint32_t)now) {
preferred = TIME_LEFT(addr->preferred, now);
if (iface->ra_useleasetime &&
preferred > iface->preferred_lifetime)
preferred = iface->preferred_lifetime;
}
valid = TIME_LEFT(addr->valid, now);
if (iface->ra_useleasetime && valid > iface->dhcp_leasetime)
valid = iface->dhcp_leasetime;
使用wireshark查看效果:
也可用tcpdump查看:
tcpdump -i br-lan -nn "icmp6 && ip6[40] == 134" -vv
标签:none