Just noticed a script I've been using for ages that went through and dynamically updated address list entries via DNS to current IPs stopped working. It fails on the line /ip firewall address-list set $i address=$newip
It appears that $i is being parsed as *N where N is the item number of the address list item, and the set command does not want to accept the input with the * character. If I strip out the * it will work, but I don't think I should have to do that, and I most certainly didn't need to do that in the past.
# Loop through each entry in the address list.
:foreach i in=[/ip firewall address-list find] do={
# Get the first five characters of the list name
:set list [:pick [/ip firewall address-list get $i list] 0 5]
# If they're 'host_', then we've got a match - process it
:if ($list = "host_") do={
# Get the comment for this address list item (this is the host name to use)
:set comment [/ip firewall address-list get $i comment]
:set oldip [/ip firewall address-list get $i address]
:set newip [:resolve $comment]
# Resolve it and set the address list entry accordingly.
:if ($newip != $oldip) do={
:log info ("Updating address for " . $comment . " to " . $newip)
/ip firewall address-list set $i address=$newip
:log info "Done"
}
}
}