MAC vs. IP Addresses: Why We Need Both?

MAC vs. IP Addresses: Why We Need Both?

I'm writing this article after drinking a couple of beers. It will not be formal and concise, but it is my spontaneous moment.

Although we have heard about MAC and IP many times, have you ever wondered why both exist, or how they each play their part in networking?

In this article, we're going to find answers to the following questions:

  • What are the current use cases of MAC and IP addresses?
  • Do we have a non-tech example to understand better?
  • Why do we need IP addresses when we already have MAC addresses?
  • Why don't we use dynamic MAC addresses?

What are the current use cases of MAC and IP Addresses?

In real networking, the IP address is what routers use to send data to the destination network. Then, at the final hop, the MAC address is used by switches to determine the destination device (the one with that MAC).

MAC Address

  • Definition: A hardware identifier assigned to a network interface card (NIC). It’s usually written in a format like AA:BB:CC:DD:EE:FF.
  • Feature: Assigned (often randomly) by the manufacturer, making it globally unique.
  • Main Use: Local network communication. Switches use MAC addresses to determine which device should receive data within a Local Area Network (LAN).

IP Address

  • Definition: A logical address assigned to a device. Typically written in dotted decimal format like 192.168.1.10 (IPv4) or something longer like 2001:db8::abcd (IPv6).
  • Feature: Allocated in a hierarchical manner (network portion vs. host portion).
  • Main Use: Routing data between different networks. Routers look at IP addresses and forward packets along the best path to reach their destinations across the internet.

How They Fit in the OSI Model

  • Layer 3 (Network Layer): During the initializing flow, transport-layer segments encapsulated with an IP header (including source and destination IP addresses), forming an IP packet. In the forwarding phase, routers parse headers to route packets to the destination network.
  • Layer 2 (Data Link Layer): At this layer, IP packets are encapsulated with a data link header containing source and destination MAC addresses, creating a frame. Switches parse these headers to forward frames to destination devices.

A Non-Tech Analogy: Identity Card vs. Home Address

In the delivery system for personal documents, we can think of it as your identity card number (MAC) and your home address (IP).

  • Street Address / IP: Let's the post office know which neighborhood or city to send your document, even if you move across the country.

  • Identity number / MAC: Unique to you (you just get a new street address, but your identity is still the same person). When the carrier hands off your document, they confirm it’s actually for you.

Why do we need IP Addresses when we already have MAC Addresses?

If every device already has a unique hardware address (MAC), why bother assigning IP addresses for routing?

  • Scalability: MAC addresses are flat—no hierarchy—so if we relied on MAC-based routing across the entire internet, routers would need to keep track of every device on Earth. IP addresses, on the other hand, are structured: we use things like CIDR (Classless Inter-Domain Routing) to group ranges of IPs so routers only need to store broad network routes. This hierarchical approach keeps router tables manageable.
  • Layer Separation: Dividing tasks between Layer 2 (MAC) and Layer 3 (IP) keeps the system modular and flexible. If we upgrade from IPv4 to IPv6, we don’t have to change every underlying link-layer technology. Likewise, we can develop new link-layer standards (like Wi-Fi 6 or beyond) without overhauling the entire internet’s IP-based routing.

Why don't we use dynamic MAC Addresses?

MAC addresses are only used to identify the destination node in a network. Why don't we assign MAC addresses dynamically when a device joins a network?

  • Added Complexity: Assigning MAC addresses dynamically would require a new protocol or system to manage them—something like DHCP but for Layer 2. This adds overhead to network setup and maintenance without a clear, widespread benefit over the current system.
  • Security Challenges: Some security features, like MAC address filtering or port security on switches, rely on knowing a device’s specific, unchanging MAC address. Dynamic MACs would make these harder to implement.
  • Tracing MACs are assigned at the factory, which ensures that each physical device is globally unique from day one. It helps trace network events history more effectively and reliably.

References:

Duy Nguyen

Full Digitalized Chief Operation Officer (FDO COO) | First cohort within "Coca-Cola Founders" - the 1st Corporate Venture funds in the world operated at global scale.

1 周

New perspective???

要查看或添加评论,请登录

Hoan Tran Viet的更多文章

  • What exactly are VPN secure tunnels?

    What exactly are VPN secure tunnels?

    Most of us have used a VPN at least once—maybe to bypass website restrictions or securely access private company…

    2 条评论
  • How are Secret keys exchanged through insecure networks?

    How are Secret keys exchanged through insecure networks?

    In the previous post, we learned about the combination of symmetric keys (used for session data encryption) and…

    7 条评论
  • How Kubernetes authenticate internal access?

    How Kubernetes authenticate internal access?

    When you access the Kubernetes API server, you authenticate as a regular user. But what happens when Pods start making…

  • How are types of Cryptography combined in our daily activities?

    How are types of Cryptography combined in our daily activities?

    Nowadays, we spend much time on the Internet for reading news, watching videos, or surfing social networks. But have…

  • How Kafka achieves its design goals (Part II)

    How Kafka achieves its design goals (Part II)

    Following the previous article, we continue to explore key features of Kafka's design that help it achieve the target…

  • How Kafka achieves its design goals (Part I)

    How Kafka achieves its design goals (Part I)

    In recent years, almost of us have been using Kafka for many use cases such as message brokers, activity tracking, and…

    2 条评论
  • How does HDD physically work?

    How does HDD physically work?

    I've used hard disk drives since I first started using computers. Before SSDs and cloud storage became prevalent, HDDs…

  • Analog recording history (Part III - Vinyl)

    Analog recording history (Part III - Vinyl)

    In the previous parts, we have explored phonograph cylinders which used cylinders as the medium to store audio signals.…

  • How the Edison Phonograph works

    How the Edison Phonograph works

    In the previous part, we explored the early history of analog sound recording. Edison's phonograph, invented by Thomas…

  • Analog audio recording history (Part I - Phonograph)

    Analog audio recording history (Part I - Phonograph)

    Cassette players preserve many memories of Vietnamese people from the 1970s to 1990s. At that time, my country was…

    2 条评论

社区洞察