How to clear the ARP cache on Linux?

There are several reasons when you might need to clear your ARP cache. There are two common ways on Linux systems, typically using the arp or ip utility. Depending on your Linux distribution and the availability, we suggest using the ip tool.

Clearing cache with ip

Newer Linux distributions have the ip utility. The ip tool has a more advanced way to clear out the full ARP cache.

ip -s -s neigh flush all

The first -s will provide a more verbose output. By adding one more, we can select the neighbor table. The neighbor table with the ip command equals both the ARP and NDISC cache. Note that the -s options are not available on all versions of the ip command. If it not supported for your version of ip, then simply remove them from the command.

The output of the flush all command will produce the following output.

The ARP cache is cleared, with verbose output

Clearing cache with arp command

The arp utility does not accept an option to clear the full cache. Instead, it allows to flush out entries found with the -d option.

arp -d 192.168.1.1

After deleting, have a look with the arp utility again to see the new list:

arp -n

The output of this command will typically show the active ARP entries.

The 192.168.1.1 entry now shows as incomplete, which means the ARP entry will be refreshed when it is needed again.

Conclusion

Depending on your distribution, the ip utility is quicker if you want to flush out the full ARP cache. For individual entries, the arp tool will do the job as quickly. Both tools are available for most distributions, including Arch Linux, CentOS, Debian, Fedora, RHEL, and Ubuntu.

Did this article to clear the ARP cache help you as well? Wonderful! Become part of the community and share this on social media to let others know. Got questions or suggestions? Join us in the comments.

These are your active connections (to your web server software). ARP is a protocol one level below these network connections. For details for flushing the ARP table, see the article on how to do that. For easily resetting the active connections, reload your web server daemon (Apache, nginx etc). The ports which state “LISTEN”, have a daemon running (53 = DNS, 631 = SAMBA or CUPS).

ip neigh flush all does not flush the cache completely, i.e. it does not delete the entries from the neighbor table. Instead it only clears the cached MAC addresses in the neighbor table, i.e. it sets all entries to state FAILED. But the entries with IP and IPv6 address are still kept in the cache. In former times the kernel expired entries after some time without usage, but unfortunately, this is not done anymore and there seems to be no way to remove entries manually.

Even a normal user could fill the neighbor cache with lots of entries which will stay until the next reboot. E.g. with “for n in {1..255}; do ping -c1 10.0.0.$n; done”

Linux and UNIX security automation

Lynis is a free and open source security scanner. It helps with testing the defenses of your Linux, macOS, and Unix systems. Typical use-cases for this software include system hardening, vulnerability scanning, and checking compliance with security standards (PCI-DSS, ISO27001, etc).