日度归档:2020年4月20日

RouterOS IPv6 实用脚本

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 ] 
}