Page 1 of 1

Help me make this script faster

Posted: Sun Nov 15, 2020 4:08 am
by jonah1810
{
	:local addr
	:for x from=101 to=119 step=2 do={
	:for i from=0 to=254 do={
	:set addr value=("10.100.$x." . $i)
	:if (0=[pick  [/ip firewall mangle print count-only where src-address=($addr)] 0]) do={
	:if [/ip firewall address-list find address=($addr) = true && list="Streamer"] do={
	[/ip firewall mangle add action=passthrough chain=forward src-address=($addr)]
	}
   }
  }
 }
}
First checks if src address is in mangle and if it isn't puts all addresses with list="Streamer" into Mangle for tracking purposes.

this scans a lot of IP's and takes about 10s on my 4011. I was trying to figure out a foreach loop to go through every address-list entry (Instead of every possible address) but I cannot for the life of me get the foreach loop to do what I want.

Re: Help me make this script faster

Posted: Sun Nov 15, 2020 10:42 am
by BartoszP
:for i from=0 to=254 do={
	:set addr value=("10.100.$x." . $i)
	:if (0=[pick  [/ip firewall mangle print count-only where src-address=($addr)] 0]) do={
You do a lot of scans with "pick" ... 10*255 of them
Just an idea ... try to substitute it with foreach loop with proper where clause.