There’s always chance, but someone needs to convince MikroTik. Before that happens, you’re on your own. After a not really enjoyable masochistic session with RouterOS scripting, I’m pretty sure it’s doable in some way with that. Here is what I came up with (DHCPv6 client lease script):
:if ($"pd-valid" = 1) do={
:log info ("### acquired prefix: ".$"pd-prefix")
} else={
:log info ("### lost prefix: ".$"pd-prefix")
:local Addresses [/ipv6 address find from-pool=dhcp-pool]
:log info $Addresses
:foreach Address in=$Addresses do={
:local Tmp [/ipv6 address get $Address address]
:local Prefix ([:pick $Tmp 0 ([:len $Tmp] - 4)]."/64")
:log info ("Prefix: ".$Prefix)
:local Interface [/ipv6 address get $Address interface]
:log info ("Interface: ".$Interface)
:do {
/ipv6 nd prefix add interface=$Interface prefix=$Prefix preferred-lifetime=0 valid-lifetime=0
} on-error={
:log warn "failed: /ipv6 nd prefix add interface=$Interface prefix=$Prefix preferred-lifetime=0 valid-lifetime=0"
}
}
}
It’s basic proof of concept, which almost works. Aside from zero robustness, the problem is that when I’m trying to add prefix with zero lifetime, same dynamic prefix already exists, so it fails. But it has to exist, because otherwise I wouldn’t be able to find what I need to add. Also, when I look at it now, I could have started there, and not from IPv6 address. The solution would be either to somehow delay the command to add zero-lifetime prefix, after the old dynamic one is removed (I’m not sure how, except maybe with horrible hack using scheduler), or script the whole address assignment, instead of using from-pool (which may not be too difficult). If anyone wants to play further, I wish you good luck.
As for me, my frustration level is high enough to last me for a while. I don’t know if it’s just me, but RouterOS scripting is so unintuitive and unfriedly, as if it was one of design goals. For example, I wanted to get prefix properly from any address. So I have an address:
[sob@CHR5] > :put [/ipv6 address get [find interface=test2 from-pool=dhcp-pool] address]
2001:db8:0:123:234:5678:9abc:def0/64
And I want only first 64 bits:
[sob@CHR5] > :put ([/ipv6 address get [find interface=test2 from-pool=dhcp-pool] address] & ffff:ffff:ffff:ffff:
Script Error: cannot compute bitwise “and” of string and ipv6 prefix
Oops. But I can do this and it works:
[sob@CHR5] > :put ([:toip6 “2001:db8::123:234:5678:9abc:def0”] & ffff:ffff:ffff:ffff:
2001:db8:0:123::
Fine, then I’ll just do this:
[sob@CHR5] > :put ([:toip6 [/ipv6 address get [find interface=test2 from-pool=dhcp-pool] address]] & ffff:ffff:ffff:ffff:
[sob@CHR5] >
What?! (edit: I see it now, it doesn’t like address ending with /64, I’d have to strip that first; so ok, it’s my mistake, but it’s one such problem after another)