Networking Fundamentals

IP Address vs MAC Address

The ultimate guide to understanding the difference between "where you are" and "who you are" in a network.

The Real World Analogy

Technical terms can be confusing. Let's break it down using something we all understand: mail and identity.

Postal Service

IP Address

home_pin The "Postal Address"

Just like your Home Address (e.g., 123 Main St, New York). It tells the world where you are located so mail can be routed to you. If you move to a new house, your address changes.

  • Used for long-distance routing.
  • Changes when you change networks.
Fingerprint ID

MAC Address

fingerprint The "Social Security Number"

Like your Fingerprint or SSN. It identifies who you are physically. Even if you move to a new country (change IP), your fingerprint (MAC) stays the same*.

  • Used for local identification.
  • Physically burned into the device.

* Note: Modern devices can "randomize" MAC addresses for privacy, but the hardware MAC remains constant.

Technical Comparison

The engineering details.

Feature IP Address MAC Address
Full Name Internet Protocol Address (IPv4 or IPv6) Media Access Control Address (Physical Address)
Purpose Logical addressing, routing packets across different networks (WAN/Internet). Physical addressing, delivering frames within the same network segment (LAN).
OSI Layer Layer 3 (Network Layer) - Used by Routers. Layer 2 (Data Link Layer) - Used by Switches/NICs.
Length & Format IPv4: 32-bit (e.g., 192.168.1.1) IPv6: 128-bit (Hexadecimal) 48-bit Hexadecimal (6 pairs separated by colons or hyphens).
Assigner Assigned by ISP (Public) or Network Admin/DHCP Server (Private). Dynamic. Burned in by Manufacturer (OUI). First 24 bits = Vendor ID.

How Data Travels

Watch how addresses change (or don't) as data moves through a Router.

laptop_mac
Laptop (Source)
IP: 192.168.1.5
MAC: AA:AA
router
Router
In
IP: 192.168.1.1
MAC: BB:BB
Out
IP: 10.0.0.1
MAC: CC:CC
dns
Server (Dest)
IP: 10.0.0.9
MAC: DD:DD
mail
Source IP
192.168.1.5
Dest IP
10.0.0.9
Source MAC
AA:AA
Dest MAC
BB:BB
Ready to send...
Key Takeaway: Notice how the IP Addresses stay the same the entire journey (End-to-End), but the MAC Addresses change at the Router (Hop-by-Hop). The router strips the old MAC header and adds a new one!

Interview Corner

Common questions asked in Networking interviews.

Think of it as layers:

  • IP (Layer 3) is for Routing. It helps routers find the best path across the global internet to the destination network.
  • MAC (Layer 2) is for Delivery. Once the packet arrives at the correct local network (LAN), the switch needs the MAC address to deliver it to the specific physical device cable/wifi card.

Analogy: The IP gets the letter to the correct building. The MAC gets it to the correct person in that building.

ARP (Address Resolution Protocol) is the bridge between Layer 3 (IP) and Layer 2 (MAC).

When a device knows the destination IP but not the MAC, it shouts (broadcasts): "Who has IP 192.168.1.5?".

The device with that IP replies: "I do! My MAC is AA:BB:CC...". The sender saves this in its ARP Cache.

Physically? No. It is burned into the ROM of the Network Interface Card (NIC) by the manufacturer.

Software-wise? Yes (Spoofing). You can instruct your OS to pretend to have a different MAC address in outgoing packets. This is often used for privacy (MAC Randomization on iOS/Android) or by hackers to bypass filters.