Created
October 18, 2025 19:36
-
-
Save dginhoux/cbc260893eaf1a5fb5b86928c15c3fb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## set old and new list name | |
# :global oldList "pub_cloud_mikrotik" | |
# :global newList "pub_cloud_mkt" | |
:global oldList "pub_cloud_mkt" | |
:global newList "pub_cloud_mikrotik" | |
################### | |
## ipv4 display old, generate new and display with duplicate protection | |
/ip firewall address-list export where list=$oldList | |
:foreach i in=[/ip firewall address-list find list=$oldList] do={ | |
:global addr [/ip firewall address-list get $i address] | |
:global comm [/ip firewall address-list get $i comment] | |
:if ([:len [/ip firewall address-list find list=$newList address=$addr]] = 0) do={ | |
/ip firewall address-list add list=$newList address=$addr comment=$comm | |
} | |
} | |
/ip firewall address-list export where list=$newList | |
## ipv4 change filter rules | |
/ip firewall filter export where dst-address-list="$oldList" | |
/ip firewall filter set [find where dst-address-list=$oldList] dst-address-list=$newList | |
/ip firewall filter set [find where src-address-list=$oldList] src-address-list=$newList | |
/ip firewall filter export where dst-address-list="$newList" | |
## ipv4 change nat rules | |
/ip firewall nat export where dst-address-list="$oldList" | |
/ip firewall nat set [find where dst-address-list=$oldList] dst-address-list=$newList | |
/ip firewall nat set [find where src-address-list=$oldList] src-address-list=$newList | |
/ip firewall nat export where dst-address-list="$newList" | |
## ipv4 change nat rules | |
/ip firewall mangle export where dst-address-list="$oldList" | |
/ip firewall mangle set [find where dst-address-list=$oldList] dst-address-list=$newList | |
/ip firewall mangle set [find where src-address-list=$oldList] src-address-list=$newList | |
/ip firewall mangle export where dst-address-list="$newList" | |
## ipv4 change raw rules | |
/ip firewall raw export where dst-address-list="$oldList" | |
/ip firewall raw set [find where dst-address-list=$oldList] dst-address-list=$newList | |
/ip firewall raw set [find where src-address-list=$oldList] src-address-list=$newList | |
/ip firewall raw export where dst-address-list="$newList" | |
## ipv4 delete old list | |
/ip firewall address-list remove [find where list=$oldList] | |
################### | |
## ipv6 display old, generate new and display with duplicate protection | |
/ipv6 firewall address-list export where list=$oldList | |
:foreach i in=[/ipv6 firewall address-list find list=$oldList] do={ | |
:global addr [/ipv6 firewall address-list get $i address] | |
:global comm [/ipv6 firewall address-list get $i comment] | |
:if ([:len [/ipv6 firewall address-list find list=$newList address=$addr]] = 0) do={ | |
/ipv6 firewall address-list add list=$newList address=$addr comment=$comm | |
} | |
} | |
/ipv6 firewall address-list export where list=$newList | |
## ipv6 change filter rules | |
/ipv6 firewall filter export where dst-address-list="$oldList" | |
/ipv6 firewall filter set [find where dst-address-list=$oldList] dst-address-list=$newList | |
/ipv6 firewall filter set [find where src-address-list=$oldList] src-address-list=$newList | |
/ipv6 firewall filter export where dst-address-list="$newList" | |
## ipv6 change nat rules | |
/ipv6 firewall nat export where dst-address-list="$oldList" | |
/ipv6 firewall nat set [find where dst-address-list=$oldList] dst-address-list=$newList | |
/ipv6 firewall nat set [find where src-address-list=$oldList] src-address-list=$newList | |
/ipv6 firewall nat export where dst-address-list="$newList" | |
## ipv6 change nat rules | |
/ipv6 firewall mangle export where dst-address-list="$oldList" | |
/ipv6 firewall mangle set [find where dst-address-list=$oldList] dst-address-list=$newList | |
/ipv6 firewall mangle set [find where src-address-list=$oldList] src-address-list=$newList | |
/ipv6 firewall mangle export where dst-address-list="$newList" | |
## ipv6 change raw rules | |
/ipv6 firewall raw export where dst-address-list="$oldList" | |
/ipv6 firewall raw set [find where dst-address-list=$oldList] dst-address-list=$newList | |
/ipv6 firewall raw set [find where src-address-list=$oldList] src-address-list=$newList | |
/ipv6 firewall raw export where dst-address-list="$newList" | |
## ipv6 delete old list | |
/ipv6 firewall address-list remove [find where list=$oldList] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment