IPv6 DHCP Client "Prefix" Variable Without Expiry Time

Hi Mikrotik community,

I am using the script below to detect and send email notifications in case of ISP assigned IPv6 prefix change on a WAN interface. I scheduled this script to run every second. ROS version is 7.1.1.

:global prefix6;
:local thisip [/ipv6 dhcp-client get [find where interface=wan1] prefix];

:if ($prefix6 != $thisip) do={
    /tool e-mail send to="email@email.com" subject="IPv6 Prefix Changed" body="IPv6 Prefix Changed";
    set prefix6 $thisip;
}

However, this leads to my mailbox being pounded with “false alarm” email notifications saying my WAN IPv6 prefix has changed which in fact it hasn’t, due to ROS pulling the ISP assigned prefix PLUS its expiry time for the “prefix” variable. As this script runs every second, I am getting 1 false alarm email per second as the expiry time keeps changing.


/system script environment print

#  NAME                     VALUE                                                                        
0  prefix6              2404::/56, 21m39s

I am wondering if there’s an alternative “prefix” variable which doesn’t include the prefix expiry time?

Thanks!

Why don’t you strip everything after the comma from the string?
Anyway, do not run such scripts every second. There is no need to do that and it causes you difficulties…

Thank you pe1chl!

Below is the amended script which is working as intended.

:global prefix6;
:local rawip [/ipv6 dhcp-client get [find where interface=wan1] prefix];
:local thisip [:pick $rawip 0 [:find $rawip ","]]

:if ($prefix6 != $thisip) do={
    /tool e-mail send to="email@email.com" subject="IPv6 Prefix Changed" body="IPv6 Prefix Changed";
    set prefix6 $thisip;
}