Community discussions

MikroTik App
 
garther
just joined
Topic Author
Posts: 2
Joined: Sat Nov 27, 2010 1:43 pm

Script to clear ARP

Sat Nov 27, 2010 1:47 pm

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!
 
User avatar
LatinSuD
Member Candidate
Member Candidate
Posts: 181
Joined: Wed Jun 29, 2005 1:05 pm
Location: Spain
Contact:

Re: Script to clear ARP

Mon Nov 29, 2010 11:09 pm

/ip arp remove [find]

(May fail if arp table is empty)
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Script to clear ARP

Tue Nov 30, 2010 3:03 pm

it fails because ARP table is dynamic and while your script runs - some entries can be removed, that causes the problem.
 
pekar
just joined
Posts: 1
Joined: Wed Jul 11, 2012 11:23 pm

Re: Script to clear ARP

Wed Jul 11, 2012 11:26 pm

Try this script:
:local dumplist [/ip arp find]
:foreach i in=$dumplist do={
    /ip arp remove $i
}
 
chapeupreto
just joined
Posts: 6
Joined: Wed Jul 21, 2010 5:49 pm

Re: Script to clear ARP

Thu Feb 12, 2015 2:17 pm

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!