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
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

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)



1 comment: