A MAC (Media Access Control) address is a 48-bit identifier assigned to a network interface controller (NIC) to identify it on a local network segment. It may be permanently burned into hardware by the manufacturer or software-assigned, and uniqueness is scoped to the relevant link or broadcast domain. It operates at Layer 2 of the OSI model and is used by Ethernet, Wi-Fi, and other IEEE 802-based protocols to address frames between devices on the same local link or segment.
In practice
In embedded systems, MAC addresses appear whenever a device connects to an Ethernet or Wi-Fi network. Microcontrollers with integrated Ethernet MACs, such as the NXP LPC1768 or STM32F4 series, typically require a MAC address to be assigned before the network stack can operate. This address is written into a peripheral register at initialization and used by the hardware to filter incoming frames, accepting only those addressed to the device or to broadcast/multicast addresses.
MAC addresses are 48 bits long and conventionally written as six colon- or hyphen-separated hex octets, for example `00:1A:2B:3C:4D:5E`. In the common globally administered (IEEE EUI-48) structure, the first 24 bits form the Organizationally Unique Identifier (OUI), assigned by the IEEE to a specific vendor, while the remaining 24 bits are the vendor-assigned device identifier. This structure applies only to globally administered addresses; locally administered addresses and some vendor schemes do not follow the IEEE-assigned OUI/device split. Devices in production should use a globally unique MAC address; embedded projects that require one typically obtain a block of addresses from the IEEE or purchase pre-programmed EUI-48/EUI-64 identifiers from vendors such as Microchip (in dedicated 24AA02E48 EEPROM ICs) or read them from a factory-programmed OTP region on the SoC itself.
In development and prototyping, it is common to use a locally administered MAC address (bit 1 of the first octet set to 1), which signals that the address was not assigned by the IEEE and is intended only for local use. Randomly generated or hardcoded development addresses are acceptable in a lab but must not ship in production without ensuring uniqueness within the deployment environment, since address collisions on a shared network can cause difficult-to-diagnose connectivity failures.
One subtle point relevant to embedded network drivers is byte ordering. Ethernet transmits MAC address bytes in the order they appear on the wire, most-significant byte first. However, some MAC peripheral registers store the address in little-endian word order, requiring the driver to reorder bytes when loading the address. The blog post "Endianness and Serial Communication" covers related byte-order considerations that apply here as well.
Frequently asked
Does every embedded device need a unique MAC address?
Any device that communicates on a shared
Ethernet or Wi-Fi segment should have a unique MAC address to avoid frame delivery conflicts. In practice, small isolated lab setups or point-to-point links sometimes tolerate duplicates, but shipping products with non-unique addresses onto a customer network can cause intermittent and hard-to-debug failures. Production devices should use either an IEEE-registered OUI block, a pre-programmed EUI-48 from a dedicated IC, or any other scheme that ensures uniqueness within the deployment environment.
Where is the MAC address stored on a typical embedded system?
Common storage locations include a dedicated serial
EEPROM (Microchip 24AA02E48 is a popular choice, since it ships with a factory-programmed EUI-48), internal OTP or
flash on the SoC, an external EEPROM on the board, or a fixed address compiled into firmware. Some SoCs, such as certain NXP i.MX and Microchip SAMA5 parts, factory-program a unique identifier in OTP that the BSP reads at boot.
What is the difference between a MAC address and an IP address?
A MAC address is a Layer 2 identifier that uniquely names a network interface on a local segment. An IP address is a Layer 3 identifier used for routing across networks.
ARP (IPv4) or NDP (IPv6) maps between the two: when a host needs to send a packet to an IP address on the local subnet, it broadcasts a request for the MAC address associated with that IP, then addresses the
Ethernet frame directly to that MAC.
What is a locally administered MAC address and when is it acceptable to use one?
Setting bit 1 (value 0x02) of the first octet marks an address as locally administered, indicating it was not assigned by the IEEE. This is acceptable for development, testing, closed networks, or any scenario where the device will never share a segment with equipment from an unknown source. It must not be used in shipping products that connect to arbitrary customer networks, since there is no global uniqueness guarantee.
How does the MAC peripheral use the address at the hardware level?
The
Ethernet MAC peripheral uses the stored address to filter incoming frames in hardware. It typically accepts frames whose destination matches the device unicast address, the broadcast address (FF:FF:FF:FF:FF:FF), or optionally configured multicast addresses. Frames that do not match are discarded before reaching the CPU, reducing
interrupt load. Some MACs support a promiscuous mode that disables filtering, which is useful for packet capture or network diagnostics.
Differentiators vs similar concepts
A MAC address (Layer 2, hardware-level, link-local scope) is often confused with an IP address (Layer 3, software-assigned, routable across networks). They serve different purposes: MAC addresses identify an interface on a local segment, while IP addresses identify endpoints across an internetwork. Another point of confusion is the MAC address versus the EUI-64, which is a 64-bit extended form used in IPv6 link-local address generation and in IEEE 802.15.4 (
Zigbee/Thread) networks; in IPv6 link-local address construction specifically, a 48-bit MAC address can be converted to EUI-64 by inserting the bytes FF:FE in the middle, though this is not a general conversion rule applicable to all MAC-like identifiers.