Even though IPv4 is getting older, it's still in use in a lot of places right now. Understanding the basics is important. So let us explore the basics. First, let's check out the anatomy of an IPv4 address. An IPv4 address is a number sequence comprised of 4 octets. Octets is a fancy way of saying each number is one byte, which is made of 8 binary digits, thus octet. An octet means you have 256 possible values, 0 through 255. The values are broken down into 4 numbers connected by periods, like 192.168.1.1. There are some special addresses in that total list, so let's start with the two big ones.

An IP address of 0.0.0.0 is a special default of "everything goes." You may see this in a server configuration to accept connections from any host or on any address. Then you have 255.255.255.255, which is a broadcast address. This is basically a "send this to everyone."

Now let's talk about what all the other network information means.

An IP address is a specific address associated to a device on the network.

A Network ID is the information used to tell what is used to identify what is a part of the same network along side a Subnet Mask.

A CIDR (Classless inter-domain routing) is used as a way to represent a subnet usually as a / after the Network ID.

A Default Gateway is the address assigned to a device that usually handles how traffic is going in, out, and routing around a network.

A broadcast address is a special address used to notify everything within a specific network.

That being said, let's take a basic network:

192.168.1.0/24

With this, the following information can be seen immediately:

Network ID = 192.168.1.0

CIDR = 24

The CIDR is a handy number to have because it can tell us how many usable IP addresses exist in that network space. To understand how, let's explore the subnet mask. So as mentioned before, an IP address is 4 octets, an octet is 8 binary digits. This means 8 digits times 4, because it's 4 octets total is 32 binary digits. A CIDR is how many digits in the address are part of the Network ID. So a CIDR can be from 0 to 32. This means that the Network ID is the first 24 binary digits (bits) and the remaining for the network is 32-24, or 8 bits. To get the number of possible values, we keep in mind we are working with binary, use the equation:

2^(32-CIDR)

2^(32-24)

2^8

256

There are 256 possible values. However, this number is actually still technically wrong. Within that range, there are two special addresses I will explain why further down. Just know for now that those are the Network ID (192.168.1.0) and the Broadcast address (192.168.1.255). So the number of usable address equation in full is:

2^(32-CIDR) - 2

2^(32-24) - 2

2^8 - 2

256 - 2

254

There are 254 usable addresses you can assign to devices on the network. Let's turn the CIDR into what a subnet mask looks like. For this, you need to understand binary. There are 24 Network ID bits, they start at the beginning. We will divide it into octets with periods starting from the beginning with 1s until we hit the CIDR, then fill the rest of the 32 with 0s, like so:

11111111.1111111.11111111.00000000

You then can take each octet and convert it from binary to decimal, giving you the following:

255.255.255.0

A subnet mask is important for identifying the network compared to the Network ID. What needs to be understood at this point is that when we look at the network, all those 1s are what cannot change on the IP to be on the same network, and the 0s are the ones we can change an use. So how does this all work? Let's start with any 192.168.1.X address (192.168.1.100):

11000000.10101000.00000001.1100100

We then take that binary value and run it through a process called "Anding" with a subnet mask. This means we compare each bit, if both are 1 we get 1, otherwise we get 0.

11000000.10101000.00000001.01100100

11111111.11111111.11111111.00000000

-----------------------------------

11000000.10101000.00000001.00000000

Now that we have that answer, we would then compare it for equality against the Network ID, in which case the binary value there and the Network ID of 192.168.1.0 are the same. While we as people may be able to make the comparison a little faster without the anding, but a computer needs to do it for the comparison to be fast and easy. When it comes to computers, they can do binary operations far faster than looking at a number string arbitrarily like a human would do. This is also where we get the broadcast address from.

So now let's use the numbers to find the broadcast address. To get the broadcast address we need to take the binary of the network ID and fill in the remaining portion that would be 0 by the subnetmask with 1s. It would look as follows:

11000000.10101000.00000001.11111111

When we convert this back into a human readable form, it becomes 192.168.1.255. Keep in mind that not everything will all work out this cleanly, it's just that a /24 is very common because it is easier to work with. The main thing to keep in mind is that the numbers may appear strange, but that is because everything is working in binary. All of it really boils down to binary logic and understanding.