I am not very good at scripting, but am clear what I want. I hope somebody can help, or point me in a better direction.
I am using unimus to manage mikrotik devices. I have mikrotiks at 4 different sites:
Site1 10.1.x.y
Site2 10.2.x.y
Site3: 10.3.x.y
Site4 10.11.x.y
What I would like is for the script to somehow identify the site (router), and then add to the script an IP address with correct IP address. Is this possible?
Many thanks.
I am using this script (credit to unimus team) to create the address list:
Code: Select all
:do {
# set your list name and addresses desired in the list
:local listName "rtr-admins"
:local addresses {"10.x.y.z/32"="Change the x to match the site"}
# do not modify past this point
/ip firewall address-list
:local existing [find list=$listName]
:foreach r in=$existing do={
:local shouldDelete true
# this is inefficient, but ROS scripting has no way to break out of a loop :(
:foreach a,c in=$addresses do={
:if ([get $r address] = $a) do={
set $r comment=$c
:set shouldDelete false
}
}
:if $shouldDelete do={
remove $r
}
}
:foreach a,c in=$addresses do={
:if ([:len [find list=$listName address=$a]] = 0) do={
add list=$listName address=$a comment=$c
}
}
} on-error={
:put "Error - failed to apply address list configuration!"
}