Chapters

MAC addresses

Chapters 2 to 6 were about IP addresses. But the frame in chapter 1 also carried a second kind of address, and the router's MAC kept coming up in every chapter since. This chapter explains what that address is.

Addressing and local delivery · chapter 7 of 34 · 6 min read

Two addresses on every interface

MAC stands for Media Access Control. A MAC address identifies one piece of network hardware: a specific network interface. An IP address identifies where a device currently sits in a network, and it is given out by the network.

IP address · logical

Given by the network (DHCP). Can change. Used to find the way across networks.

192.168.1.23

MAC address · physical

Set by the hardware maker. Normally stays the same. Used for delivery inside one local network.

a4:83:e7:2b:91:0c

A physical network interface (chapter 2) is real hardware that sends and receives signals, so it needs an address of its own. Every hardware interface has a MAC, even when it has no IP:

InterfaceIPMACNote
en0 · WiFi192.168.1.23a4:83:e7:2b:91:0cThe one we followa chip with an antenna: radio signals
en1 · Ethernetnonea4:83:e7:5c:02:7dNo cable, so no IPbut the hardware still has its MAC
Bluetoothnonea4:83:e7:2b:91:0dShort-range radioits own interface, its own MAC
lo0 · loopback127.0.0.1noneNot hardwarenothing is sent on a wire, so no MAC is needed

Why an IP is not enough

An IP address is given by whatever network you join, so the same laptop gets different IPs over one week:

WhereIPMAC (WiFi)
Home, Monday192.168.1.23a4:83:e7:2b:91:0c
Home, after router restart192.168.1.31a4:83:e7:2b:91:0c
Kadé office, staff WiFi172.16.1.12a4:83:e7:2b:91:0c
Café10.0.4.17a4:83:e7:2b:91:0c
Bold = changed. The IP says where the laptop is right now. The MAC says which piece of hardware it is.

The format: 6 bytes = 48 bits

A MAC address is always 6 bytes = 48 bits, everywhere. Each byte is written as two hex digits (so a4 is one byte). Only the separator changes with the tool you use:

Where you see itSame address, written as
macOS, Linuxa4:83:e7:2b:91:0c
WindowsA4-83-E7-2B-91-0C
Cisco network geara483.e72b.910c
Upper or lower case does not matter. a4 and A4 are the same byte.

Hexadecimal in two minutes

Decimal uses 10 symbols (0 to 9). Binary uses 2 (0 and 1). Hexadecimal (hex, base 16) uses 16: 0 to 9, then A, B, C, D, E, F. After 9, instead of moving to two digits, hex carries on with letters up to F, which is 15.

  1. 000000
  2. 110001
  3. 220010
  4. 330011
  5. 440100
  6. 550101
  7. 660110
  8. 770111
  9. 881000
  10. 991001
  11. A101010
  12. B111011
  13. C121100
  14. D131101
  15. E141110
  16. F151111

Top: hex digit. Middle: its decimal value. Bottom: its 4 bits. The highlighted digits are the letters that come after 9.

One hex digit is exactly 4 bits, so two hex digits are exactly one byte. That is why hex is used for MACs and for the byte dumps in chapter 1. Reading a4: a = 1010, 4 = 0100, so the byte is 10100100, which is 10 × 16 + 4 = 164.

The two halves: maker and device

A MAC address splits into two halves, much like an IP splits into network part and host part (chapter 3):

OUI · the maker (3 bytes)

device part (3 bytes)

a4
83
e7
2b
91
0c

Each byte in hex (large) and in binary: one row of 4 bits for each hex digit. The two outlined bits at the end of the first byte have special meanings (section 6).

  • First 3 bytes: OUI (Organizationally Unique Identifier). Assigned to a hardware maker by the IEEE, the body that runs this system. Every maker has one or more.
  • Last 3 bytes: device part. Chosen by the maker, different for every interface it builds.

So devices from the same maker share the first half and differ in the second. The Kadé office bought its two PCs from the same maker:

DeviceMACReading it
Front desk PC3c:7c:3f:10:22:01same maker, device 10:22:01
Packing PC3c:7c:3f:10:9e:47same maker, device 10:9e:47
Look up the first 3 bytes in the IEEE's public OUI list and you get the maker's name. That is how router admin pages and network scanners show "Apple" or "Intel" next to a device.

Two special bits in the first byte

The last two bits of the first byte have fixed meanings. They explain two things you will meet soon: broadcast MACs (used by ARP) and random MACs.

Bit (of the first byte)If 0If 1
Last bitcalled I/GUnicast: one interfaceGroup: multicast or broadcastff:ff:ff:ff:ff:ff (all 1s) = every device
Second-last bitcalled U/LUniversal: set by the maker, uses a real OUILocal: set by softwarerandom "private" MACs, virtual machines
#MACFirst byte in binaryMeaning
1a4:83:e7:2b:91:0claptop WiFi10100100One interface, set by the maker
25e:1a:0b:c3:77:e2phone (chapter 3)01011110One interface, locally set: the phone uses a random "private" MAC
342:01:0a:0a:01:0akade-api in GCP01000010One interface, locally set by the cloud platform
4ff:ff:ff:ff:ff:ffbroadcast11111111Every device on the local network (ARP uses this)

"Fixed" has an exception: private MACs

A MAC is burned into the hardware, but the OS can send a different one. Modern phones and laptops (iOS, Android, Windows, macOS) do this on purpose: they use a random MAC for each WiFi network, so shops and cafés cannot track the same device across networks. The phone in the home DHCP table from chapter 3 (5e:1a:…) is doing exactly this.

One practical effect: a DHCP reservation is tied to a MAC. If a device switches to a new random MAC, its reservation no longer matches. For the office printer this is not a problem (printers use their real MAC), but it can surprise you with phones.

Try a MAC address

Paste any MAC in any format. The tool splits it and reads the two special bits.

OUI · the maker (3 bytes)

device part (3 bytes)

5e
1a
0b
c3
77
e2
macOS / Linux form
5e:1a:0b:c3:77:e2
Windows form
5E-1A-0B-C3-77-E2
Cisco form
5e1a.0bc3.77e2
Last bit of first byte
0 → one interface (unicast)
Second-last bit
1 → locally set (software)
Reading
Locally set: not a maker OUI. Probably a random private MAC or a virtual interface.

In the cloud

A cloud VM has a virtual network card, so the platform picks its MAC. You never set it. In GCP a VM's MAC usually starts with 42:01 and ends with its internal IP written in hex. For kade-api (10.10.1.10): 10 = 0a, 10 = 0a, 1 = 01, 10 = 0a, giving 42:01:0a:0a:01:0a. The 42 has the "locally set" bit on, as the table in section 6 shows.

Summary

#IdeaIn one lineNew terms
1What it isThe hardware address of one network interfaceMAC, Media Access Control
2WhyIPs change with the network; hardware needs a fixed ID
3Format6 bytes = 48 bits, hex, colons or dashes
4Hex16 symbols 0-F; one digit = 4 bits; two = a bytehexadecimal, nibble
5HalvesFirst 3 bytes = maker (OUI), last 3 = deviceOUI, IEEE
6Special bitsGroup vs one device; maker-set vs locally setbroadcast MAC, I/G, U/L
7ExceptionPhones and laptops use random private MACs per WiFiprivate MAC, MAC spoofing
9CloudThe platform assigns VM MACs (GCP: 42:01 + IP in hex)

Try it yourself

Every hardware interface and its MAC

networksetup -listallhardwareports

Interfaces with MACs

  • What to look for: The link/ether (or ether) value. Loopback shows 00:00:00:00:00:00 or none.
  • Runs on: Linux · macOS: ifconfig · Windows: getmac /v
  • From section: 1. Two addresses on every interface
ip link

The first byte in binary

python3 -c "print(format(0x5e,'08b'))"

The VM's MAC

  • What to look for: Starts with 42:01.
  • Runs on: on a GCP VM
  • From section: 9. In the cloud
curl -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/instance/network-interfaces/0/mac

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