Link to home
Start Free TrialLog in
Avatar of badreece
badreece

asked on

Flushing the arp table

How do you flush the arp table.  Do you have to do it one entry at a time, or can you just ditch the whole thing at once?

Thanks,
Bret
Avatar of bhagawatula
bhagawatula

What OS?
On HPUX and Solaris :
try route -f
to flush the table.
I think you need to add your default route again after this.

-f Flush the routing tables of all  gateway  entries.
    If  this  is  used  in conjunction with one of the     commands described above, route  flushes the gate-ways before performing the command.  

arp -d hostname

You could build a wrapper script to first get all hostnames with arp -a and then remove them with arp -d.

What Unix are we talking about here? If you are interested to know on how to flush the arp table in Solaris, this is the way you would do it:

as root:

: root@ns:/export/home/dserna2: arp -a
Net to Media Table
Device   IP Address               Mask      Flags   Phys Addr
------ -------------------- --------------- ----- ---------------
le0    209.220.74.1         255.255.255.255       00:10:67:00:3f:80
le0    ns                   255.255.255.255 SP    08:00:20:75:e9:29
le0    BASE-ADDRESS.MCAST.NET 240.0.0.0       SM    01:00:5e:00:00:00
: root@ns:/export/home/dserna2: ifconfig -a
lo0: flags=849<UP,LOOPBACK,RUNNING,MULTICAST> mtu 8232
    inet 127.0.0.1 netmask ff000000
le0: flags=863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST> mtu 1500
    inet 209.220.74.121 netmask ffffff00 broadcast 209.220.74.255
    ether 8:0:20:75:e9:29
: root@ns:/export/home/dserna2: ifconfig le0 209.220.74.121 ; arp -a
Net to Media Table
Device   IP Address               Mask      Flags   Phys Addr
------ -------------------- --------------- ----- ---------------
le0    ns                   255.255.255.255 SP    08:00:20:75:e9:29
le0    BASE-ADDRESS.MCAST.NET 240.0.0.0       SM    01:00:5e:00:00:00
: root@ns:/export/home/dserna2:



I don't know about other Unix versions. Hope that helps.
regardless of what version the following could be adapted:
 below should work for solaris on le0 interface

for arpent in `arp -a | grep "^le0" ` ; do
     arp -d $arpent
done

you could specify multiple/all interfaces by substituting grep with egrep and using the following:
egrep "^le0|^hme0|^net0"

etc...

regardless of what version the following could be adapted:
 below should work for solaris on le0 interface

for arpent in `arp -a | grep "^le0" | awk ''{ print $2 }' ` ; do
     arp -d $arpent
done

you could specify multiple/all interfaces by substituting grep with egrep and using the following:
egrep "^le0|^hme0|^net0"

etc...

ASKER CERTIFIED SOLUTION
Avatar of festive
festive

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of badreece

ASKER

That's going to work for me.
Thanks,
Bret