How does ARP find the MAC address for an IP address?
MediumConceptARP, DHCP & NAT
Answer
ARP (Address Resolution Protocol) finds the MAC address that belongs to an IPv4 address on the same local network. It is needed because Ethernet and Wi-Fi deliver frames by MAC address, while IP knows only IP addresses.
- The sender first checks its ARP cache, a table of recent IP-to-MAC mappings. On a miss, it broadcasts an ARP request to
FF:FF:FF:FF:FF:FFasking who owns the target IP address; only the owner sends back a unicast ARP reply, and the sender caches the answer for a short time. - For a destination on another network, the host does not ARP for the remote IP. It ARPs for its default gateway (the router) and sends the frame there.
- ARP has no authentication, so an attacker can send fake replies (ARP spoofing) to intercept traffic. IPv6 replaces ARP with Neighbor Discovery.
Example: Host A (192.168.1.10) wants to send to host B (192.168.1.20) on the same LAN:
A -> broadcast : "Who has 192.168.1.20? Tell 192.168.1.10"
B -> A : "192.168.1.20 is at AA:BB:CC:11:22:33"
A caches 192.168.1.20 -> AA:BB:CC:11:22:33 and sends its frame to B
More in ARP, DHCP & NAT
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | How does DHCP assign an IP address to a device? Explain DORA. | Concept | Medium | Read the answer to How does DHCP assign an IP address to a device? Explain DORA. | |||
| 2 | How does ARP find the MAC address for an IP address? | Concept | Medium | Read the answer to How does ARP find the MAC address for an IP address? | |||
| 3 | What is NAT, and why is it used? | Concept | Medium | Read the answer to What is NAT, and why is it used? | |||
| 4 | What is ICMP, and how do ping and traceroute work? | Concept | Medium | Read the answer to What is ICMP, and how do ping and traceroute work? |