DEV Community

Cover image for Every Device Needs an Address: Understanding IP Addressing, IPv4, IPv6, NAT, and Subnetting
Divine Uzor
Divine Uzor

Posted on

Every Device Needs an Address: Understanding IP Addressing, IPv4, IPv6, NAT, and Subnetting

"How does data know where to go?"

In the previous article, we explored the OSI Model and saw how data travels through seven layers before reaching another device.

One layer stood out in particular.

Layer 3: The Network Layer.

This is the layer responsible for moving data between networks. But before data can travel anywhere, the network has to answer one very important question.

Where exactly should this data go?

Imagine ordering food online without entering your home address.

The restaurant prepares your meal.

The delivery rider picks it up.

Everything is ready.

But there's one problem.

Nobody knows where to deliver it.

That is exactly what would happen on the Internet if devices didn't have addresses.

Every phone, laptop, server, printer, router, virtual machine, and cloud resource needs an address so data knows where to go.

That address is called an IP address.

Whether you're troubleshooting a network, configuring Azure resources, deploying virtual machines, or simply browsing the web, IP addressing is working quietly in the background.

In this article, you'll learn:

  • What an IP address actually is
  • The difference between IPv4 and IPv6
  • Why IPv4 almost ran out of addresses
  • Public vs private IP addresses
  • How NAT lets multiple devices share one public IP
  • What subnetting and CIDR notation mean
  • Why these concepts matter in cloud computing

Let's begin.

What Exactly Is an IP Address?

An IP (Internet Protocol) address is a unique logical address assigned to a device connected to a network.

Its job is surprisingly simple.

It answers two questions.

  1. Who are you?
  2. Where are you?

Without an IP address, devices wouldn't know where to send information.

Think about sending a letter through the post.

The postal service doesn't know you personally.

It only knows the address written on the envelope.

The same thing happens on the Internet.

When you open YouTube or Google, your computer doesn't magically know where those servers are.

It sends packets that contain destination IP addresses, allowing routers across the Internet to deliver those packets to the correct server.

Every packet depends on an address.

No address.

No communication.

IP Address vs MAC Address

At this point, it's worth clearing up one of the biggest beginner questions.

What's the difference between an IP address and a MAC address?

Although both identify devices, they do very different jobs.

Think about yourself.

You have:

  • a home address
  • fingerprints

Your fingerprints identify who you are.

Your home address identifies where you live.

Networking works the same way.

A MAC address is like your fingerprint.

It is burned into the network interface card (NIC) by the manufacturer and identifies the physical device on the local network.

An IP address is like your home address.

It identifies where that device currently exists on a network.

If you move to another house, your fingerprint stays the same.

Only your address changes.

Likewise, if you connect your laptop to another network, your MAC address stays the same while your IP address usually changes.

This distinction is important because:

  • Layer 2 (Data Link) uses MAC addresses.
  • Layer 3 (Network) uses IP addresses.

Remember our OSI article?

This is where those layers begin working together.

IPv4: The Original Internet Addressing System

The version of IP addressing that built the Internet is called IPv4.

It has existed since the early 1980s and is still the most widely used version today.

An IPv4 address is made up of 32 bits.

Instead of writing 32 ones and zeros, we split them into four groups separated by periods.

For example:

192.168.10.25
Enter fullscreen mode Exit fullscreen mode

Each group is called an octet because it contains 8 bits.

Each octet can contain values from:

0 – 255
Enter fullscreen mode Exit fullscreen mode

That's because eight binary bits can represent 256 different values.

The same address in binary looks like this:

11000000.10101000.00001010.00011001
Enter fullscreen mode Exit fullscreen mode

Fortunately, humans don't have to read binary very often.

That's why dotted decimal notation exists.

Every IPv4 Address Has Two Parts

An IPv4 address isn't just one long number.

It actually contains two separate sections.

  • Network portion
  • Host portion

The network portion identifies the network.

The host portion identifies the individual device inside that network.

Imagine a hotel.

The hotel's street address identifies the building.

The room number identifies one specific guest.

IP addressing works the same way.

The network tells routers which network to deliver traffic to.

The host tells the network which device should receive it.

We'll see exactly how the network decides where this dividing line is when we discuss subnet masks later in this article.

Why Did IPv4 Run Out?

When IPv4 was created, engineers believed its address space would last for decades.

After all...

32 bits gives us:

2³² = 4,294,967,296 addresses
Enter fullscreen mode Exit fullscreen mode

More than 4.3 billion addresses.

Back then, that sounded impossible to exhaust.

But the Internet changed.

Today we don't just have computers.

We have:

  • smartphones
  • tablets
  • cloud servers
  • smart TVs
  • gaming consoles
  • IoT devices
  • security cameras
  • smart watches
  • sensors
  • virtual machines

Billions of devices now compete for IPv4 addresses.

Eventually, the available address pool began running out.

This problem became known as IPv4 address exhaustion.

Instead of replacing IPv4 immediately, engineers developed clever techniques to make those addresses last much longer.

The biggest one was Network Address Translation (NAT).

Before we explain NAT, we first need to understand the difference between public and private IP addresses.

Coming up in Part 4: We'll explore public vs. private IP addresses, how NAT allows your entire home to share a single public IP address, why this was one of the most important innovations in networking, and how IPv6 was designed to solve the address shortage permanently.

Top comments (0)