mikrotik log file code example

Example 1: mikrotik address list log into file

/ip firewall address-list print file=ssh_blacklist where list=ssh_blacklist

Example 2: mikrotik address list log into file

{
	: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;
}

Tags:

Misc Example