arp Command
Introduction
The arp
command is a networking utility used to display and modify the Address Resolution Protocol (ARP) cache in Linux and Unix-like operating systems. ARP is a crucial protocol that maps IP addresses to MAC (Media Access Control) addresses, enabling communication between devices on a local network.
The ARP cache serves as a lookup table that helps devices find each other on a network without having to repeatedly use the ARP protocol for every packet. By maintaining this cache, network performance is significantly improved as devices can quickly determine the hardware address associated with an IP address they need to communicate with.

Understanding ARP
Before diving into the command itself, it's important to understand what ARP does:
- Purpose: ARP translates IP addresses (logical addresses) to MAC addresses (physical hardware addresses)
- Layer: It operates between the Data Link Layer (Layer 2) and the Network Layer (Layer 3) of the OSI model
- Process:
- When a device wants to communicate with another device on the local network, it needs the MAC address
- If the MAC address isn't in the ARP cache, the device broadcasts an ARP request
- The device with the matching IP address responds with its MAC address
- Both devices update their ARP caches with this information
Basic Syntax
The basic syntax of the arp command is:
Where:
- options: Various flags that modify the behavior of the command
- hostname: The hostname or IP address to look up or modify in the ARP cache
Installation
The arp command is typically included in the net-tools
package, which may not be installed by default on newer Linux distributions. To install it:
Debian/Ubuntu-based Systems
Red Hat/CentOS/Fedora Systems
Arch Linux
Basic Usage
Displaying the ARP Cache
To display the entire ARP cache:
This shows all entries in the ARP cache, including IP addresses, MAC addresses, interface names, and entry types.
Displaying the ARP Cache in Numeric Format
To display the ARP cache with numeric addresses instead of resolving hostnames:
This is useful when you want to see the actual IP addresses or when DNS resolution is slow.
Displaying the ARP Cache for a Specific Host
To display the ARP entry for a specific host:
Or using an IP address:
Displaying the ARP Cache in Verbose Mode
For more detailed information:
The verbose mode provides additional information about each entry in the ARP cache.
Advanced Usage
Adding an ARP Entry
To manually add an entry to the ARP cache:
This creates a static ARP entry mapping the IP address 192.168.1.100 to the MAC address 00:11:22:33:44:55.
Deleting an ARP Entry
To remove an entry from the ARP cache:
This deletes the ARP entry for the specified IP address.
Adding Multiple ARP Entries from a File
To add multiple ARP entries from a file:
The file should contain entries in the format:
For example:
Specifying the Hardware Type
To specify the hardware address type:
Common hardware types include:
ether
(Ethernet)ax25
(AMPR AX.25)arcnet
(ARCnet)netrom
(AMPR NET/ROM)rose
(AMPR ROSE)dlci
(Frame Relay DLCI)fddi
(Fiber Distributed Data Interface)hippi
(HIPPI)irda
(IrLAP)
Specifying the Interface
To display ARP entries for a specific network interface:
This shows only the ARP entries associated with the specified interface.
Common Options
Option | Description |
---|---|
-a, --all | Display all entries in the ARP cache |
-n, --numeric | Display numeric addresses instead of resolving hostnames |
-v, --verbose | Display verbose information |
-d, --delete | Delete an entry from the ARP cache |
-s, --set | Create a new ARP entry |
-f, --file | Read new entries from a file |
-H, --hw-type | Specify the hardware address type |
-i, --device | Specify the network interface |
-e | Display the ARP cache in Linux/Unix format |
-D, --use-device | Use the hardware address of the specified interface |
Practical Examples
Example 1: Checking if a Device is on the Network
To check if a device with a specific IP address is on the network:
This sends a single ping to the IP address and then checks if an ARP entry was created.
Example 2: Detecting IP Address Conflicts
To check if multiple devices are using the same IP address:
This looks for duplicate entries in the ARP cache, which can indicate IP address conflicts.
Example 3: Securing Against ARP Spoofing
To create a static ARP entry for critical devices (like your default gateway):
This helps protect against ARP spoofing attacks by ensuring that the IP-to-MAC mapping for important devices doesn't change.
Example 4: Troubleshooting Network Connectivity
If you're having trouble connecting to a device:
Example 5: Clearing the ARP Cache
To clear the entire ARP cache (requires root privileges):
Note: This uses the ip
command, which is the modern replacement for many networking utilities including arp
.
Related Files
The ARP cache information is stored in the kernel and can be accessed through:
/proc/net/arp
: Contains the current ARP table/etc/ethers
: Can be used to configure static ARP entries
Comparison with Modern Alternatives
arp vs. ip neighbor
The ip neighbor
command from the iproute2
package is the modern replacement for arp
:
arp Command | ip neighbor Equivalent |
---|---|
arp | ip neighbor show |
arp -n | ip -n neighbor show |
arp -s 192.168.1.100 00:11:22:33:44:55 | ip neighbor add 192.168.1.100 lladdr 00:11:22:33:44:55 dev eth0 |
arp -d 192.168.1.100 | ip neighbor del 192.168.1.100 dev eth0 |
The ip neighbor
command offers more features and is actively maintained, while arp
is considered legacy.
Troubleshooting
Common Issues
Incomplete ARP Entries
If you see entries marked as "incomplete":
This means that an ARP request was sent, but no response was received. Possible causes include:
- The device is turned off
- The device is not connected to the network
- A firewall is blocking ARP requests or responses
- Network interface issues
Stale ARP Entries
ARP entries can become stale if a device's MAC address changes (e.g., after replacing a network card). To fix this:
This removes the stale entry and forces a new ARP request.
Permission Denied
If you get "Permission denied" when trying to modify the ARP cache:
You need to run the command with root privileges using sudo
.
Security Considerations
ARP Spoofing
ARP spoofing (or ARP poisoning) is a type of attack where an attacker sends fake ARP messages to associate their MAC address with the IP address of another device, such as the default gateway. This can lead to:
- Man-in-the-middle attacks
- Denial of service
- Session hijacking
To protect against ARP spoofing:
- Use static ARP entries for critical devices
- Consider using ARP monitoring tools
- Implement network segmentation
- Use encrypted protocols (HTTPS, SSH, etc.)
Best Practices
- Regularly Monitor ARP Cache: Check for unexpected or suspicious entries
- Use Static ARP Entries: For critical infrastructure devices
- Keep Systems Updated: Ensure your operating system and network tools are up to date
- Consider Network Security Tools: Tools like Arpwatch can monitor for ARP changes
Conclusion
The arp
command is a fundamental networking tool for viewing and manipulating the ARP cache in Linux systems. While it's gradually being replaced by more modern tools like ip neighbor
, understanding arp
is still valuable for network troubleshooting, diagnostics, and security monitoring.
By mastering the arp
command, system administrators and network engineers can effectively manage IP-to-MAC address mappings, troubleshoot network connectivity issues, and help secure their networks against ARP-based attacks.
Test Your Knowledge
Take a quiz to reinforce what you've learned
Exam Preparation
Access short and long answer questions for written exams