Monday, September 19, 2011

clearing arp cache in linux

Address Resolution Protocol (also known as ARP) is one of the effective ways for searching the address of a host’s hardware(Ethernet). Sometimes wrong arp cache will make problems. You can clear all arp cache using following commands.

how to see current arp cache
root@cpaneltest [~]# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.1.1 ether 00:25:5E:1F:7A:BE C eth0
192.168.1.2 ether 6C:F0:49:C5:BF:6A C eth0
192.168.1.4 ether 6C:F0:49:C5:BF:26 C eth0
root@cpaneltest [~]#

Clearing arp cache with verbose
root@cpaneltest [~]# ip -s -s neigh flush all
192.168.1.1 dev eth0 lladdr 00:25:5e:1f:7a:be ref 17 used 28/27/81 REACHABLE
192.168.1.2 dev eth0 lladdr 6c:f0:49:c5:bf:6a ref 2 used 64/64/20 STALE
192.168.1.4 dev eth0 lladdr 6c:f0:49:c5:bf:26 ref 4 used 92/3/0 REACHABLE

*** Round 1, deleting 3 entries ***
*** Flush is complete after 1 round ***

current entries
root@cpaneltest [~]# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.1.1 (incomplete) eth0
192.168.1.2 (incomplete) eth0
192.168.1.4 ether 6C:F0:49:C5:BF:26 C eth0
root@cpaneltest [~]#

You can also delete particular arp entries using following command
root@cpaneltest [~]# arp -d 192.168.1.1
root@cpaneltest [~]# arp -d 192.168.1.2

Adding a static arp entry
root@cpaneltest [~]# arp -s 192.168.1.10 00:00:93:12:04:57

This will answer ARP requests for 10.0.0.2 on eth0 with the MAC address for eth1.
 #arp -i eth0 -Ds 10.0.0.2 eth1 pub

Delete the ARP table entry for 10.0.0.1 on interface eth1. This will match published proxy ARP entries and permanent entries.
#arp -i eth1 -d 10.0.0.1


Recommended Reading

1. Practical Guide to Linux Commands, Editors, and Shell Programming, A (2nd Edition)
2. Understanding the Linux Virtual Memory Manager
3. UNIX and Linux System Administration Handbook (4th Edition)

2 comments: