arp command examples (with examples)

arp command examples (with examples)

Show the current ARP table

Code:

arp -a

Motivation: The motivation for using this command is to display the current ARP (Address Resolution Protocol) table for your system. The ARP table contains information about the IP addresses and their corresponding MAC (Media Access Control) addresses that the system has recently communicated with. By examining the ARP table, you can easily identify the devices on your network and their respective MAC addresses.

Explanation: The -a option is used with the arp command to display the current ARP table. This option stands for “all” and shows all available entries in the ARP cache.

Example Output:

? (192.168.0.1) at 00:11:22:33:44:55 [ether] on eth0
? (192.168.0.2) at aa:bb:cc:dd:ee:ff [ether] on eth0

Delete a specific entry

Code:

arp -d address

Motivation: There may be situations where you need to remove a specific entry from the ARP cache. For example, let’s say a device’s MAC address has changed, but the previous entry still exists in your system’s ARP table. In such cases, using the arp -d command allows you to delete the outdated entry and ensure that your system maintains accurate MAC-to-IP address mappings.

Explanation: The -d option followed by the IP address is used to delete a specific entry from the ARP table. By specifying the IP address associated with the entry, you can remove it from the cache.

Example Output:

Deleted entry for 192.168.0.1

Create an entry in the ARP table

Code:

arp -s address mac_address

Motivation: Sometimes, you may need to manually add an entry to the system’s ARP table. This can be useful in certain scenarios, such as configuring a static IP address for a device or ensuring that a specific MAC address is associated with an IP address. Using the arp -s command allows you to create a custom entry in the ARP cache.

Explanation: The -s option followed by the IP address and the MAC address is used to manually create an entry in the ARP table. By specifying the IP address and the corresponding MAC address, you can add a new mapping to the cache.

Example Output:

Added entry for 192.168.0.1 00:11:22:33:44:55

By utilizing the arp command with its various options, you can effectively manage and manipulate the ARP cache in your system. These examples demonstrate how to view the current ARP table, delete specific entries, and create custom mappings. Understanding and utilizing these functionalities can help in troubleshooting network connectivity issues or ensuring accurate mapping of IP addresses to MAC addresses.

Related Posts

How to use the command 'llm' (with examples)

How to use the command 'llm' (with examples)

The ’llm’ command allows users to interact with Large Language Models (LLMs) through remote APIs and models that can be installed and run on their local machine.

Read More
How to use the command "git bug" (with examples)

How to use the command "git bug" (with examples)

The command “git bug” is a distributed bug tracker that utilizes git’s internal storage.

Read More
Creating Linux Filesystems with mke2fs (with examples)

Creating Linux Filesystems with mke2fs (with examples)

Introduction The mke2fs command is used to create a Linux filesystem within a partition.

Read More