IP addressing: 32 bits divided into two parts (network and host). The size of the network and the number of hosts in each is determined by the netmask.
For a netmask of n bits, the number of possible hosts in a network is equal to:
(32 - n)^2 - 2
I.e.: for a netmask of 24 bits, there are 8 bits left for the hosts, and therefore:
8^2 = 256 - 2 = 254 hosts
The first and last address (in this case, 0 and 255) represent the network address and the broadcast address respectively, and cannot be used as host addresses.
The notation used is:
[network] / [CIDR]
Where [CIDR] is the number of bits in the netmask associated to this network. Netmasks are also written as 4 bytes expressed in decimal, for example:
255.255.255.0 == /24 (the first 24 bits are set to 1)
I.e.: the network 192.168.3.0 previously known as "class C" 192.168.3, is now written as 192.168.3.0 /24
Netmask table:
| # bits | netmask | bit pattern | # hosts | +--------+-----------------+-------------------------------------+----------+ | ... | ... | ... | ... | | /8 | 255.0.0.0 | 11111111 00000000 00000000 00000000 | 16777214 | | /9 | 255.128.0.0 | 11111111 10000000 00000000 00000000 | 8388606 | | ... | ... | ... | ... | | /19 | 255.255.224.0 | 11111111 11111111 11100000 00000000 | 8190 | | ... | ... | ... | ... | | /24 | 255.255.255.0 | 11111111 11111111 11111111 00000000 | 254 | | /25 | 255.255.255.128 | 11111111 11111111 11111111 10000000 | 126 | | ... | ... | ... | ... | | /30 | 255.255.255.252 | 11111111 11111111 11111111 11111100 | 2 | | ... | ... | ... | ... | +--------+-----------------+-------------------------------------+----------+
Since classes are not used anymore, networks are not limited to octet-boundaries (8, 16 or 24), and indeed any length netmask of contiguous bits can be used (/2, /3, ... /19, /22).
Also, a CIDR block can be furtther divided into smaller networks -- this is called subnetting.
For instance, the network 192.168.2.128 /27
is a network
of (32 - 27)^2 - 2
, i.e. 30 hosts:
192.168.2.129 -> 192.168.2.158 (.128 = net, .159 = broadcast)
This network can be subnetted into two smaller networks of 14 hosts each:
192.168.2.128 /28 : 192.168.2.129 -> .143 (128 = net, 143 = broadcast) 192.168.2.144 /28 : 192.168.2.145 -> .158 (144 = net, 159 = broadcast)