What is a subnet mask's binary representation?

QuestionsQuestions8 SkillsProDec, 22 2025
0127

A subnet mask is always 32 bits long, just like an IP address. Its binary representation is unique because it always consists of a sequence of continuous 1s followed by a sequence of continuous 0s.

In the experiment you are currently performing, you are using a /26 subnet mask. Here is how that looks in binary:

1. The CIDR Notation (/26)

The number 26 simply tells you there are twenty-six 1s in a row.

2. The Binary Breakdown

If we write out 32 bits and make the first 26 of them 1 and the rest 0, we get:
11111111.11111111.11111111.11000000

3. Converting to Decimal (Dotted Quad)

To get the decimal version (255.255.255.192) used in your Python script, we convert each 8-bit group (octet):

  • 11111111 = 255
  • 11111111 = 255
  • 11111111 = 255
  • 11000000 = 192 (128 + 64)

Common Examples:

CIDR Binary Representation Decimal Mask
/8 11111111.00000000.00000000.00000000 255.0.0.0
/16 11111111.11111111.00000000.00000000 255.255.0.0
/24 11111111.11111111.11111111.00000000 255.255.255.0
/26 11111111.11111111.11111111.11000000 255.255.255.192

Why binary matters:
The computer performs the bitwise AND operation bit-by-bit. Wherever there is a 1 in the mask, the computer "keeps" the original IP bit (Network portion). Wherever there is a 0, the computer "ignores" the bit by turning it into a 0 (Host portion).

You can see this in action by running your network_calc.py script; it calculates the result of this binary interaction for you

0 Comments

no data
Be the first to share your comment!