IPv6 地址更新脚本
用于当 RouterOS IPv6 更新时,主动向客户端广播旧地址过期
:local poolname "pool6"
:local ifname "bridge"
:global oldprefix;
:local newprefix;
:set $newprefix [/ipv6 pool used get [find info="bridge"] prefix];
:if ([ :typeof $oldprefix ] = "nothing") do {
:set $oldprefix $newprefix
}
:if ($newprefix != $oldprefix) do {
:log info "Kill IPv6 prefix, old prefix: $oldprefix, new prefix: $newprefix";
:ipv6 nd prefix add prefix=$oldprefix interface=$ifname on-link=yes autonomous=yes preferred-lifetime=0s valid-lifetime=0s;
:delay 5;
:ipv6 nd prefix remove [/ipv6 nd prefix find prefix=$oldprefix];
:set $oldprefix $newprefix;
}
IPv6 DHCP Rebinding 脚本
用于修复当 PPPoE 重新拨号时 IPv6 DHCP 卡在 Rebinding 状态
:local wan "pppoe-telecom"
:if ( [ /ipv6 dhcp-client get [ find interface=$wan ] status ] = "rebinding..." ) do={
/ipv6 dhcp-client release [ find interface=$wan ]
}
IPv6 自动更新当前 Prefix 到 Prefix Hint
如果提供了 IPv6 prefix hint,那么有可能拿到 hint 里的 prefix
:local interfaceName "pppoe-telecom";
:local oldIP6Prefix [ /ipv6 dhcp-client get [find interface=$interfaceName] prefix-hint ]
:local ip6Prefix [ /ipv6 dhcp-client get [find interface=$interfaceName] prefix ]
:set ip6Prefix [ :pick $ip6Prefix 0 [ :find $ip6Prefix "," ] ] ;
:if ($oldIP6Prefix != $ip6Prefix) \
do={
/ipv6 dhcp-client set prefix-hint=$ip6Prefix [find interface=$interfaceName]
:log info ("Update IPv6 Prefix Hint: " . $ip6Prefix);
}
IPv6 自动修改 MSS
可以极大缓解 IPv6 网页打不开的问题
/ipv6 firewall mangle
add action=change-mss chain=forward new-mss=clamp-to-pmtu passthrough=yes protocol=tcp tcp-flags=syn