The ARP (Address Resolution Protocol) command is a versatile tool available in Linux, and I’ve often found myself marveling at its vast potential. I’ve encountered many occasions where this simple command has saved the day. This network utility displays and modifies the Address Resolution Protocol (ARP) cache. The ARP cache is a table that stores the mapping of IP addresses to their corresponding MAC addresses.
Below, I’ve curated a list of my favorite and most frequently used arp commands in Linux. I’ve also shared the general syntax for each and included sample outputs to give you a clear idea of what to expect. Dive in!
Top 10 uses of ARP command in Linux
No. | Command Description | Command Syntax |
---|---|---|
1. | Displaying the ARP cache | arp |
2. | Adding an entry manually | arp -s <IPAddress> <HWaddress> |
3. | Deleting an entry | arp -d <IPAddress> |
4. | Displaying ARP entries for a specific interface | arp -i <interface> |
5. | Making the ARP entries permanent | arp -s <IPAddress> <HWaddress> temp |
6. | Reading entries from a file | arp -f <filename> |
7. | Displaying the ARP cache in numeric form | arp -n |
8. | Flushing out the ARP cache | ip -s -s neigh flush all |
9. | Making ARP entries read-only | arp -s <IPAddress> <HWaddress> pub |
10. | Suppressing the ARP header | arp -e |
These commands offer a quick reference guide for those who wish to glance through and quickly get the gist of what the arp
command can offer. Let’s now dig into the details of each of those commands.
1. Displaying the ARP cache
Syntax: arp
Example:
$ arp
Address HWtype HWaddress Flags Mask Iface
192.168.0.1 ether 08:00:27:6c:62:f4 C eth0
This is the most basic usage of the arp command. By running it without any arguments, you can display the ARP cache. The cache lists IP addresses and their associated MAC addresses. It’s like peeking into your system’s address book. I love this command for its simplicity!
2. Adding an entry manually
Syntax: arp -s <IPAddress> <HWaddress>
Example:
$ arp -s 192.168.0.100 00:1a:2b:3c:4d:5e
There have been moments when I needed to add a specific IP and MAC address pairing manually. While I don’t use this daily, it’s been a lifesaver in particular situations.
3. Deleting an entry
Syntax: arp -d <IPAddress>
Example:
$ arp -d 192.168.0.100
As much as I like adding things, sometimes you just need to declutter. This command removes a specific entry from the ARP cache, making it perfect for those moments when you need a fresh start.
4. Displaying ARP entries for a specific interface
Syntax: arp -i <interface>
Example:
$ arp -i eth0 Address HWtype HWaddress Flags Mask Iface 192.168.0.1 ether 08:00:27:6c:62:f4 C eth0
Different interfaces, different ARP tables. It’s always good to filter results based on interfaces. Especially useful if you, like me, sometimes deal with multiple interfaces and need precise data.
5. Making the ARP entries permanent
Syntax: arp -s <IPAddress> <HWaddress> temp
Example:
$ arp -s 192.168.0.100 00:1a:2b:3c:4d:5e temp
For those rare occasions when you want an ARP entry to survive a reboot, this is your go-to command. I don’t find myself needing this often, but I’m always glad I know it when I do.
6. Reading entries from a file
Syntax: arp -f <filename>
Example:
$ arp -f /path/to/file
The ability to read from a file simplifies bulk tasks. I find it handy during system setups where I have a predefined list of entries to load.
7. Displaying the ARP cache in numeric form
Syntax: arp -n
Example:
$ arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.0.1 ether 08:00:27:6c:62:f4 C eth0
If, like me, you prefer IP addresses in numeric form (without hostnames), this command is for you. Sometimes simplicity is just better.
8. Flushing out the ARP cache
Syntax: ip -s -s neigh flush all
Example:
$ ip -s -s neigh flush all
Technically, this isn’t the arp
command, but it’s closely related. I included this because I often find myself wanting to start fresh, and this command clears out the entire ARP cache. It’s like spring cleaning for your network!
9. Making ARP entries read-only
Syntax: arp -s <IPAddress> <HWaddress> pub
Example:
$ arp -s 192.168.0.100 00:1a:2b:3c:4d:5e pub
By setting an entry to “pub”, you’re making it read-only. It’s a lesser-known feature but has been crucial when ensuring certain network setups remain unchanged.
10. Suppressing the ARP header
Syntax: arp -e
Example:
$ arp -e
192.168.0.1 ether 08:00:27:6c:62:f4 C eth0
If you’re not a fan of the ARP header (like me in certain scripting scenarios), this command is for you. It gives you just the essentials, and sometimes that’s all you need.
Closing thoughts
The ARP command in Linux offers more than meets the eye. These ten ways to use the command have enriched my Linux journey, and I hope they make your experience even better. Remember, the key to mastering Linux is continuous learning and experimentation. And as you experiment, you’ll find your own favorites among these commands.