Netmask-prefix
Netmask v. Address Prefix Length
Two notations are used to specify subnets: Netmask and Address Prefix Length:
192.168.0.0/255.255.255.248 (Netmask)
192.168.0.0/29 (Address Prefix Length)
Both are regularly used around the network. The Netmask specifies a bit pattern that indicates the number of bits available for a particular network. For a netmask, the number of 0's indicate the number of hosts within a given network range.
For instance, the above netmask of 255.255.255.248 (the same as 192.168.0.0/29) looks like this in binary:
11111111111111111111111111111000
That would be 29 1's followed by three 0's. The three 0's are hosts available to that particular subnet. In this example, three zeros would indicate 8 possible host since three binary digits correspond to 0-7 (including 0, there are eight possible numbers).
A simple way to think about this (in fact, the way netmasks were designed) is to mask an IP address with the netmask. If we masked (top and bottom are both 1) 192.168.0.29 (11000000 10101000 00000000 00011101), we would wind up with the 192.168.0.24:
11000000 10101000 00000000 00011101 (192.168.0.29)
11111111 11111111 11111111 11111000 (255.255.255.248)
-------------------------------------
11000000 10101000 00000000 00011000 (192.168.0.24)
This means that 192.168.0.29/29 is on the 192.168.0.24 subnet and that there are 8 hosts (24-31) available.
Netmasks are only counted as the number of zeros from the right; there are no zeros in the middle of a netmask. After all, a netmask like 255.255.255.250 (...11111010) wouldn't make much sense since it would refer to a range including only odd ip addresses. It wouldn't be a range at all! Consequently, there are only a few valid network masks. Each specify a number half the size of the prior netmask:
0 - 256 Hosts or Subnets
128 - 128 Hosts or Subnets
192 - 64 Hosts or Subnets
224 - 32 Hosts or Subnets
240 - 16 Hosts or Subnets
248 - 8 Hosts or Subnets
252 - 4 Hosts or Subnets
254 - 2 Hosts or Subnets
255 - 1 Host or Subnet
Netmask / Address Prefix Conversions
Netmask Address Prefix Length Hosts / Class C's / Class B's / Class A's
255.255.255.255 /32 1
255.255.255.254 /31 2
255.255.255.252 /30 4
255.255.255.248 /29 8
255.255.255.240 /28 16
255.255.255.224 /27 32
255.255.255.192 /26 64
255.255.255.128 /25 128
255.255.255.0 /24 (Class C) 256 / 1
255.255.254.0 /23 512 / 2
255.255.252.0 /22 1,024 / 4
255.255.248.0 /21 2,048 / 8
255.255.240.0 /20 4,096 / 16
255.255.224.0 /19 8,192 / 32
255.255.192.0 /18 16,384 / 64
255.255.128.0 /17 32,768 / 128
255.255.0.0 /16 (Class B) 65,536 / 256 / 1
255.254.0.0 /15 131,072 / 512 / 2
255.252.0.0 /14 262,144 / 1024 / 4
255.248.0.0 /13 524,288 / 2048 / 8
255.240.0.0 /12 1,048,576 / 4096 / 16
255.224.0.0 /11 2,097,152 / 8129 / 32
255.192.0.0 /10 4,194,304 / 16,384 / 64
255.128.0.0 /9 8,388,608 / 32,768 / 128
255.0.0.0 /8 (Class A) 16,777,216 / 65,536 / 256 / 1
254.0.0.0 /7 33,554,432 / 131,072 / 512 / 2
252.0.0.0 /6 67,108,864 / 262,144 / 1,024 / 4
248.0.0.0 /5 134,217,728 / 524,288 / 2,048 / 8
240.0.0.0 /4 268,435,456 / 1,048,576 / 4,096 / 16
224.0.0.0 /3 536,870,912 / 2,097,152 / 8,192 / 32
192.0.0.0 /2 1,073,741,824 / 4,194,304 / 16,384 / 64
128.0.0.0 /1 2,147,483,648 / 8,388,608 / 32,768 / 128
0.0.0.0 /0 (The Internet) 4,294,967,296 / 16,777,216 / 65,536 / 256
Requires Login