Understanding ARP:
Address Resolution Protocol (ARP) is used to map IP addresses to MAC (hardware) addresses on a local network. The ARP cache (or table) stores these mappings to avoid repeated ARP requests for known hosts. The arp
command allows you to view and manipulate this cache.
Entry Types:
- Dynamic entries: Automatically added by the ARP protocol and periodically refreshed
- Static entries: Manually added and persist until deleted or system reboot
- Permanent entries: Manually added and persist across reboots
- Proxy ARP entries: Allow the system to respond to ARP requests for an IP address on behalf of another host
Cache Entry States:
ARP entries typically have one of the following states:
- Complete: The entry has a valid IP-to-MAC mapping
- Incomplete: The system is currently trying to resolve the MAC address
- Stale: The entry was valid but hasn't been confirmed recently
- Failed: The ARP resolution process failed for this entry
Modern Alternatives:
While the arp
command is still widely used, modern Linux systems also provide these alternatives:
ip neigh
: From the iproute2 package, provides more functionality and consistent syntax with other network commands
ip -s neigh
: Shows statistical information about neighbor entries
ip neigh flush
: Clears entries from the neighbor table
Common Use Cases:
- Network troubleshooting: Identifying if a host is reachable at the link layer
- Security: Detecting potential ARP spoofing by monitoring unexpected changes
- Static mappings: Setting permanent IP-to-MAC mappings to avoid ARP traffic
- Proxy ARP: Allowing a host to act as a router for hosts that don't have a default gateway configured
ARP Security Considerations:
- ARP has no authentication mechanism, making it vulnerable to spoofing attacks
- Adding static ARP entries can help protect against ARP spoofing
- Monitoring for changes in ARP entries can help detect network attacks
- Tools like arpwatch or arpalert can be used to monitor for suspicious ARP activity
Interpreting ARP Output:
A typical ARP table entry contains:
- IP Address: The IPv4 address of the remote host
- HW type: Usually "ether" for Ethernet
- HW address: The MAC address (e.g., 00:11:22:33:44:55)
- Flags: Entry attributes like "C" (complete), "M" (permanent), "P" (publish)
- Mask: Netmask for proxy ARP entries
- Iface: The network interface this entry applies to
Proxy ARP Explained:
Proxy ARP allows a system to answer ARP requests on behalf of another host. This is used in scenarios like:
- Network Address Translation (NAT) setups
- VPN configurations where remote hosts appear to be on the local network
- Router redundancy protocols
- Network bridging scenarios
Limitations:
- Only works with IPv4 (not IPv6, which uses Neighbor Discovery Protocol instead)
- ARP entries are typically cached for a limited time (usually 5-20 minutes)
- The
arp
command cannot directly manipulate kernel ARP timeout settings
- May require root privileges for operations that modify the ARP cache
- The syntax varies slightly between different Unix/Linux distributions
Related Files:
/proc/net/arp
: Contains the current ARP table on Linux systems
/etc/ethers
: On some systems, stores static ARP entries
/etc/networks
: Contains network name to address mappings
Important Notes:
- Changes made with the
arp
command are not persistent across reboots unless configured in network startup scripts
- To make permanent changes, add the
arp
commands to network initialization scripts or use distribution-specific configuration files
- The
arp
command is being deprecated in favor of the ip neigh
command from the iproute2 package
- ARP is a layer 2 protocol and only works on the local network segment; it does not cross routers
Related Commands:
ip neigh
: Modern replacement for arp that manages the neighbor (ARP) table
arping
: Send ARP requests to probe a specific host
tcpdump
: Capture and analyze network traffic including ARP packets
arpwatch
: Monitor ARP activity for suspicious changes
rarp
: Reverse ARP lookup (get IP from MAC address)
ifconfig
: Configure network interfaces
route
: View and manipulate the routing table