Chapters

MAC vs IP: why we need both

Every interface has two addresses. This chapter puts them side by side and shows why neither one can do the other's job.

Addressing and local delivery · chapter 8 of 34 · 3 min read

Side by side

PropertyIP addressMAC address
Size32 bits (4 bytes)48 bits (6 bytes)
Written as4 decimal octets, dots6 hex bytes, colons or dashes
Example192.168.1.23a4:83:e7:2b:91:0c
Set byThe network (DHCP, or by hand)The hardware maker
Changes?Yes, with every network you joinNormally noexcept private MACs and spoofing (ch 7)
Can repeat?Yes, across separate private networksNo, unique worldwidefor maker-set MACs
Has structure to route by?Yes: network part + host partNo: maker + serial, says nothing about location
JobGet across networks to the right oneLast step: the exact device on the local network
Lives inThe packet (chapter 1, wrap 2)The frame (chapter 1, wrap 3)

Size and notation

Different lengths, different notation. Here are the laptop's two addresses bit by bit:

IP address · 32 bits = 4 bytes · written in decimal, with dots: 192.168.1.23

MAC address · 48 bits = 6 bytes · written in hex, with colons: a4:83:e7:2b:91:0c

  • IP: the packet's address (chapter 1, wrap 2)
  • MAC: the frame's address (chapter 1, wrap 3)

Every byte is 8 bits, whichever way it is written. The IP is 4 of them, the MAC 6: humans see the IP in decimal with dots and the MAC in hex with colons.

An IP can repeat, a MAC cannot

Say a Kadé staff member works from their own home. Their laptop also got 192.168.1.23 from their home router. That is fine: the two home networks never mix, and on the internet each home shows its own public IP (chapter 10 explains how).

your home · 192.168.1.0/24Your laptopIP 192.168.1.23MAC a4:83:e7:2b:91:0cHome routerpublic 203.0.113.45staff member's home · 192.168.1.0/24Their laptopIP 192.168.1.23 same, fineMAC 70:3a:cb:04:e1:9f differentTheir routerpublic 203.0.113.88Internetsees only the public IPsprivate IPs repeat freelybecause these networks never mix

Wide by design - scroll it sideways.

A MAC is different. It must be unique within any network it joins, and maker-set MACs are unique worldwide. Even the two network cards in one laptop (WiFi and Ethernet, chapter 7) have different MACs.

IP gets you across networks

Follow the laptop's request to kade-api hop by hop. At every router, the destination IP is used to make a routing decision: each router checks its table (chapter 5) and picks the next step. The MAC pair is thrown away and rebuilt at every hop. Step through it:

Hop 1 · laptop → home router

Frame · MAC addresses · rebuilt on every hop

froma4:83:e7:2b:91:0claptop
to3c:84:6a:10:ee:01home router, LAN side

Packet · IP addresses and ports · carried inside the frame

from192.168.1.23:52814
to34.87.120.15:443

The router sees its own MAC in the frame, so it takes it. Then it reads the destination IP. That is not one of its networks, so its default route sends it to the ISP.

MAC finishes the job locally

A MAC has no such meaning. 42:01:0a:0a:01:0a says who made the card (or that the platform set it), not where it is. A router could not use it to pick a direction.

But once the packet reaches the right local network, the MAC is exactly what is needed: on that network, the frame is handed to the one interface whose MAC matches. In hop 4 above, kade-api accepts the frame because the destination MAC is its own.

Why we need both

IP · across the internet

Globally meaningful. Gets the data to the right local network, hop by hop.

Cannot pick one device on a shared wire by itself: something must turn it into a hardware address.

MAC · inside one network

Picks the exact interface for the current step.

No structure to route by, so it is useless beyond the local network.

One question is left. When a device needs to deliver locally, it knows the IP (of the target or the gateway) but needs the MAC. How does it get it? With ARP, which takes an IP and returns the matching MAC. That is the next chapter.

Summary

#IdeaIn one lineNew terms
1ComparedIP: 32-bit, dotted, changes, repeats, routable. MAC: 48-bit, hex, fixed, unique, local.
3RepeatingSame private IP in separate networks is fine; MACs stay unique
4IP's jobEvery router decides the next hop from the destination IPhop
5MAC's jobHands the frame to the exact interface, one link at a time
6The linkARP turns an IP into a MAC (next chapter)ARP

Try it yourself

IPs and MACs side by side

  • What to look for: Each line pairs one IP with one MAC, all on your local network.
  • Runs on: Linux · macOS / Windows: arp -a
  • From section: 1. Side by side
ip neigh

The routers on the way

  • What to look for: Only IPs appear. MACs of far-away routers are never visible to you.
  • Runs on: Windows: tracert 1.1.1.1
  • From section: 4. IP gets you across networks
traceroute 1.1.1.1

Spotted a mistake, or something unclear? Suggest an edit on GitHub