Networking Fundamentals

Ch.7: Understanding MAC Addresses

By Ayush Arora4 min read

Inspired by: YouTube

In previous chapters, we looked at IP addresses, subnet masks, and routers - all of which help us route data across local and remote networks. But there's a crucial piece of the puzzle we've glossed over: how do electrical signals actually find the right physical hardware chip?

To answer that, we need to talk about MAC Addresses.

What is a Network Interface?

Before understanding MAC addresses, we need to understand what they are attached to: a Network Interface.

Your laptop, router, or mobile phone communicates with other devices using a network interface. This is the physical piece of hardware that transmits and receives signals (wired or wirelessly). Examples include:

Because these are actual, physical pieces of hardware, we need a permanent way to address them.

Why do we need a MAC Address if we have an IP Address?

You might be wondering: If my laptop already has an IP address, why does it need another address?

The answer comes down to Virtual vs. Physical:

When you send a data packet from Host A to Host B on a local network, knowing the IP address isn't enough. The physical electrical signals need the exact physical MAC address of the destination device's hardware to successfully deliver the data!

The Structure of a MAC Address

So, what does a MAC address look like?

Unlike an IP address which is written in standard decimal numbers (like 192.168.1.1), a MAC address is written in Hexadecimal.

Hexadecimal Basics

While standard decimal numbers go from 0 to 9, hexadecimal numbers go from 0 to 15. Because we can't use two digits to represent a single number in hex (like 10), we use letters! Hexadecimal numbers are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

Size and Formatting

A MAC address is exactly 48 bits long, which equals 6 bytes (since 1 byte = 8 bits).

It is typically written as a set of six two-digit hexadecimal numbers, separated by either colons (:) or hyphens (-).

Each of these six pairs represents exactly 1 byte.

The Two Halves of a MAC Address

A 6-byte MAC address isn't just a random string of characters; it's logically split perfectly in half:

  1. First 3 Bytes (OUI): This stands for Organizationally Unique Identifier. When companies like Cisco, Intel, or Apple manufacture a network interface, they are assigned specific 3-byte codes. Every device made by that manufacturer will start with their specific OUI.
  2. Last 3 Bytes (Host): The remaining 3 bytes are assigned uniquely by the manufacturer to that exact physical piece of hardware. Even if two Intel network cards share the same first 3 bytes, their last 3 bytes will be completely different.

Just like an IP address is split into a Network ID and a Host ID, a MAC address is split into a Manufacturer ID (OUI) and a Device ID!

Finding Your Own MAC Address

Curious what your device's MAC address looks like? You can easily find it using your computer's terminal:

Next Steps

As a developer, you might not interact directly with MAC addresses every day. However, having a mental model of how physical hardware is addressed is crucial for understanding the OSI model, switches, and routing.