Skip to content

arp command in Linux

The Linux arp command allows users to view and manipulate the Address Resolution Protocol (ARP) cache and tables. It is a valuable tool for troubleshooting network connectivity issues and managing network configurations. With arp, users can display the ARP cache, add static ARP entries, and delete existing entries. By understanding how to use the ARP command effectively, users can ensure smooth and efficient network communication within their Linux system.

Terminal window
arp [OPTION] [ADDRESS]
OptionDescription
-a, —inetDisplay the ARP table for IPv4 addresses
-A, —addrDisplay the ARP table for all network addresses
-n, —numericShow numerical addresses instead of resolving hostnames
-d, —deleteDelete an entry specified by ADDRESS
-v, —verboseDisplay detailed information
-i, —deviceSpecify the network interface to operate on
-s, —setCreate a new entry for the specified ADDRESS
ParameterDescription
ADDRESSSpecifies the target network address
Terminal window
arp

Displays the ARP table showing the IP and MAC addresses of devices connected to the network.

Display ARP Table for a Specific Interface

Section titled “Display ARP Table for a Specific Interface”
Terminal window
arp -i eth0

Displays the ARP table for a specific network interface, such as eth0.

Terminal window
sudo arp -d 192.168.1.1

Clears the ARP cache entry for the specified IP address “192.168.1.1”.

Terminal window
arp 192.168.1.1

Resolves and displays the MAC address corresponding to the IP address “192.168.1.1”.

Terminal window
sudo arp -s 192.168.1.2 00:11:22:33:44:55

Adds a static ARP entry mapping IP address “192.168.1.2” to MAC address “00:11:22:33:44:55”.

Terminal window
sudo arp -d 192.168.1.2

Deletes the static ARP entry for the specified IP address “192.168.1.2”.

Terminal window
arp -n

Displays the ARP table with numeric values (IP and MAC addresses) without resolving hostnames.

Terminal window
arp -v

Displays additional information about the ARP cache entries such as age and hardware type.

To use the arp command in Linux, execute the following command:

Terminal window
arp

To display the ARP cache in Linux, use the following command:

Terminal window
arp -n

How do I add an entry to the ARP cache in Linux?

Section titled “How do I add an entry to the ARP cache in Linux?”

To add an entry to the ARP cache in Linux, you can use the following command format:

Terminal window
arp -s <IP_address> <MAC_address>

How do I delete an entry from the ARP cache in Linux?

Section titled “How do I delete an entry from the ARP cache in Linux?”

To delete an entry from the ARP cache in Linux, use the following command:

Terminal window
arp -d <IP_address>

To flush the ARP cache in Linux, you can use the following command:

Terminal window
ip -s -s neigh flush all

How do I set a specific timeout for ARP cache entries in Linux?

Section titled “How do I set a specific timeout for ARP cache entries in Linux?”

To set a specific timeout for ARP cache entries in Linux, execute the following command:

Terminal window
echo "600" > /proc/sys/net/ipv4/neigh/default/gc_stale_time

How do I prevent ARP cache poisoning in Linux?

Section titled “How do I prevent ARP cache poisoning in Linux?”

To prevent ARP cache poisoning in Linux, you can enable ARP inspection on your network switches and use tools like arpwatch to monitor ARP activities.

How do I view detailed information about an IP in the ARP cache in Linux?

Section titled “How do I view detailed information about an IP in the ARP cache in Linux?”

To view detailed information about an IP in the ARP cache in Linux, you can use the following command:

Terminal window
arp -a <IP_address>
  • Display and modify the IP-to-MAC address translation tables
  • View the ARP cache
  • Debug networking issues related to ARP
  • Spoofing attacks detection and prevention
  • Troubleshoot connectivity problems