TExcelTAD
Home › Computer Networking › MAC Addresses

MAC Addresses

Every Ethernet and Wi-Fi interface has a MAC address (Media Access Control address): a 48-bit number that identifies it on the local link. It is usually written as six bytes in hex, separated by colons or dashes:

text
3c:22:fb:91:0a:7e        Linux, macOS
3C-22-FB-91-0A-7E        Windows
3c22.fb91.0a7e           Cisco

All three are the same address. The data link layer uses MAC addresses to deliver a frame to the next device on the same link: a host, a router's interface, an access point.

Structure of a MAC address

Bits Meaning
First 3 bytes OUI (Organizationally Unique Identifier), assigned by the IEEE to a manufacturer
Last 3 bytes assigned by the manufacturer to each interface
Bit 0 of the first byte (I/G bit) 0 = unicast (one interface), 1 = multicast (a group)
Bit 1 of the first byte (U/L bit) 0 = universally administered (burned in), 1 = locally administered (set by software)
python · try it yourself
def parse_mac(text):
    cleaned = text.replace(":", "").replace("-", "").replace(".", "")
    if len(cleaned) != 12:
        raise ValueError(f"not a MAC address: {text!r}")
    return bytes.fromhex(cleaned)

def describe(mac: bytes):
    first = mac[0]
    kind = "multicast" if first & 0b01 else "unicast"
    admin = "locally administered" if first & 0b10 else "universal (burned-in)"
    if mac == b"\xff" * 6:
        return "broadcast", "(all 48 bits set)"
    return kind, admin

for text in ["3C-22-FB-91-0A-7E", "3c22.fb91.0a7e", "01:00:5e:00:00:fb",
             "ff:ff:ff:ff:ff:ff", "da:a1:19:6b:22:04"]:
    mac = parse_mac(text)
    pretty = ":".join(f"{b:02x}" for b in mac)
    kind, admin = describe(mac)
    print(f"{pretty}  OUI {mac[:3].hex(':')}  {kind:<9} {admin}")
3c:22:fb:91:0a:7e  OUI 3c:22:fb  unicast   universal (burned-in)
3c:22:fb:91:0a:7e  OUI 3c:22:fb  unicast   universal (burned-in)
01:00:5e:00:00:fb  OUI 01:00:5e  multicast universal (burned-in)
ff:ff:ff:ff:ff:ff  OUI ff:ff:ff  broadcast (all 48 bits set)
da:a1:19:6b:22:04  OUI da:a1:19  unicast   locally administered

Note the multicast and broadcast addresses: their I/G bit is 1. Real interfaces always have unicast addresses, and only use multicast and broadcast addresses as destinations.

Special destination addresses

Address Meaning
ff:ff:ff:ff:ff:ff broadcast: every device on the LAN accepts it (ARP requests, DHCP discover)
01:00:5e:xx:xx:xx IPv4 multicast (the low 23 bits of the multicast IP address)
33:33:xx:xx:xx:xx IPv6 multicast (the low 32 bits of the multicast IPv6 address)
01:80:c2:00:00:00 Spanning Tree Protocol between switches

The IPv4 mapping is a nice bit-manipulation exercise: copy the low 23 bits of the group address into 01:00:5e:00:00:00.

python · try it yourself
import ipaddress

def ipv4_multicast_mac(group):
    ip = int(ipaddress.IPv4Address(group))
    low23 = ip & 0x7FFFFF
    mac = 0x01005E000000 | low23
    return mac.to_bytes(6, "big").hex(":")

for group in ["224.0.0.1", "224.0.0.251", "239.255.255.250", "225.128.0.1"]:
    print(f"{group:<16} -> {ipv4_multicast_mac(group)}")
224.0.0.1        -> 01:00:5e:00:00:01
224.0.0.251      -> 01:00:5e:00:00:fb
239.255.255.250  -> 01:00:5e:7f:ff:fa
225.128.0.1      -> 01:00:5e:00:00:01

Because only 23 of the 28 variable bits of a multicast address survive, 32 different IP groups share each MAC address. 224.0.0.1 and 225.128.0.1 map to the same MAC.

Looking up the vendor

The OUI tells you who made the network card. Tools like Wireshark show the vendor name next to each address using the IEEE registry. Here is a tiny excerpt as a lookup table:

python · try it yourself
OUI = {
    "00:1a:2b": "Ayecom Technology",
    "00:50:56": "VMware",
    "08:00:27": "Oracle VirtualBox",
    "52:54:00": "QEMU/KVM (locally administered)",
    "b8:27:eb": "Raspberry Pi Foundation",
}

def vendor(mac):
    return OUI.get(mac.lower()[:8], "unknown vendor")

for mac in ["08:00:27:4F:1C:22", "b8:27:eb:12:34:56", "00:50:56:c0:00:08", "3c:22:fb:91:0a:7e"]:
    print(f"{mac.lower()}  {vendor(mac)}")
08:00:27:4f:1c:22  Oracle VirtualBox
b8:27:eb:12:34:56  Raspberry Pi Foundation
00:50:56:c0:00:08  VMware
3c:22:fb:91:0a:7e  unknown vendor

Your own MAC addresses

On Linux, ip link lists your interfaces and their MAC addresses (link/ether):

bash
ip link show

Sample output:

text
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 3c:22:fb:91:0a:7e brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether da:a1:19:6b:22:04 brd ff:ff:ff:ff:ff:ff permanent 70:9c:d1:5e:02:aa

On Windows use getmac or ipconfig /all; on macOS ifconfig en0.

MAC randomisation and privacy

Because a burned-in MAC address never changes, a phone that broadcasts it when scanning for Wi-Fi could be tracked from shop to shop. Modern phones and laptops therefore use a random, locally administered MAC per network (like da:a1:19:6b:22:04 above, whose second-lowest bit in the first byte is 1). This also means MAC addresses are not a reliable way to identify or authenticate a device: they are easy to change with one command.

Note: MAC addresses never leave the local network. When your packet crosses a router, the router builds a new frame with its own MAC as the source. A server on the Internet never sees your MAC address.

Test yourself

How many bits are in a MAC address?

  1. 32
  2. 48
  3. 64
  4. 128

What does the OUI part of a MAC address identify?

  1. The network the device is on
  2. The manufacturer of the interface
  3. The device's IP address
  4. The switch port

Which MAC address is a multicast address?

  1. 3c:22:fb:91:0a:7e
  2. 00:50:56:c0:00:08
  3. 01:00:5e:00:00:fb
  4. da:a1:19:6b:22:04