Skip to main content

IP in Practice: IPv4 Address Structure & Classes

There are two main types of IP addresses: IPv4 and IPv6. Many of us are familiar with the first option. The first post in this series included an interactive section where you could test IP addresses. Stay tuned for IPv6. The numbers may seem random, but did you know your IP address matters? It matters for our privacy and could also matter to external actors if they can gain access to our systems. I, however, am talking about what it could reveal.

  • Is your IP address private or public?
  • How much does that affect the number of IP addresses that can be on a network?
  • How are IP addresses organized into classes?

In this post, I'll focus on answering each of these questions.

Structure of an IPv4 Address

  • Follows a dotted-decimal notation
  • Has four octets
  • Each octet has a value between 0 and 255, made up of 8 bits
  • Has a total length of 32 bits in binary form

What are IP Classes?

Because IPv4 addresses have 32 bits, there are 232 possible combinations. That is over 4 billion possible IPv4 addresses. These IP addresses are split into 5 separate classes.

Class IPv4 Address Range Leading Bits
A 0.0.0.0 - 127.255.255.255 0xxxxxxx
B 128.0.0.0 - 191.255.255.255 10xxxxxx
C 192.0.0.0 - 223.255.255.255 110xxxxx
D 224.0.0.0 - 239.255.255.255 1110xxxx
E 240.0.0.0 - 255.255.255.255 1111xxxx

Within these ranges, there are both private and public IP addresses. Private IP address ranges are addressed in RFC1918.

What exactly are private and public IP addresses?

Going beyond which one is routable over the Internet, let's approach it from another view: What resource are we reaching for and how do we access it? RFC1918 highlights three categories to consider:

  • Am I reaching for hosts within my network?
  • Am I reaching hosts on another network without necessarily going across the Internet?
  • Am I going out to the Internet?

If you answer yes to the first two questions, you need a private IP address. Using a private IP address offers:

  • Security by isolation: Using private IP addresses is like having a private account on social media. Not everyone has access to your posts unless they follow. Similarly, your private network can only be accessed if connected to it, just as someone asking for your Wi-Fi password.
  • Preserves precious IP space: On January 31, 2011, we ran out of IPv4 addresses. Using private IP addresses allowed for many devices to share one IP address to send and receive traffic (NAT). Think of a family within a home. Everyone can send and receive mail or some package, but it all goes to one address.
  • Allows for IP address reuse: Private IP addresses can be reused. For example, you and your neighbor can share the same subnet of IP addresses: 192.168.1.0/24. How? Many addresses can share a house or building number of 123 but have different street names to identify the exact destination. Similarly, NAT abstracts the shared IP addresses and routes each household's traffic by a designated IP address to reach the Internet.
NAT diagram
Network Address Translation takes multiple hosts on a network with unique IP addresses to share a single public NAT IP address from the router.

If you answer yes to the last question, you are using a public IP address. Using a public IP address offers:

  • More uniqueness across the Internet: There are approximately 17.8 million private IP addresses, which seems a drop in the bucket with the remaining 4 billion possible public IP addresses.
  • Easily accessed across the Internet: Whenever you access a website, you are accessing the web server, which uses a public IP address. You can find most websites' public IP addresses by doing a public lookup or using a terminal application command (i.e. nslookup or dig)
  • Supports hosting and peer-to-peer connections: Public IP addresses are required when you want others to initiate connections to your device, such as running a web server, online game server, or even setting up remote access directly to your computer.
RFC1918 Private IP Address Ranges
Class Range Number of Possible Addresses
A 10.0.0.0 - 10.255.255.255 16.7 million (16,777,216)
B 172.16.0.0 - 172.31.255.255 1.04 million (1,048,576)
C 192.168.0.0 - 192.168.255.255 65,536

As you can see, the private IP ranges do not account for the over 4 billion IP addresses that IPv4 provides. Some are used by public-facing servers, while others have specific, reserved purposes such as experimentation and multicasting, particularly for classes D and E. This will be discussed in-depth in a later post.

What's Next?

We scratched the surface with the types of IPv4 addresses. The next part will include a deeper dive into public and private addresses, routing techniques, and a lab demo on Cisco Packet Tracer to see all IP in action.

Comments

Popular posts from this blog

How to Set Up a Cisco Router as a DHCP Server (Step-by-Step Guide)

Lab time! Want to build a DHCP server?  In this lab, I will show you how to build your own DHCP server on a router using Cisco Packet Tracer, as shown above. By the end of this post, you will be able to create your own DHCP server with a Cisco 2911 router, perhaps in a home lab setting, and prepare you to build your own on other hardware.  Why a Router?  A DHCP server is a centralized, automated service that assigns important network configuration details to devices on a network, such as IP addresses. Without it, we would have to create manual entries for our entire network, which can be time-consuming and lead to errors. Traditionally, there are dedicated servers to handle these functions. There are many ways to implement a DHCP server in your topology, including a dedicated physical server, a virtual machine, cloud-based gateways, and firewalls. However, there are specific benefits to using a router as your DHCP server: Reduced infrastructure: While havi...

Subnetting Tips

When I was first introduced to subnetting, it was difficult to understand the math and the process behind it. I watched videos but it did not click. I focused more on how to calculate it than on the reasoning behind it. Why do we subnet? I remember seeing forward slashes followed by numbers, classes, letters, network and broadcast addresses - important terms that was overshadowed by just trying to grasp why certain numbers were used.  Years later, I hear the word "subnetting" in one of my courses, and it reminded me of my struggles. Yet, I was excited. It was a time for redemption. Example after example, I started to get them right but also got to understand how to create a subnet with sufficient space for devices. Because of this, I have grown to love subnetting.  For me, it took time - a break that lasted about two years followed by a curriculum that focused on the topic for a few weeks. If you find yourself struggling with subnetting, do not worry. It takes time. If someth...

New Series: IP in Practice

I have done a few posts on subnetting and the inner workings of DHCP. I wanted to do a post on IPv6 and a hands-on demo on implementing DHCP on actual networking equipment. However, I missed a few parts that I would like to cover that would particularly help in understanding how IP works and why it is needed. Unlike the previous series, this will be a direct approach to a certain protocol: Internet Protocol (IP). I recently started my first series, covering important ports, protocols, and acronyms used in the networking field. However, I realized not only is it difficult to address the ones to mention, but for some letters it's hard to find. The intended structure was to have several per letter not just one. The idea seemed fun and engaging, however, doing over 20 posts alphabetically on acronyms, ports, and protocols lacks order and deviates from the direct approach I want this blog to have. For that reason, I am putting it on hold indefinitely. It was fun at first, but it was not...