Community discussions

MikroTik App
 
myorcac
just joined
Topic Author
Posts: 2
Joined: Mon Dec 20, 2021 10:33 am

IPv6 DHCP Client "Prefix" Variable Without Expiry Time

Mon Jan 31, 2022 5:08 pm

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!
 
pe1chl
Forum Guru
Forum Guru
Posts: 10194
Joined: Mon Jun 08, 2015 12:09 pm

Re: IPv6 DHCP Client "Prefix" Variable Without Expiry Time  [SOLVED]

Mon Jan 31, 2022 6:46 pm

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...
 
myorcac
just joined
Topic Author
Posts: 2
Joined: Mon Dec 20, 2021 10:33 am

Re: IPv6 DHCP Client "Prefix" Variable Without Expiry Time

Tue Feb 01, 2022 1:04 pm

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

Who is online

Users browsing this forum: No registered users and 21 guests