IT and security stuff

Calculating IPv4

Provided an IP address and a Subnet Mask, we can use binary conversion to find the Network Address, total usable IP addresses and range and the the Broadcast Address.

A Network Address looks like this or something similar : 192.168.1.0/24

The CIDR tells us how many binary digits are turned on in the subnet mask.

/24 tells us we have 24 bits “on”(1). In this case the 24 first digits are 1 which gives 11111111.11111111.11111111.00000000 or 255.255.255.0

Just by looking at the CIDR we know that the Subnet Mask is 255.255.255.0. You can refer to this page for more info on CIDR.

We can find the CIDR by counting the number of bits are are turned on.

Let’s find more about the Subnet Mask and it’s purpose.

Let’s use 192.168.25.55 as our given IP. What would be the Network Address?

We can tell the network address will be 192.168.0.0 as the Subnet Mask is 255.255.224.0. This means on our network, only the two last octet will change.

Next using AND equation(0 + 0 = 0, 0 + 1 = 0, 1 + 0 = 0, 1 + 1 = 1) we can figure what will be our network address 3rd octet.

00000000 = 0 so our network address is 192.168.0.0

Ok now, since we have a special type of Subnet Mask here, as the third octet is not 255, we have limitations on the number of usable hosts we can have. We will need a subnet wildcard. Just subtract 255.255.255.255 with your current Subnet Mask and it will give you the wildcard.

This tells us the two first octet won’t change. The third octet will have a range between 0-31 and the fourth octet 0-255.

This tells us our network will have a range of 192.168.0.0 – 1923.168.31.255. 0-31 is 32 total numbers and 0-255 is 256 total numbers. 32 * 256 = 8192 total hosts. Since we need a host for our network (192.168.0.0) and our broadcast(192.168.31.255) we subtract 2 from the total hosts which gives us a total of 8190 usable hosts in a range of 192.168.0.1 to 192.168.31.254.

It’s worth mentioning, sometimes, the broadcast address won’t always be ending with 255. Let’s check it out with this example:

Since the 4th Subnet Mask octet is 11000000 we know that the 2 first digits are reserved for the network. Every other digits are 0 so comparing it to the octet chart we add them all together, in this example it gives us 63. Our broadcast address would be 192.168.45.63.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.