Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / Networking 1: Addresses and Routing

    ARP: From a Neighbour's IP Address to Its MAC Address

    ARP has no security. Any device can falsely answer "I'm 192.168.1.1!" and receive everyone's traffic

    Chapter 8 of 113 min read

    The Plain Picture#

    You're in a crowded hall and need to hand a note to "the person in seat 37", but you don't know what they look like. So you shout: "Who's in seat 37?" One person waves: "Me! I'm wearing the red jacket." Now you can walk over. You remember "seat 37 = red jacket" for a while so you don't have to shout again.

    The Real Name#

    ARP (Address Resolution Protocol) finds the MAC address that belongs to an IP address on the same LAN. Your computer keeps the answers in an ARP cache.

    Why it's needed: to send a frame on the LAN you need the neighbour's MAC address (Chapter 3), but you only know its IP address (Chapter 4).

    Under the Hood#

    Your laptop (192.168.1.37) wants to send a packet to the internet, so it needs the MAC address of its gateway 192.168.1.1 (Chapter 7):

    Output
      1. Laptop broadcasts to ff:ff:ff:ff:ff:ff (everyone, Ch 3):
             "Who has 192.168.1.1? Tell 192.168.1.37."
      2. Only the router replies, directly to the laptop:
             "192.168.1.1 is at 3c:84:6a:11:22:33."
      3. Laptop stores it in its ARP cache (for a few minutes) and sends the frame.

    See your ARP cache with arp -a (Mac and Linux).

    Note: you ARP for the gateway, not the far-away server. The server's MAC address is irrelevant to you — it's on a different LAN.

    Gotchas

    • ARP has no security. Any device can falsely answer "I'm 192.168.1.1!" and receive everyone's traffic — ARP spoofing. It's one reason public Wi-Fi is risky without encryption (HTTPS, Networking 3: DNS, HTTP and HTTPS).

    • ARP is for IPv4. IPv6 does the same job with a protocol called Neighbour Discovery.

    Check yourself

    3 questions
    1

    What problem does ARP solve?

    Show answer

    Finding the MAC address for an IP address on the local network.

    2

    To send a packet to a server on the internet, whose MAC address does your laptop look up?

    Show answer

    The default gateway's (the router's).

    3

    Why is ARP spoofing possible?

    Show answer

    ARP replies aren't verified; any device can claim to own an IP address.