Script to clear ARP

Hi,
I’m trying to write a script under Mikrotik 4.13 to clear ARP tables.

Right now I’ve got:

:put "Removing NAT..."
:local arpCount [/ip arp print count-only];
for i from=0 to=$arpCount do={
:put "/ip arp remove $i;"
/ip arp remove $i;
}

and the script output is always:

> /system script run deleteARP        
Removing NAT...
4
/ip arp remove 0;
interrupted
           no such item

Please can anyone tell me why the command /ip arp remove numbers=$i is not working correctly and how to solve this?

Thanks for any help!

/ip arp remove [find]

(May fail if arp table is empty)

it fails because ARP table is dynamic and while your script runs - some entries can be removed, that causes the problem.

Try this script:

:local dumplist [/ip arp find]
:foreach i in=$dumplist do={
    /ip arp remove $i
}

Hi there!

In the arp section on Terminal (i.e., /ip arp ), uou should use

remove [find]

or

:foreach ip in={[find]} do={remove "$ip"}

Hope it helps!

Thanks!