Linux Commands

What is the arp command in Linux

The arp stands for the “Address Resolution Protocol” and it makes changes in the kernel’s table which contains the arp addresses. It communicates with the IPv4 networks and resolves the IP address of any other machine into the physical address which is known as the MAC (Media Access Control) address. In this follow-up, we are going to explain the arp command and its utilization in Linux.

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:

$ sudo apt install 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:

$ ping 192.168.18.135

To confirm the connection with the device of IP address 192.168.18.135, execute the following arp command:

$ arp

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:

$ arp -a 192.168.18.135

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:

$ arp -v

Similarly, to display the above output in numeric form, run the command using the “-n” flag:

$ arp -n

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”:

$ arp -d 192.168.18.135

To confirm the removal of the machine, again run the arp command:

$ arp

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:

$ man arp

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.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.