MAC Address vs IP Address: Key Differences Explained
MAC address vs IP address: layer, size, scope, how routers rewrite MACs per hop, ARP and IPv6 Neighbor Discovery, Linux commands and security notes.
A MAC address identifies a network interface on its local link: a 48-bit hardware address used by Ethernet and Wi-Fi to deliver frames to the next device. An IP address identifies a host on a network and is used by routers to carry packets end to end. The MAC changes at every hop, while the IP stays the same.
Both addresses appear in every packet capture, every ip command and every cloud network console, so mixing them up costs time when you troubleshoot. This guide compares them side by side, shows how a packet uses both, and gives the commands to inspect them on Linux. It sits in our networking series next to the guide on the OSI model, because the MAC belongs to layer 2 and the IP address to layer 3.
Key takeaways
- A MAC address is 48 bits (EUI-48 in IEEE terms), written as six pairs of hex digits. It works only inside one local network segment.
- An IPv4 address is 32 bits (RFC 791) and an IPv6 address is 128 bits (RFC 8200). Both are used for routing between networks.
- Every router rewrites the source and destination MAC address on a packet, but leaves the source and destination IP address alone, apart from NAT.
- IPv4 finds the MAC for an IP address with ARP (RFC 826). IPv6 uses Neighbor Discovery (RFC 4861) instead.
- A MAC address is a good identifier on a local link, but you can change it in software. It is not proof of identity.
MAC address vs IP address at a glance
| Property | MAC address | IP address |
|---|---|---|
| OSI layer | Layer 2, data link | Layer 3, network |
| Length | 48 bits (6 bytes) for a standard Ethernet or Wi-Fi interface | 32 bits for IPv4, 128 bits for IPv6 |
| Example | 3c:22:fb:1a:90:7e | 192.168.1.25 or 2001:db8::25 |
| Scope | One local link (a LAN segment or VLAN) | Local network or the whole internet, depending on the range |
| Assigned by | The manufacturer, using a block registered with the IEEE | An administrator, DHCP server, cloud platform or autoconfiguration |
| Changes when you move networks | No (unless randomized or changed) | Yes, normally |
| Changes on each hop | Yes, rewritten by every router | No (apart from NAT) |
| Used for | Delivering a frame to the next device | Routing a packet toward its destination |
| Resolved with | ARP (IPv4) or Neighbor Discovery (IPv6) | DNS maps names to IP addresses |
What is a MAC address?
A Media Access Control address is the link-layer identifier of a network interface. The IEEE Registration Authority describes EUI-48 and EUI-64 as globally unique identifiers most commonly used for IEEE 802 MAC addresses. The first 24 bits form the Organizationally Unique Identifier (OUI), which the IEEE assigns to a company as an MA-L block, and the manufacturer fills in the rest. The IEEE also sells smaller blocks (MA-M and MA-S) so that a small vendor does not need a full 16-million-address block.
The design goal is that two interfaces on the same segment never share an address. Our post on whether MAC addresses are really permanent and unique covers the exceptions: addresses can be changed in software, virtual machines get generated ones, and phones randomize them on Wi-Fi.
What is an IP address?
An Internet Protocol address identifies a host on a network and tells routers where to send a packet. RFC 791 defines IPv4 addresses as four octets (32 bits), split into a network part and a host part. RFC 8200 defines IPv6 addresses as 128 bits. The prefix length (CIDR notation, such as /24) marks where the network part ends. For that notation, see what CIDR notation is and why it is used.
Three IPv4 blocks are reserved for private use by RFC 1918: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Packets with these addresses should not be forwarded across the public internet, which is why home and office networks use NAT at the edge.
How a packet uses both addresses
Suppose a laptop at 192.168.1.25 opens a web page on a server at 203.0.113.10. The laptop knows the destination IP address but the server is not on its local link, so it sends the frame to its default gateway.
- The laptop checks whether
203.0.113.10is inside its own subnet. It is not, so the next hop is the gateway, for example192.168.1.1. - The laptop needs the gateway's MAC address. It asks with ARP, or reads it from its neighbor cache if it asked recently.
- The frame leaves with source MAC = laptop, destination MAC = gateway. The IP header inside says source
192.168.1.25, destination203.0.113.10. - The gateway strips the Ethernet header, looks up the IP destination in its routing table, finds the next hop, and builds a new frame with its own MAC as source and the next router's MAC as destination.
- This repeats until the last router, which sends a frame straight to the server's MAC address.
The IP header survives the whole trip, apart from changes made by NAT. The Ethernet header is rebuilt at every hop. That is the single most useful fact to remember when you read a packet capture. For the layer-by-layer view, read how data flows through the OSI stack.
How ARP and Neighbor Discovery connect the two
On an IPv4 network, a host that knows an IP address but not the MAC address broadcasts an ARP request. RFC 826 describes the protocol as converting a protocol address into the 48-bit Ethernet address for transmission on Ethernet hardware. The owner of the IP address answers directly (unicast) with its MAC address, and the asker caches the result. The full exchange, with packet fields, is in how ARP maps IP addresses to MAC addresses.
IPv6 does not use ARP. RFC 4861 (Neighbor Discovery for IPv6) covers the same job with ICMPv6: a node sends a Neighbor Solicitation to a solicited-node multicast address, and the target replies with a unicast Neighbor Advertisement carrying its link-layer address. Using multicast instead of broadcast means fewer devices have to process each request.
IPv6 also has a link to the MAC address in one place. RFC 4291 describes the Modified EUI-64 interface identifier: take the 48-bit MAC, insert 0xFF and 0xFE between the vendor and device halves, and invert the universal/local bit. Many systems now prefer privacy or stable-opaque identifiers instead, so do not assume an IPv6 address reveals the MAC.
Inspect both on Linux
# Link-layer details: interface name, state, MAC (link/ether)
ip link show
# IP addresses assigned to every interface (IPv4 and IPv6)
ip address show
ip -4 address show dev eth0
# The neighbor table: which IP maps to which MAC
ip neigh show
# Delete cached entries for one interface (does nothing without arguments)
sudo ip neigh flush dev eth0
In ip neigh show each entry carries a state. The ip-neighbour manual page defines reachable (valid until the reachability timeout expires), stale (valid but suspicious), incomplete (not yet resolved), failed (probes exceeded without an answer) and permanent (valid indefinitely, removed only by an administrator). A gateway stuck in incomplete or failed usually points to a layer 2 problem, such as the wrong VLAN or a dead switch port, rather than a routing error. More on this tool is in ping, traceroute and netstat for network diagnostics.
Where each address matters in daily work
| Task | Which address you use | Why |
|---|---|---|
| Static route or firewall rule between networks | IP | Routers and firewalls match on IP ranges. |
| DHCP reservation for a printer | MAC (to identify the device) and IP (to hand out) | The DHCP server needs a stable key for the client. |
| Switch port security or Wi-Fi access list | MAC | Switches forward frames by MAC address. |
| Troubleshooting duplicate address problems | Both | Two hosts with one IP produce flapping MAC entries. See what happens when two devices share an IP address. |
| Load balancer or Kubernetes Service | IP and port | Traffic is balanced at layer 3 and layer 4. |
| Packet capture analysis | Both | The Ethernet header shows who sent this hop, the IP header shows the end-to-end path. |
DHCP is a good example of the two working together. RFC 2131 says a server identifies a client by its client identifier if one is supplied, and otherwise by the hardware address in the chaddr field, combined with the subnet. It also warns that relying on the hardware address can surprise you if an interface moves to another machine.
Security notes for defenders
- MAC filtering is a convenience, not a security control. A MAC address travels in clear text on the local link and software can set a different one, so use it to tidy access lists and rely on authentication such as 802.1X or WPA for real access control.
- ARP has no authentication. A host on the same segment can answer for someone else's IP address, which is why switches offer features that validate ARP against DHCP records. Ask your network team whether dynamic ARP inspection (or the vendor's equivalent) is enabled.
- Monitor the neighbor table. A gateway IP that suddenly maps to a new MAC address deserves an alert.
- Segment with VLANs and subnets so broadcast traffic and ARP stay small. See how VLANs and subnets work together.
Why DevOps engineers should care
Containers and virtual machines each get a virtual interface with its own MAC address, and your orchestrator hands out the IP addresses. When a service cannot reach another one, the answer is often at layer 2 or 3: the neighbor table, a missing route, an overlapping subnet or a duplicate address. Knowing which address belongs to which layer lets you pick the right tool in seconds. A broader set of cloud concepts is in 18 cloud networking concepts DevOps engineers must know.
If you want to practise these commands on a real Linux host, our Linux administration training in Pune includes networking labs, and the DevOps training in Pune course builds on them. Both run in the classroom at Kharadi and live online across India.
Frequently asked questions
What is the main difference between a MAC address and an IP address?
A MAC address identifies a network interface on a local link and is used at layer 2. An IP address identifies a host on a network and is used at layer 3 for routing between networks. The MAC changes at each hop, the IP does not.
Can a device have more than one MAC or IP address?
Yes. Every network interface has its own MAC address, so a laptop with Ethernet and Wi-Fi has two. A single interface can also hold several IP addresses, including both IPv4 and IPv6.
Why do we need both addresses?
MAC addresses let a switch deliver a frame on one segment without any network configuration. IP addresses are hierarchical, so routers can summarize them and forward packets across millions of networks. Separating the two lets each layer do one job.
Does a router change the MAC or the IP address of a packet?
A router rewrites the Ethernet header, so the source and destination MAC addresses change at every hop. It leaves the IP addresses unchanged, unless it performs NAT.
Can you find a device from its IP address or MAC address?
On the same local network, the ARP or neighbor table maps an IP address to a MAC address. Across the internet, the MAC address of a remote host is never visible to you, because it was replaced at the last router.
Is a MAC address permanent?
The manufacturer burns one into the interface, but operating systems can override it, virtual machines generate their own, and many phones use a randomized MAC for each Wi-Fi network. Treat it as a stable hint, not a guarantee.
Does IPv6 use ARP?
No. IPv6 uses Neighbor Discovery (RFC 4861), which runs over ICMPv6 and sends Neighbor Solicitation and Neighbor Advertisement messages instead of ARP broadcasts.
Official references
- RFC 826: An Ethernet Address Resolution Protocol
- RFC 791: Internet Protocol
- RFC 8200: Internet Protocol, Version 6 (IPv6) Specification
- RFC 4291: IP Version 6 Addressing Architecture
- RFC 4861: Neighbor Discovery for IP version 6
- RFC 1918: Address Allocation for Private Internets
- RFC 2131: Dynamic Host Configuration Protocol
- IEEE Registration Authority FAQs (OUI, EUI-48, EUI-64)
- ip-neighbour(8) manual page
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0