Community discussions

 
MikroX
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?
 
ronix
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

Dear
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
ericksetiawan
Trainer
Trainer
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
Jotne
Forum Guru
Forum Guru
Posts: 1303
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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.
blcok_list.jpg
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

MikroTik->Splunk
 

Who is online

Users browsing this forum: No registered users and 1 guest