Inside this Article
Definition of ARP
ARP is defined in RFC 826, which was published in 1982. It is a stateless protocol, meaning each request is processed independently without reference to previous requests. When a device wants to communicate with another device on the same local network, it needs to know the MAC address of the target device. If it does not have this information in its cache, it broadcasts an ARP request to all devices on the network, asking “Who has this IP address?” The device with the matching IP address then responds with its MAC address.How Does ARP Work?
Let’s break down the ARP process step by step:- Checking the Cache: When a device needs to communicate with another device on the local network, it first checks its ARP cache. This is a table that stores recent MAC-to-IP mappings. If the MAC address for the target IP is found, the device can immediately send the packet.
- ARP Request: If the MAC address is not in the cache, the device sends a broadcast ARP request. This request contains the sender’s MAC and IP addresses, and the target IP address. It is sent to the MAC broadcast address FF:FF:FF:FF:FF:FF, which is accepted by all devices on the network.
- ARP Reply: The device with the target IP address recognizes its address and sends an ARP reply. This reply contains the MAC address associated with the IP address. The reply is sent directly to the MAC address of the requesting device.
- Cache Update: Upon receiving the ARP reply, the original device updates its ARP cache with the new MAC-to-IP mapping. This entry will remain in the cache for a certain amount of time.
- Communication: With the MAC address now known, the device can send the packet directly to the intended recipient.
ARP Cache
The ARP cache is a crucial component of the ARP process. It is a table maintained by each device that stores the MAC addresses corresponding to IP addresses. Entries in the ARP cache can be of two types:- Dynamic Entries: These are the entries that are added to the cache as a result of an ARP reply. They are temporary and will be removed from the cache after a certain period of time if not used.
- Static Entries: These are manually configured by a system administrator and do not expire. They are useful in situations where you always want a certain IP address to map to a specific MAC address.
Types of ARP Messages
There are four types of ARP messages:- ARP Request: Sent by a device to request the MAC address corresponding to an IP address.
- ARP Reply: Sent by a device in response to an ARP request, providing its MAC address.
- Gratuitous ARP (GARP): Sent by a device to announce its IP and MAC address to the network, either when it boots up or when its MAC or IP address changes. This helps update the caches of other devices.
- Reverse ARP (RARP): Used by a device to request its own IP address when it only knows its MAC address. This is mostly obsolete and has been replaced by BOOTP and DHCP.
ARP vs RARP
While ARP maps an IP address to a MAC address, Reverse ARP (RARP) does the opposite. It allows a device to discover its own IP address if it already knows its MAC address. RARP is useful in situations where a device does not have a means to store its own IP address, such as diskless workstations or embedded systems. The device broadcasts its MAC address and a RARP server responds with the corresponding IP address. However, RARP has significant limitations. It requires a RARP server on every network segment and does not provide additional configuration information like a subnet mask or default gateway. Due to these limitations, RARP has largely been replaced by more robust protocols like BOOTP and DHCP.ARP Spoofing and ARP Poisoning
One of the major security concerns with ARP is that it does not have any built-in authentication mechanism. This vulnerability can be exploited in an attack known as ARP spoofing or ARP poisoning.In an ARP spoofing attack, a malicious actor sends falsified ARP messages over a local area network. These messages are designed to associate the attacker’s MAC address with the IP address of another host, such as the default gateway. This can allow the attacker to intercept data frames on the network, modify the traffic, or stop the traffic altogether. Here’s how it works:
- Normal ARP Operation: Normally, Host A wants to communicate with Host B. It sends an ARP request for Host B’s MAC address. Host B responds with its MAC address.
- ARP Spoofing: In an ARP spoofing attack, the attacker sends a fake ARP reply to Host A, claiming that Host B’s IP address is associated with the attacker’s MAC address.
- Intercepting Communication: If Host A believes the attacker and updates its ARP cache, it will send all data intended for Host B to the attacker instead. The attacker can then forward the data to Host B (so the communication still works), allowing them to intercept and read or modify the data in transit.
Proxy ARP
Proxy ARP is a technique by which a device on a network answers ARP requests intended for another device. This can be useful in certain network configurations. Here’s a typical scenario:- Devices A and B are on the same physical network but in different subnets.
- Device A wants to communicate with Device B, so it sends an ARP request for Device B’s IP address.
- The router, which is configured for Proxy ARP, recognizes that Device B is on a different subnet. It responds to the ARP request with its own MAC address.
- Device A sends the packet to the router, which then forwards it to Device B.
Gratuitous ARP
Gratuitous ARP (GARP) is a special type of ARP request where the source and destination IP addresses are both set to the IP address of the device issuing the packet, and the destination MAC address is set to the broadcast address FF:FF:FF:FF:FF:FF. The purpose of a GARP is to update the ARP caches of other devices on the network. A device will typically send a GARP in two situations:- Device Startup: When a device first joins a network, it will send a GARP to announce its IP and MAC addresses to the other devices on the network.
- IP Address Change: If a device’s IP address changes, it will send a GARP to inform the network of the new IP-to-MAC mapping.
ARP vs ICMP
ARP and ICMP (Internet Control Message Protocol) are both network layer protocols, but they serve different purposes. ARP, as we’ve discussed, is used to discover the MAC address associated with a given IP address on a local network. It operates at the data link layer (Layer 2) of the OSI model. ICMP, on the other hand, is used by network devices to send error messages and operational information about IP packet processing. It is an integral part of IP and operates at the network layer (Layer 3) of the OSI model. Some common uses of ICMP include:- Ping: The ping utility uses ICMP Echo Request and Echo Reply messages to test the reachability of a host and measure round-trip times.
- Traceroute: The traceroute utility uses ICMP Time Exceeded messages to discover the path packets take from the source to the destination.
- Destination Unreachable: If a router cannot forward an IP packet or if the packet’s destination host is not available, the router sends an ICMP Destination Unreachable message back to the source.
ARP in IPv6
In IPv6, the functionality of ARP is replaced by the Neighbor Discovery Protocol (NDP), which is a part of the ICMPv6 protocol. NDP serves several purposes, including:- Neighbor Solicitation (NS): Similar to an ARP request, an NS message is sent by a device to determine the link-layer address of a neighbor, or to verify that a neighbor is still reachable via a cached link-layer address.
- Neighbor Advertisement (NA): Similar to an ARP reply, an NA message is sent by a device in response to an NS message, providing its link-layer address.
- Router Solicitation (RS) and Router Advertisement (RA): Used by hosts to discover the presence of routers on the link, and by routers to announce their presence and provide configuration information to hosts.
- Redirect: Used by routers to inform a host of a better first hop for a destination.
Limitations of ARP
While ARP is a critical protocol for local network communication, it does have some limitations and vulnerabilities:- No Authentication: ARP does not provide any means of authenticating the sender of an ARP message. This leaves it vulnerable to spoofing attacks.
- Broadcast Overhead: ARP relies on broadcasting, which can lead to significant network overhead, especially on large networks.
- Cache Poisoning: Because ARP cache updates are trusted implicitly, an attacker can send fraudulent ARP replies to poison the cache of a victim and intercept their traffic.
- No Confidentiality or Integrity: ARP messages are not encrypted and can be intercepted and modified by an attacker.
- Limited Scalability: ARP is designed for local networks and does not scale well to large, complex networks.
ARP Alternatives
While ARP is widely used, there are some alternatives and enhancements that address its limitations:- Static ARP: In small networks, the ARP cache can be manually configured with static mappings between IP and MAC addresses. This prevents ARP spoofing but doesn’t scale well.
- Reverse ARP (RARP): Used by diskless workstations to obtain their IP address. Largely obsolete and replaced by BOOTP and DHCP.
- Proxy ARP: A technique where a device, usually a router, answers ARP requests on behalf of another device. Useful for connecting subnets at the link layer.
- Dynamic ARP Inspection (DAI): A security feature on some switches that validates ARP packets against a trusted database before updating the local ARP cache or forwarding the packet. Helps prevent ARP spoofing.
- Neighbor Discovery Protocol (NDP): Replaces ARP in IPv6 networks. Provides additional features like Secure Neighbor Discovery (SEND) for authenticating NDP messages.
- Link Layer Discovery Protocol (LLDP): A vendor-neutral protocol used by network devices for advertising their identity, capabilities, and neighbors. Can be used in conjunction with or instead of ARP in some environments.