arp command examples (with examples)
Show the current ARP table
Code:
arp -a
Motivation: The motivation for using this command is to display the current ARP (Address Resolution Protocol) table for your system. The ARP table contains information about the IP addresses and their corresponding MAC (Media Access Control) addresses that the system has recently communicated with. By examining the ARP table, you can easily identify the devices on your network and their respective MAC addresses.
Explanation:
The -a
option is used with the arp
command to display the current ARP table. This option stands for “all” and shows all available entries in the ARP cache.
Example Output:
? (192.168.0.1) at 00:11:22:33:44:55 [ether] on eth0
? (192.168.0.2) at aa:bb:cc:dd:ee:ff [ether] on eth0
Delete a specific entry
Code:
arp -d address
Motivation:
There may be situations where you need to remove a specific entry from the ARP cache. For example, let’s say a device’s MAC address has changed, but the previous entry still exists in your system’s ARP table. In such cases, using the arp -d
command allows you to delete the outdated entry and ensure that your system maintains accurate MAC-to-IP address mappings.
Explanation:
The -d
option followed by the IP address is used to delete a specific entry from the ARP table. By specifying the IP address associated with the entry, you can remove it from the cache.
Example Output:
Deleted entry for 192.168.0.1
Create an entry in the ARP table
Code:
arp -s address mac_address
Motivation:
Sometimes, you may need to manually add an entry to the system’s ARP table. This can be useful in certain scenarios, such as configuring a static IP address for a device or ensuring that a specific MAC address is associated with an IP address. Using the arp -s
command allows you to create a custom entry in the ARP cache.
Explanation:
The -s
option followed by the IP address and the MAC address is used to manually create an entry in the ARP table. By specifying the IP address and the corresponding MAC address, you can add a new mapping to the cache.
Example Output:
Added entry for 192.168.0.1 00:11:22:33:44:55
By utilizing the arp
command with its various options, you can effectively manage and manipulate the ARP cache in your system. These examples demonstrate how to view the current ARP table, delete specific entries, and create custom mappings. Understanding and utilizing these functionalities can help in troubleshooting network connectivity issues or ensuring accurate mapping of IP addresses to MAC addresses.