Share your love
Quickly Use arp command in Linux Networking in 2 Steps
This guide intends to show how to use arp command in Linux networking. ARP stands for Address Resolution Protocol. It is a networking protocol used to map an IP address to a corresponding physical (MAC) address on a local network. Also, it is essential for communication between devices on the same network segment. ARP operates at the data link layer of the OSI model and is responsible for resolving IP addresses to MAC addresses.
Now you can follow the steps below to start the ARP utility installation and command line usage on Linux distros.
Learn To Use arp command in Linux Networking
Before you start to complete this guide, you need to log in to your server as a non-root user with sudo privileges. You can use this instruction for all Linux distros such as AlmaLinux, Debian 12, Ubuntu 22.04, Rocky Linux, Fedora, etc.
Now follow the steps below to Use arp command in Linux Networking.
Step 1 – Install the arp command line utility on Linux
As you may know, the ARP command is an extension of the net-tools package. Also, it is pre-installed on most Linux distros. So you must have ARP utility installed by default on your Linux server. To verify this, you can check its version:
arp --version
In the output, you will see your net-tools version:
Output
net-tools 2.10
However, you may not have net-tools and arp installed on your server by default. To install it, you can use the following commands:
In Debian / Ubuntu, you can run the following command:
sudo apt install net-tools
For RHEL-based distros like AlmaLinux, Rocky Linux, and Fedora, you can use:
sudo dnf install net-tools
Once the net-tools package is installed, you should have access to the arp command on your Linux system.
Step 2 – How To Use arp Command in Linux?
Now that you have gotten familiar with the arp command and installed it on your Linux distro, you can start using it. Let’s begin with the general syntax.
General Syntax of arp command
The general syntax for the arp command in Linux is as follows:
arp [options] [hostname | IP_address]
- arp: This is the command itself, used to interact with the Address Resolution Protocol (ARP) cache.
- [options]: Optional command-line options that modify the behavior of the arp command.
- [hostname | IP_address]: Optional parameter specifying either the hostname or the IP address of the target device.
Common Options Used in arp command
Here we provide some of the most used options in the arp command including:
- -a: Display the current contents of the ARP cache.
- -s: Add an entry to the ARP cache manually.
- -d: Delete an entry from the ARP cache.
- -i [interface]: Specify the network interface to use (e.g., eth0, wlan0).
View ARP Cache in Linux
To see your current details of the ARP Cache on your Linux distro, you can use the following command in your terminal:
arp -a
In your output, you will see the IP address and corresponding MAC address of each entry.
Manually Add ARP Entry in Linux
If you plan to add an ARP entry cache on your Linux server manually, you can use the following syntax command:
sudo arp -s <IP_ADDRESS> <MAC_ADDRESS>
You need to replace the <IP_ADDRESS> with the IP address you want to add, and the <MAC_ADDRESS> with the corresponding MAC address.
Delete an Entry From ARP Cache
Also, you can easily delete an ARP Cachee entry from your list. To do this, you can use the following syntax:
sudo arp -d <IP_ADDRESS>
Flush ARP Cache List
If you plan to flush and clear your ARP cache list, you can simply run the command below:
sudo ip -s -s neigh flush all
List of Options and usage of the arp command
To get more options and usage of the ARP utility in Linux, you can run the help command or man page:
# arp -h
# man arp
Note: The sudo privileges are typically required to use options that modify the ARP cache, such as adding or deleting entries.
Conclusion
The arp command in Linux is a powerful tool for managing and troubleshooting network connectivity at the data link layer. At this point, you have learned to Use arp command in Linux Networking. Hope you enjoy it.
Also, you may like to read the following articles:
Apache2 service failed with result exit code – Fix Issue
Understanding Login Shell and Interactive Shell in Linux