An IP address can be split into 2 different parts – the network- and the host-part.
When/How this partition is happening is defined via the netmask, which is built by the same 32 bit as an IP address (therefore in a range between 0.0.0.0 and 255.255.255.255)
The network part can be seen from left to right, the host part from right to left.
Example
Netmask 255.255.255.0 – Short /24
Available IP addresses in this subnetwork: 254
This means if we define a network with 192.168.0.0 the first 3 numbers 192.168.0 are the network part and the last number 0 is the host part.
Theoratically there are 256 IP addresses available, but the first and last IP address inside a subnet are predefined. With our example of a /24 subnet
192.168.0.0 => Network address
192.168.0.255 => Broadcast address
That why we “only” have an actual useable area between 192.168.0.1 and 192.168.0.254 which sums up to a maximum of 254 usable addresses.
If we want to have more than 254 concurrent clients inside a given network we have to decrease the netmask. See the following table:
Netmask | usable IPv4 addresses | Netmask visualized as bits |
255.0.0.0(/8) | max. 16.777.214 | 1111’1111.0000’0000.0000’0000.0000’0000 |
255.240.0.0 (/12) | max. 1.048.574 | 1111’1111.1111’0000.0000’0000.0000’0000 |
255.255.0.0 (/16) | max. 65.534 | 1111’1111.1111’1111.0000’0000.0000’0000 |
255.255.240.0 (/20) | max. 4094 | 1111’1111.1111’1111.1111’0000.0000’0000 |
255.255.248.0 (/21) | max. 2046 | 1111’1111.1111’1111.1111’1000.0000’0000 |
255.255.252.0 (/22) | max. 1022 | 1111’1111.1111’1111.1111’1100.0000’0000 |
255.255.254.0 (/23) | max. 510 | 1111’1111.1111’1111.1111’1110.0000’0000 |
255.255.255.0 (/24) | max. 254 | 1111’1111.1111’1111.1111’1111.0000’0000 |
255.255.255.128 (/25) | max. 126 | 1111’1111.1111’1111.1111’1111.1000’0000 |
255.255.255.192 (/26) | max. 62 | 1111’1111.1111’1111.1111’1111.1100’0000 |
255.255.255.224 (/27) | max. 30 | 1111’1111.1111’1111.1111’1111.1110’0000 |
255.255.255.240 (/28) | max. 14 | 1111’1111.1111’1111.1111’1111.1111’0000 |
255.255.255.248 (/29) | max. 6 | 1111’1111.1111’1111.1111’1111.1111’1000 |
255.255.255.252 (/30) | max. 2 | 1111’1111.1111’1111.1111’1111.1111’1100 |
255.255.255.254 (/31) | 2 as P2P | 1111’1111.1111’1111.1111’1111.1111’1110 |
255.255.255.255 (/32) | None | 1111’1111.1111’1111.1111’1111.1111’1111 |
But of course you can use multiple subnetworks and combine them with each other via a Router.
Why do we need subnetworks?
Subnetworks are needed so clients know if an IP-packet should be redirected only in the local network or if it should be handled by a router (and therefore redirected to another network).