View address resolution cache using the ARP command in Linux

Home > Search > Linux commands
  by

The arp command  can be used to view the arp cache. In this example, there is an entry in thr arp cache that shows that the device with hostname fs1.example.com has MAC address 00:25:b4:cf:3e:81.

[root@server1 ~]# arp
Address          HWType     HWaddress           Flags  Mask    Iface
fs1.example.com  ether      00:25:b4:cf:3e:81   0              Eth0

 


IP Addresses

The -n (numbers) option can be used to display IP addresses instead of hostnames.

[root@server1 ~]# arp -n
Address          HWType     HWaddress           Flags  Mask    Iface
192.168.0.12     ether      00:25:b4:cf:3e:81   0              Eth0

 


Delete ARP records

The -d option can be used to delete records from the ARP table. For example, to delete the record with hostname fs1.example.com. 

[root@server1 ~]# arp -d fs1.example.com

 


The ip neighbour show command can also be used to view the arp cache. In this example, notice there is output with REACHABLE, STALE, and DELAY.

  • REACHABLE = The IP address to MAC address resolution is valid.
  • STALE = The IP address to MAC address resolution is valid but probalby unreachable. 
  • DELAY = The IP address to MAC address resolution is not valid.
[root@server1 ~]# ip neighbour show
192.168.0.101 dev eth0 lladdr 00:25:b4:cf:3e:81 REACHABLE
192.168.0.102 dev eth0 lladdr 00:25:b4:de:4a:25 STALE
192.168.0.103 dev eth0 lladdr 00:25:b4:a1:37:b4 DELAY

 

The ip neighbour add command can be used to add a record to the ARP cache. Notice the last field in "permanent". Possible options are:

  • permanent
  • noarp
  • stale
  • reachable
[root@server1 ~]# ip neighbour add 192.168.0.104 lladdr 00:25:b4:b2:25:c1 dev eth0 nud permanent

 

The ip neighbour del command can be used to delete a record from the ARP cache.

[root@server1 ~]# ip neighbour del 192.168.0.104 dev eth0

 

The ip neighbour chg command can be used to modify a records in the ARP cache. For example, to change the state from stale to reachable:

[root@server1 ~]# ip neighbour chg 192.168.0.102 dev eth0 nud reachable

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments