if there have no timeout (forever ban without time) then …it can’t import how can i modify this script ?
If mikrotik can add option for us to auto save the Address-List will be great . More user-friendly even you think it is not necessary (but i know a lot of people point out that such add function to save Address-List but mikrotik never listen) ![]()
if ( [/file get [/file find name=dynamic.txt] size] > 0 ) do={
:global content [/file get [/file find name=dynamic.txt] contents] ;
:global contentLen [ :len $content ] ;
:global lineEnd 0;
:global line “”;
:global lastEnd 0;
:global addrip “”;
:global list “”;
:global timeout “”;
:global end 0;
:do {
:set lineEnd [:find $content “\n” $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;
:if ( [:pick $line 0 1] != “#” and [:pick $line 0 1] != “F” and [:pick $line 0 2] != " #" and [:len $line ] > 40) do={
:set end [:find $line " " 27] ;
:set addrip [:pick $line 27 $end] ;
:set end [:find $line " " 5] ;
:set list [:pick $line 5 $end] ;
:set end [:find $line " " 59] ;
:set timeout [:pick $line 59 $end] ;
:put “IP: $addrip, list: $list, timeout: $timeout”
/ip firewall address-list add address=$addrip list=$list timeout=$timeout comment=“imported”
}
} while ($lineEnd < $contentLen)
}
I’m not a script guru at all, but I would think that there’s a way to redirect the output of a scrip to a file, and doing so, use the command
/ip firewall address-list export
This will dump the address lists to a txt file that contains exactly the commands needed to build the address list.
If you want to import from this script, then simply clear all address lists and run the script, and you’ll have a complete restore.