ARP: finding a MAC address from an IP (and ARP spoofing)

☰ All 15 lessons

Two devices on the same Wi-Fi. They know each other's IP. And still, they can't send anything using just the IP. Why?

Inside a LAN, it's MAC addresses

In lesson 5 we saw that switches deliver data using MAC addresses. So inside a local network, whether it's a file transfer or any other communication, the delivery happens by MAC. If device A wants to send something to device B, it needs B's MAC. To send something out to the internet, it needs the router's MAC.

ARP: Address Resolution Protocol

What we usually know, though, is the IP. The protocol that finds the MAC for an IP is ARP, the Address Resolution Protocol.

Say A is 192.168.31.1 and B is 192.168.31.2. A knows B's IP but not its MAC, so A asks the whole network (a broadcast): "Who has 192.168.31.2? Tell me your MAC." Every device hears the question. B replies: "I'm 31.2, here's my MAC." A remembers the answer in its ARP table, and the transfer can start.

See your own ARP table: open a terminal and type arp -a. You'll see IPs on your network next to their MAC addresses.

ARP request, reply and ARP spoofingA 31.1B 31.2AttackerWho has 192.168.31.2? (broadcast)"Me! MAC B4:2E:…""No, me! MAC 66:6F:…" (fake)A's data goes to the attacker
  1. A broadcasts: "Who has 192.168.31.2?"
  2. B answers with its real MAC.
  3. An attacker answers too, with its own MAC, faking B.
  4. If A believes the fake answer, its data goes to the attacker.
Steps 1–2 are normal ARP. Steps 3–4 are ARP spoofing.

ARP spoofing

ARP has no way to check who is telling the truth. So when A asks "who is 31.2?", an attacker on the same network can answer before B does: "I'm 31.2, here's my MAC." If A believes it, every packet meant for B goes to the attacker instead. That's ARP spoofing (or ARP poisoning), a classic man-in-the-middle attack: the attacker can read the traffic, change it, or pass it on so nobody notices.

It's one reason HTTPS matters even on "safe" office or home Wi-Fi. For more Layer 2 attacks, read network attacks explained: ARP, DHCP and VLAN hopping.

Key takeaways

  • Inside a LAN, data is delivered by MAC address.
  • ARP finds the MAC for an IP by broadcasting "who has this IP?"
  • arp -a shows your device's IP-to-MAC table.
  • ARP spoofing: an attacker answers falsely and gets the traffic (man-in-the-middle).

Quick quiz

Pick an answer to check yourself. Answer both to mark this lesson done.

1. Which protocol finds the MAC address for an IP inside a LAN?

  1. A) DNS
  2. B) DHCP
  3. C) ARP
  4. D) TCP
Show answer

Answer: C. ARP, the Address Resolution Protocol, uses an IP address to find that device's MAC address.

2. What does the attacker do in ARP spoofing?

  1. A) Changes the Wi-Fi password
  2. B) Claims someone else's IP and gives their own MAC
  3. C) Changes a domain's IP in DNS
  4. D) Scans ports
Show answer

Answer: B. The attacker answers the ARP question before the real owner, so data goes to the attacker's MAC.

Frequently asked questions

What is ARP used for?

ARP finds the MAC address that belongs to an IP address on a local network, so data can be delivered inside the LAN.

What is ARP spoofing?

An attack where someone on the same network sends fake ARP replies, linking another device's IP to their own MAC so traffic is sent to them.

How do I see my ARP table?

Open a terminal or Command Prompt and type arp -a.

Do it hands-on.

This tutorial gives you the concepts. The 50 Days Ethical Hacking Challenge puts them to work in real labs, explained in Malayalam.