Good morning/evening everybody , here is a script to convert dynamic to static address list ips
You just need to change the name of the list which you want to convert to static
{
#Enter the name of the list at the end of the next line:
:local na “Facebook”
foreach i in=[/ip firewall address-list find (dynamic=yes)&&(list=$na)] do={
:local a [/ip firewall address-list get value-name=address $i]
/ip firewall address-list remove $i
/ip firewall address-list add address=$a list=Facebook
}}
Thanks!
Another way, for all lists:
# Convert dynamic to static in address-lists so dynamic records do not get deleted after a router reboot.
:local comment
:local address
:local list
:local disabled
:local found
:set found 0;
/ip firewall address-list
:foreach a in=[find] do={
:if ([get $a dynamic] = true) do={
/system logging disable 0
:set found 1;
:set comment [get $a comment]
:set address [get $a address]
:set list [get $a list]
:set disabled [get $a disabled]
remove $a
add address=$address list=$list comment=$comment disabled=$disabled
}
}
:if ($found=1) do={
/system logging enable 0
:log info "Dynamic to static conversion finished. System logging enabled."
:set found 0;
}
excellent script for converting dynamic ip to static in address-list;
thanks
Comment and disabling are not supported on dynamics, use that is more simple:
I understand why disable log, but hardcode it inside is wrong, can interfer with other script or function…
:local list
:local address
:log info "Dynamic to static conversion started"
/ip firewall address-list
:foreach a in=[find where dynamic=true] do={
:set list [get $a list]
:set address [get $a address]
remove $a
add list=$list address=$address disabled=no
}
:log info "Dynamic to static conversion finished"
A little modification maybe required for newer version i guess,
change
dynamic=true
to
dynamic=yes
Yes is true, from 6.34 must be used =yes
I modifu the script posted by other user, and I not notice the “wrong” true.