IP Address vs MAC Address: Layer 3 and Layer 2 Explained
IP addresses and MAC addresses both identify communication points, but they work at different layers. This guide explains how Layer 2 and Layer 3 addressing work together.
IP Address vs MAC Address: Layer 3 and Layer 2: Table of Contents
1. Quick Difference
IP addresses are logical Layer 3 addresses used for routing. MAC addresses are Layer 2 addresses used for local frame delivery.
2. How They Work Together
A packet keeps IP addressing end to end, while each local Ethernet hop uses MAC addresses for next-hop delivery.
- Remote traffic uses the gateway MAC.
- Routers rebuild Layer 2 frames.
- Switches learn source MAC addresses.
3. ARP
ARP maps an IPv4 address to a MAC address on the local network.
- arp -a
- ip neigh
- show arp
- show mac address-table
4. DHCP and NAT
DHCP assigns IP settings and may identify clients by MAC. NAT changes IP addresses at a boundary but does not carry your internal MAC across the internet.
- DHCP assigns address, mask, gateway, DNS.
- NAT translates private IP to public IP.
- MAC changes at routed hops.
5. Troubleshooting
Check both Layer 2 and Layer 3. Correct IP settings do not help if VLAN, ARP, or switch port state is wrong.
- ipconfig /all
- ping default gateway
- arp -a
- show interfaces status
IP Address vs MAC Address: Layer 3 and Layer 2: Frequently Asked Questions
Is MAC the same as IP?
No. MAC is Layer 2 and IP is Layer 3.
Does my MAC reach the internet?
No. Routers rewrite Layer 2 frames at each hop.
What command shows IP-to-MAC mappings?
Use show arp on Cisco, arp -a on Windows, or ip neigh on Linux.
Follow a Packet from One Host to Another
When a host sends traffic, it first compares the destination IP address with its own address and subnet mask. If the destination is local, the host uses ARP to learn the destination MAC address. If the destination is remote, the host keeps the remote IP address in the packet but resolves the MAC address of its default gateway. The Ethernet frame therefore changes at every routed hop, while the original source and destination IP addresses normally remain end to end.
A switch learns source MAC addresses and records the port where each address was seen. It forwards a known unicast frame toward the matching port, floods an unknown unicast inside the VLAN, and does not make an IP routing decision. A router removes the incoming Layer 2 frame, checks the IP routing table, reduces TTL, selects a next hop, and builds a new frame for the outgoing link.
Use ARP and Neighbor Tables as Evidence
If a local IPv4 destination cannot be reached, verify that both hosts use the correct mask and VLAN, then inspect the ARP cache. An incomplete ARP entry means the sender asked for a MAC address but did not receive a usable reply. Possible causes include a VLAN mismatch, offline destination, duplicate IP, port security, wireless isolation or a Layer 2 path failure. On a router, compare show ip arp, the interface state and the MAC address table on the connected switch.
For IPv6, Neighbor Discovery performs related address-resolution and reachability functions using ICMPv6 rather than ARP. Filtering all ICMPv6 can therefore break essential IPv6 behavior.
Addresses Can Change for Different Reasons
A DHCP lease can change a host’s IP address without changing its network-interface MAC address. Replacing a network adapter can change the MAC while the device receives a similar IP configuration. NAT can translate the source or destination IP at a network boundary, but it does not carry the original Ethernet MAC address across routers. This distinction is important when interpreting firewall, DHCP, switch and application logs.
Use the IP Location Finder for public address, ASN and provider context, the DHCP guide for dynamic addressing, the NAT guide for translation, and the switching practice page to reinforce Layer 2 behavior.
IP Address vs MAC Address: Layer 3 and Layer 2: Tags and Keywords
IP address vs MAC address, ARP, Layer 2, Layer 3, switching, routing, DHCP, NAT, show arp, network troubleshooting