Adventures in the Art of Home Labs

IPv4 Addressing Part I

Written by

in

Introduction

We cannot get into home labs without fully understanding what an IP address is and how it works. Back in the fall of 2003, I set off to become a Microsoft Certified Systems Engineer for Windows and Windows Server 2000. At the time, I didn’t know that there were paths to Linux Systems Administration. Had I known, I would readily have taken that path. I believed everyone when they advised me to become an MCSE but that’s a story for a different day.

I truly did not know much beyond the basics that every computer needed an IP address, a subnet mask, and a default gateway in order to get out on to the internet. I had no concept of what a subnet mask is and I understood that basically a default gateway was how my PC reached the internet-at-large. Beyond this basic understanding, I had no concept of what waters I would be wading into.

This post will discuss the basics of what an IP address is and how a computer finds and communicates with another. This is essential reading if you want to build a real systems and continue on your home lab journey. We will start with IPv4 and then launch into a discussion of IPv6. Once you learn IPv4, IPv6 is a delight because it is simpler to work with and more powerful and capable. Rarely do these two go hand in hand. Anyhow, without further ado, let’s launch into IP Addressing with IPv4, the original gangster of the internet.

IPv4 Basics

An IPv4 address is made up of 4 sets of numbers, each numbered 0-255. Since computers consider zero as the first number in counting, we refer to a range of 0-255 as having 256 possible numbers. Each set of numbers is called an octet because it has 8 bits for a total of 32 bits. Hence, IPv4 is known as a 32 bit addressing scheme. At the time of the internet’s development, it was never anticipated that address requirements would go beyond 4.29 billion total. Once the internet moved into the commercial space from government, military, and education, it quickly became apparent that there would be an immediate risk of address depletion for which workarounds were developed. We will get into those later.

You might have noticed that at home, you get assigned an IP address of 192.168.0.1-192.168.0.254 or 192.168.1.1-192.168.1.254. When you first set up your router, you probably had to launch your favorite web browser, and go to http://192.168.0.1 or http://192.168.1.1 to complete the task. Or you might have used an app to complete the setup which gave you some information about your network like the IP address, subnet mask, and default gateway is. This information is fundamental to how your PC, also known as a host, functions on a modern network.

Let’s take a moment to analyze the address, 192.168.1.1. This address belongs to an space that has been set aside for private networks like the one in your home. It is usually accompanied a subnet mask. Think of a subnet mask as a number that tells you how many hosts you can assign in a given network. Typically home routers set a default subnet mask of 255.255.255.0. This tells you that 24 bits are assigned to the network and 8 bits are available to assign to computers, tablets, phones, smart watches, and other devices. Since the last octet has a 0 in it which means there are 254 assignable addresses. The first and last addresses are not assignable.

The first address is known as the network address which is how a router finds a given network. The last address is called the broadcast address. The broadcast address is how hosts discover available services. It also ensures that the broadcast is confined to the network. After all, we don’t want broadcast storms to happen as that would degrade network performance drastically. The remaining 254 addresses are up for assignment. For a home network, this can be plenty. But think of larger organizations like offices, hospitals, banks, etc. 254 addresses would be impossibly small.

Private Address Space

IANA, or the Internet Assigned Numbers Authority has taken some address blocks out of service for private networks of varying sizes. Even the largest block of private address space may not be big enough for some large organizations. Below is a table of the RFC1918 address space. RFC1918 refers to the reservation of IP address blocks for private networks.

Address SpaceRangeSubnet MaskNumber of Hosts
10.0.0.0/810.0.0.0-10.255.255.255255.0.0.016,777,214
172.16.0.0/12172.16.0.0-172.31.255.255255.240.0.01,048,576
192.168.0.0/16192.168.0.0 – 192.168.255.255255.255.0.065,536

You might have noticed from the table above that the 192.168.0.0/16 address space is a lot larger than our example one, 192.168.1.0. It is often common with smaller organizations and home labs to take on the of these blocks and cut it down. Small business and home networks often don’t finding themselves in need of address space so large. You might have noticed that I added a /8, /12, and /16 to each respective block. This is called CIDR or Classless Inter Domain Routing notation. CIDR notation is a shorthand for the subnet mask.

On the face of it, these look like large blocks of addresses. Before the era of smart phones, watches, tablets, and the Internet-of-Things, this might have been sufficient. Large organizations might completely use up the 172.16.0.0/12 block and have to move into the 10.0.0.0/8 block for extra addresses or vice versa. We are going to be nowhere near some of this large size, so it is common to carve down the blocks into smaller ones. Hence, we carved 192.168.1.0/24 out of the block of 192.168.0.0/16. We will look into the math behind this in a bit. For now, we will look at the IP address.

Anatomy of an IP address

Since we are keeping with the example address of 192.168.1.1, we will do a deep dive into the anatomy of the address so that we can better understand how it works. We know computers communicate using binary, so this address needs to be converted to binary by the processes that be. Let’s see how this happens by looking at the table below.

2^82^72^62^52^42^32^22^12^0
2561286432168410
011000000
010101000
000000010
000000010

In binary, 1 is off and 2 is on. I set up a table for converting an IP address from decimal to binary. Each row represents one of the four octets. So 192.168.1.1 in binary is 01100000.01010100.00000010.00000010. Networking equipment converts 192.168.1.1 to binary. We can convert an address to binary as above.

In the first octet we have 192. According to the chart above, we find the highest number that 192 is closest to. In this case 192 is closer to 128 then 256. So we place a 0 in the 256 column and a 1 in the 128 and 64 columns because 128 + 64 = 192. From there, we can convert each additional octet to binary. It’s good practice but rarely will you work with this. It’s just good to have an understanding of the binary side. Try converting the remaining 3 octets as practice.

When it comes to knowing my address space, I actually like the chart method using CIDR. You will eventually commit a lot of this to memory as I have. Here is what that looks like:When it comes to knowing my address space, I actually like the chart method using CIDR rather than binary. You will eventually commit a lot of this to memory as I have. Here is what that looks like. Notice how when the CIDR number decreases, the number of hosts increase.

CIDRSubnet MaskNo. of Hosts
/32255.255.255.2551
/31255.255.255.2552
/30255.255.255.2524
/29255.255.255.2488
/28255.255.255.24016
/27255.255.255.22432
/26255.255.255.19264
/25255.255.255.128128
/24255.255.255.0256
/23255.255.254.0512
/22255.255.252.01024
/21255.255.248.02048
/20255.255.240.04096
/19255.255.224.08192
/18255.255.192.016,384
/17255.255.128.032,768
/16255.255.0.065,536
/15255.254.0.0131,072
/14255.252.0.0262,144
/13255.248.0.0524,288
/12255.240.0.01,048,576
/11255.224.0.02,097,152
/10255.192.0.04,194,304
/9255.128.0.08,388,608
/8255.0.0.016,777,216

Block sizes larger than a /8 rarely exist outside of very large corporations. It probably would have been nice had there been a /4 made available as a private address. In our home labs, the rule of thumb used to be a 256 address space. Given the proliferation of devices out there, I usually recommend doing /22 for your home network which would give you 1022 usable addresses. Very good for a home lab.

Also, there is nothing wrong with carving a /22 address space out of the 172.16.0.0 or 10.0.0.0 blocks. I use 172.20.0.0/22 so the complete range of addresses is 172.20.120.0 – 172.20.123.255. Of that range, 172.20.120.1 – 172.20.123.254 or 1022 addresses are available for assignment to hosts. I’ve purposely used a more obscure address in my home lab design because I might want to connect it to somebody else’s and this eliminates the risk of an overlapping IP scheme. For now, that will not be a problem because we are not yet expanding our network beyond the borders of our home lab.

I recommend to people starting a home lab not to stick with the 192.168.0.1/24 or 192.168.1.1/24. These two address schemes are just way too common. If you keep with one of these schemes, you risk technical debt later on and may need to renumber your network which is not fun at all. This is where planning comes into play. Plan your network and home lab for some growth and 1022 addresses should server you well.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *