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 :

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

Just by looking at the CIDR we know that the Subnet Mask is 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 as our given IP. What would be the Network Address?

We can tell the network address will be as the Subnet Mask is 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

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 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 – 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 ( and our broadcast( we subtract 2 from the total hosts which gives us a total of 8190 usable hosts in a range of to

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

Leave a Reply

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

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