Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

The Short Answer

A MAC address (media access control address) is the hardware address of a network interface. It is 48 bits long and is normally written as six pairs of hexadecimal digits:

52:54:00:3a:7c:1e

Every Ethernet and Wi-Fi interface has one. Switches use it to deliver frames to the right port on a local network.

How It Is Written

FormatWhere you see it
52:54:00:3a:7c:1eLinux tools
52-54-00-3A-7C-1ESome desktop systems, labels
5254.003a.7c1eSome switches and routers

All three are the same address. Upper and lower case mean the same thing.

The Vendor Part and the Flag Bits

The first three bytes are the organizationally unique identifier (OUI), a block the IEEE assigns to a manufacturer; vendor lookup tools read only this part. The last three bytes are numbered by the manufacturer. Two bits of the first byte carry a meaning of their own:

  • Multicast bit: the lowest bit. When it is set, the address names a group, not one interface. ff:ff:ff:ff:ff:ff is the broadcast address that every device on the segment receives.
  • Locally administered bit: the second-lowest bit. When it is set, the address was chosen by software rather than assigned by the manufacturer. For a normal unicast address, the second hex digit is then 2, 6, a, or e, as in 52:54:00.

MAC Address and IP Address

The two work on different layers of the OSI model. The MAC address belongs to layer 2, the data link layer, and is used only between devices on the same local segment. The IP address belongs to layer 3 and is used end to end; see what is an IP address.

A protocol ties them together. For IPv4 it is ARP (Address Resolution Protocol): a host broadcasts "who has 203.0.113.1?" and the owner of that address answers with its MAC address. IPv6 uses neighbor discovery for the same job. Linux keeps the answers in its neighbor table:

ip neigh

Each line shows an IP address, the interface, the MAC address after lladdr, and a state such as REACHABLE or STALE. The entry for your gateway matters most: if it is missing or marked FAILED, the server cannot leave its subnet.

It Does Not Leave the Local Network

When a packet passes a router, the router builds a new frame with its own MAC address as the source and the next hop's as the destination. The IP addresses stay the same along the way; the MAC addresses change at every hop. A web server therefore never sees a visitor's MAC address, only the IP address.

How to See It on Linux

ip link show

The address appears after link/ether for each interface. For one interface only:

ip link show eth0
cat /sys/class/net/eth0/address

Interface names vary: eth0, ens3, and enp1s0 are all common. The ip command guide explains the rest of the output.

Virtual Machines Get Generated Addresses

A virtual server has no physical network card, so the hypervisor generates a MAC address for each virtual interface. KVM and QEMU use the prefix 52:54:00 by default, which is why many virtual servers show an address that starts with it. The address is stored in the virtual machine's configuration and stays the same across reboots; whether it survives a reinstall varies by provider.

Why Some Networks Tie an IP Address to a MAC Address

  • DHCP reservations: a DHCP server hands the same IP address to the same MAC address every time; see what is DHCP.
  • Anti-spoofing: data center networks often accept traffic from an IP address only when it comes from the MAC address it was assigned to. If you change a server's MAC address, or move an IP address to another machine yourself, traffic can stop. How this is enforced varies by provider.
  • Static ARP entries: some routers pin each IP address to one MAC address so that another device cannot claim it.

Randomized Addresses on Mobile Devices

Current mobile devices and laptops often use a random, locally administered MAC address for each Wi-Fi network, so that the device cannot be followed from one network to the next. For whoever runs the network, this means a reservation tied to a device's old address may stop matching.

Was this answer helpful?
Loading...