Overview
A MAC address is a hardware identifier burned into a network interface card and used to move frames across a single local link. An IP address is a logical network address assigned to a device and used to route packets across interconnected networks, including the internet. They operate at different OSI layers, working together to get data from one physical wire to a destination anywhere in the world.
Comparison Diagram
Comparison Table
| Aspect | MAC Address | IP Address |
|---|---|---|
| OSI layer | Layer 2 (Data Link) | Layer 3 (Network) |
| Format | 48-bit hex, e.g. 00:1A:2B:3C:4D:5E | 32-bit (IPv4) or 128-bit (IPv6) dotted/colon notation |
| Assignment | Burned in by the NIC manufacturer at production | Assigned by a network admin or DHCP server |
| Structure | Flat, no hierarchy — vendor prefix plus serial | Hierarchical — network portion plus host portion for routing |
| Persistence | Fixed to the physical interface (though spoofable) | Can change when a device moves to a different network |
| Role in delivery | Identifies the next-hop device on the local link | Identifies source and destination across the whole path |
| Behavior across hops | Rewritten by every router at each hop | Preserved end-to-end (barring NAT) |
| Resolution mechanism | Discovered via ARP (IPv4) or NDP (IPv6) | Discovered via DNS for hostnames |
Key Differences
- MAC address operates at Layer 2 while IP address operates at Layer 3.
- MAC is burned into hardware by the manufacturer, whereas IP is assigned by the network.
- A frame’s MAC addresses are rewritten at every hop, but the packet’s IP addresses stay end-to-end constant.
- ARP maps an IP address to the MAC address needed for delivery on the local segment.
- MAC addresses are flat with no structure, while IP addresses are hierarchical to support routing.
When to Use Each
MAC Address
- Switch Forwarding: Switches build MAC address tables to forward Ethernet frames to the correct port within a LAN segment.
- MAC-based Access Control: Wi-Fi or switch port security can allow or block traffic based on the known hardware address of a device.
- DHCP Reservations: Binding a specific IP lease to a device’s MAC ensures it always receives the same address on the network.
IP Address
- Routing Across Networks: Routers forward packets between distinct networks, including the internet, using destination IP addresses.
- Firewall and ACL Rules: Access policies are typically defined against source and destination IP ranges rather than hardware addresses.
- Subnetting and Network Design: The hierarchical structure of IP addresses lets engineers divide networks into logical, routable subnets.