facebook youtube pinterest twitter reddit whatsapp instagram

What is arp Command in Linux and How Do I Use It?

The arp command in Linux is used to display and modify the Address Resolution Protocol (ARP) cache. ARP is a protocol that is used to map the IP addresses of network devices to their physical (hardware) addresses, such as their MAC address.

The ARP cache is a table that stores the mapping of IP addresses to physical addresses so that the system can quickly look up the physical address of a device when it needs to communicate with it.

Using The arp Command

To use the arp command, you must first open a terminal window on your Linux system. From there, you can use the following commands:

  • arp -a: This command displays the contents of the ARP cache, showing the mapping of IP addresses to physical addresses.
  • arp -d <IP address>: This command deletes the specified IP address from the ARP cache.
  • arp -s <IP address> <physical address> [<interface>]: This command adds a new entry to the ARP cache, mapping the specified IP address to the specified physical address. The optional <interface> parameter can be used to specify the network interface that the mapping applies to.
  • arp -v: This command enables verbose output, which will display additional information about the progress of the operation.

The arp command also provides some additional options that you can use to modify the behavior of the command. For example, you can use the -n flag to display the IP addresses and physical addresses in numeric form, rather than resolving them to hostnames and device names. You can view the full list of available options by using the man command to view the arp manual.

Examples of The Arp Command

Here are some examples of using the arp command in Linux:

Display the contents of the ARP cache

To display the contents of the ARP cache, you would use the following command:

arp -a

Delete an IP Address

To delete the IP address "192.168.1.5" from the ARP cache, you would use the following command:

arp -d 192.168.1.5

Add a New Entry to the ARP Cache

To add a new entry to the ARP cache that maps the IP address "192.168.1.5" to the physical address "00:11:22:33:44:55", you would use the following command:

arp -s 192.168.1.5 00:11:22:33:44:55

Display the IP addresses and Physical Addresses in Numeric Form

To display the IP addresses and physical addresses in numeric form, rather than resolving them to hostnames and device names, you would use the -n flag, like this:

arp -n -a

Add a New Entry To The Arp Cache By Reading it From a File

The below command reads the specified file and adds the entries in the file to the ARP cache. The file should contain one entry per line, in the format <IP address> <physical address> [<interface>].

arp -f <filename>

Display the ARP cache entries for a Specified Network Interface

The below command displays the ARP cache entries for the specified network interface.

arp -n -i <interface>

Delete all Entries from Arp Cache

This command deletes all entries from the ARP cache.

arp -n -d

Other Examples:

The below command displays the entries in the ARP cache that have been marked as "permanent", meaning that they will not be automatically removed from the cache.

arp -n -p

The below command displays the entries in the ARP cache that have a time stamp associated with them. The time stamp indicates how long ago the entry was last used.

arp -n -t

These examples demonstrate some of the more advanced features of the arp command. You can use these commands and options to perform more complex operations on the ARP cache on your Linux system.

Related Post(s)

  • The ac Command in Unix & Linux

    The ac command is a Unix utility that is used to display statistics about users' connect time. It displays the total connect time for all users or for a specific user. The connect time is the amount o

  • What is Linux adduser and addgroup commands

    The adduser and addgroup commands are Linux utilities that are used to create new user and group accounts on a Linux system. The adduser command is used to create a new user account, while the addgrou

  • What is alias and How Do I Use It in Linux?

    The alias command can be used to represent a longer command or series of commands in Linux. Aliases allow you to type a shorter and easier-to-remember name instead of the full command, which can save

  • What is unlias & How Do I Use It in Linux?

    The unalias command is a Linux utility that is used to remove an alias that has been defined on the system. To use the unalias command, you simply need to specify the name of the alias that you want

  • What is apt-get and How Do I Use It?

    apt-get is a command line tool used for managing packages on a Debian-based Linux system. It is a part of the Advanced Packaging Tool (apt) system, which is used to manage the installation, removal, a

  • What is ar Command in Linux and How Do I Use It?

    ar is a command line tool used for creating, modifying, and extracting files from archives. An archive is a single file that contains multiple files, often in a compressed format. GNU ar is part of the GNU Compiler Collection (GCC) and is commonly us