What is an arp command in Linux
The arp command is one of the networking tools that converts the IP address of any machine into its MAC address. The arp command comes with the utility of the net-tools, so if the net-tools are not installed on your Linux, you can run the following command to install the net-tools:
To understand the use of the arp command, we will consider an example, we have another machine with the IP address 192.168.18.135, we will ping to this ip address:
To confirm the connection with the device of IP address 192.168.18.135, execute the following arp command:
In the above output, it is being confirmed that machine 192.168.18.135 is connected with our device. The description of the parameters in the output is as:
- Address: The IPv4 address of the machine
- HWtype: The type of connection in our case is through ethernet
- HWaddress: The MAC address of the machine
- Flags Mask: Tells the address is extracted manually, user-defined, or incomplete
- IFace: It is the interface name
To find the entries of a specific device for example 192.168.18.135, we will run the arp command with the “a” flag:
In the above output, the IP address of the connected machine is displayed with its MAC address and this connection is through ethernet on enp0s3. To find out detailed information about the device and its entries, we use the ”v” flag:
Similarly, to display the above output in numeric form, run the command using the “-n” flag:
The “n” flag displays the symbolic hosts, ports, and user names in numerical form. To remove the device from the arp list, we will use the “-d”:
To confirm the removal of the machine, again run the arp command:
The machine has been removed from the list of arp tables and to get more information about the arp command, we can access the manual of arp command:
Conclusion
The arp command is used to find the details of the connected devices when the protocol converts the IP to MAC. In this write-up, we have explained the arp command and its working with the help of some examples. We also discuss the flags used with the arp command to get specific information on Linux.