Clearing ARP and DNS Cache in Linux

clear linux cache

I received several odd messages on one of my Red Hat Linux servers yesterday morning, “Neighbor table overflow”, which made me go digging around. All I could find with some well-placed Googling was that the message could be related to bad or overflowing ARP cache. One fix might be to increase the available cache, and another to simply clear it. I decided to clear it and see what happens.

In any case, how do you clear ARP and DNS cache in linux?

  1. To view the ARP cache:
    • Open a terminal prompt
    • Become root on your machine
    • Run command: arp -n
  2. Clear ARP cache and validate:
    • Run command: ip -s -s neigh flush all
    • Run command: arp -n
    • Compare the last command results to the first (should have less rows)
  3. Clear the DNS cache:
    • Run command: service nscd restart
    • Should response with stopping and starting the service (see screen shot)

The error messages have not repeated since I cleared the cache. I have been adding/moving network cards recently to servers on my network, so that may be have been the real culprit.