arp Command in Linux
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
Overview
In the Linux universe, one command that is vital for network troubleshooting and configuration is the arp command. The arp command, short for 'Address Resolution Protocol', is a protocol used to find the host's MAC (Media Access Control) address given the IP address. This utility is vital for network administration and understanding the mapping between a machine's IP and MAC addresses.
Syntax of arp Command in Linux
The basic syntax of the arp command in Linux is as follows:
Where:
- [-vn]: The -v option stands for verbose, and -n stands for numerical. The verbose option provides detailed output, while numerical gives numeric IP addresses avoiding domain name resolution.
- [-H type] [-i if]: -H allows you to specify the hardware type. -i lets you specify the name of the network interface.
- -a [hostname] | -d hostname [pub] | -s hostname ether_addr [temp] | -s hostname pub [only] [proxy]: -a displays the arp cache. -d deletes an entry. -s creates a new entry. The optional 'hostname', 'ether_addr', and other flags further refine these operations.
Options in arp Command in Linux
-
-a: Displays the current ARP table entries.
For example -
Output:
This command lists all entries in the ARP table. The output shows the IP address, MAC address and the interface used.
-
-d: Deletes an entry from the ARP table.
For example -
This command deletes the ARP entry for the IP 192.168.1.1.
-
-s: Creates a new entry in the ARP table.
For example -
This command adds a new entry to the ARP table, linking the IP address 192.168.1.2 with the MAC address 00:11:22:33:44:55.
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Example Usages
-
Display ARP table:
Output:
Explanation: Using 'arp' without any option displays the ARP table showing IP, MAC address, and the interface name.
-
Adding an ARP table entry:
Explanation: Creates a new ARP entry for the IP address 192.168.1.3 and the MAC address 00:aa:bb:cc:dd
.
Tips
-
ARP entries are temporary and may be deleted after a period of time or upon reboot. To create permanent entries, consider updating the ARP configuration files.
-
Incorrect use of arp command can affect network operations. Always double-check before deleting or adding entries.
Turn Learning into Career Growth
Advanced Use Cases of arp Command in Linux
-
Delete all ARP entries:
Explanation: This command combination deletes all entries from the ARP table. It uses awk to filter and construct delete commands, which are then executed by sh.
-
Display ARP entries for a specific interface:
Output:
Explanation: This command displays the ARP entries specifically for the network interface 'eth0'.
Conclusion
-
The arp command in Linux is a powerful tool for managing IP to MAC address mappings.
-
It is important for network administration and troubleshooting.
-
The command provides options for displaying, adding, and deleting ARP entries.
-
Though powerful, incorrect usage of the arp command can lead to network issues. Therefore, it's crucial to use it wisely and cautiously.




