Friday, July 17, 2015

Subnet Mask

Let us dissect a few subnet mask and see what does it mean. Let us start with a simple example.

10.0.0.0/8:

In an IPv4 there are four parts. Each of them can vary from 0-255. You may know that an 8 bit integer is required to store values from 0-255. Hence each part of an IPv4 is 8bit long.

The '/8' means that first 8 bits are held fixed and rest can vary. In other words since each part is 8 bit long, the first part is fixed and the rest can vary. So it ranges from

10.000.000.000 to 10.255.255.255


172.16.0.0/12:
Here first 12 bits are held fixed and rest can vary.

'172' consumes 8 bits and first 4 bits of 16 are held fixed.

Decimal 16 = Binary 0001 0000.
Decimal 31 = Binary 0001 1111.

So we see that by keeping the first four bits of 16 fixed, we can go from 16 to 31.
Hence 172.16.0.0/12 can vary from

172.16.000.000 to 172.31.255.255


192.168.0.0/16:
Here first 16 bits are fixed. So 192 and 168 are held fixed and rest can vary.

192.168.000.000 to 192.168.255.255

No comments: