Community discussions

just joined
Topic Author
Posts: 1
Joined: Thu Aug 09, 2018 1:45 pm

IP address list export script

Thu Aug 09, 2018 1:53 pm

Dear community,

I'm struggling with creating a script capable to export one of my static firewall Address Lists, named ssh_blacklist, to a .rsc file. I tried doing so with:

/ip firewall address-list print where list="ssh_blacklist" ; export file=ssh_blasklist.rsc

- but it didn't work

/ip firewall address-list find ssh_blacklist ; export file=ssh_blasklist.rsc

- also didn't work

Any ideas?
Member Candidate
Member Candidate
Posts: 152
Joined: Thu Nov 17, 2011 6:51 pm

Re: IP address list export script

Tue Dec 25, 2018 12:34 pm

you can use this script to print it to txt file
/ip firewall address-list print file=ssh_blacklist where list=ssh_blacklist
User avatar
Posts: 10
Joined: Fri Nov 20, 2015 6:29 am
Location: localhost

Re: IP address list export script

Fri Dec 28, 2018 6:50 am

Try this:

	:local listName "Server"; #change this
	:local fileName "exported.rsc"; #change this
	:local buffer;

	:global filteredList [/ip firewall address-list print as-value where list=$listName && dynamic=no];
	:foreach i in=$filteredList do={
		:set $buffer ($buffer."add list=".$listName." address=".$i->"address"."; ");
	/file print file=$fileName where name="";
	:delay 1s;
	:set $buffer ("/ip firewall address-list; ".$buffer);
	/file set $fileName contents=$buffer;

NOTE : Please note that there is variable size limitation in RouterOS. It will affect your file result.
User avatar
Forum Guru
Forum Guru
Posts: 1302
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at

Re: IP address list export script

Fri Dec 28, 2018 9:54 am

Why do you like to export it?
If it is to examine the address, you can use send log hits to Syslog.
I do have black list for any trying a blocked port on my router. If you enter this log, router sends a message to my Syslog server (Splunk)
In Splunk I can see all IP address who and when they got in the log.

Here you can see how has tried to access my RDP, but ended are in a block access list.
See my signature for more info.
You do not have the required permissions to view the files attached to this post.
How to use Splunk to monitor your MikroTik Router


Who is online

Users browsing this forum: MSN [Bot] and 17 guests