Subnet in Binary

Subnetting is one of the most important pieces of knowledge an engineer must know. There’s quick ways to subnet but before learning the tricks, it’s important to know what is actually happening in binary.

An IPv4 address consists of 32 individual bits ranging between 0.0.0 – The reason for this is due to 255 being the biggest decimal number that we’re able to express in binary with 8 bits. 1111 1111 = 255.

Classful Address Ranges

Everyone has probably heard of these once or twice. The classes of addresses. Class A, B, C.

Class A: – ( a /8)

Class B: – ( a /16)

Class C: – (a /24)

Now that we know what they are, lets throw them out the window! This is no longer used any longer and now we incorporate classless subnetting called VLSM – variable length subnet masks. However, we need to know the address ranges of the classful subnets due to some older protocols like RIP. (and old people)


VLSM means that the mask for example /24 or determines the subnet size and no longer relies on the Class like A, B, or C to determine the subnet mask.

For instance you can have an address start with the class A IP address of which by old standards would mean that you own all the IP address space of – (16,777216 addresses) but nowadays would be subnetted down through VLSM to maybe a /15 or Which would give us an address range of –


Lets break down the previous example with binary and how it actually works. We used an with a subnet mask of or in CIDR (classless inter-domain routing notation) a /15.

Binary is simply either a 0 or a 1. An IPv4 address has 32 bits ( a bit is a 0 or a 1) cut into four separate chunks called octets. Therefore, an IPv4 address is composed of bits in the pattern of:

00000000.00000000.00000000.00000000 <-- 32 bits 
This example equals

00001000.00000000.00000000.00000000 equals
11111111.11111110.00000000.00000000 equals the subnet mask of

By looking at the above mask in binary, we can determine which bits are ‘locked’ and are non-permeable. Lets bold the Network ID with the Subnet Mask.

00001000.00000000.00000000.00000000 <-
11111111.11111110.00000000.00000000 <-

Going from the above, these bold bits are locked and can not be changed. To get the broadcast ID ( the last address in the subnet) we simply flip the unlocked bits.

00001000.00000000.00000000.00000000 <- Original
00001000.00000001.11111111.11111111 <- Flipped

By flipping our unlocked bits our broadcast ID is found of Network ID Subnet Mask Broadcast ID

One more example.

The /19 represents 19 locked bits meaning they can never change in this subnet. Lets show the the network ID and mask in binary.

10101100.00010000.00000000.00000000 equals
11111111.11111111.11100000.00000000 equals /19 or

If we flip the unlocked bits we get our broadcast

10101100.00010000.00000000.00000000 equals
10101100.00010000.00011111.11111111 equals Network ID Subnet ID Broadcast ID

So now that we know what is actually happening at the bit level, we’re now ready to move on to faster ways to subnet. We’ll cover that in my next post Quick Subnetting!





One thought on “Subnet in Binary”

Leave a Reply

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