The division of a contiguous address space of IP addresses into several smaller address spaces is called subnetting.
A subnet or subnetwork is a physical segment of a network in which IP addresses with the same network address are used. These subnetworks can be connected via routers to form a large, interconnected network.

Image source
Why Subnetting?
If the physical network structure is not taken into account when assigning IP addresses and IP addresses are assigned randomly, all routers in that network must know which subnet an address is located in. Or they simply forward all data packets in the hope that the data packet will eventually reach its destination. Higher transmission protocols then have to request or resend data packets that were thought to be lost. This increases the network load.
If a new host is added, it takes a very long time for all routers to become aware of it. Individual hosts at the edges of a network run the risk of becoming unreachable because their IP address is unknown at the other end of the network.
To distribute the network load sensibly and orderly, networks are divided according to local conditions and/or organizational considerations. This also takes into account the number of hosts within a subnet.
Taking the physical network structure into account by specifically assigning IP addresses and thus logically grouping multiple hosts into a subnet reduces routing information to the network address. The network address ensures the location of an IP address in a specific subnet. A router then only needs the routing information for this subnet and not for all individual hosts within it. The last router to route to the destination subnet is then responsible for delivering the IP data packet.
How does subnetting work?
Each IP address is divided into a network address and a host address. The subnet mask determines where this separation takes place. The following table lists all possible subnet masks. Depending on the network address and subnet mask used, a specific number of hosts can be addressed in a subnet.
| Amount | Subnet mask | 32-Bit value | Suffix |
|---|---|---|---|
| 16.777.214 | 255.0.0.0 | 1111 1111 0000 0000 0000 0000 0000 0000 | /8 |
| 8.388.606 | 255.128.0.0 | 1111 1111 1000 0000 0000 0000 0000 0000 | /9 |
| 4.194.302 | 255.192.0.0 | 1111 1111 1100 0000 0000 0000 0000 0000 | /10 |
| 2.097.150 | 255.224.0.0 | 1111 1111 1110 0000 0000 0000 0000 0000 | /11 |
| 1.048.574 | 255.240.0.0 | 1111 1111 1111 0000 0000 0000 0000 0000 | /12 |
| 524.286 | 255.248.0.0 | 1111 1111 1111 1000 0000 0000 0000 0000 | /13 |
| 262.142 | 255.252.0.0 | 1111 1111 1111 1100 0000 0000 0000 0000 | /14 |
| 131.070 | 255.254.0.0 | 1111 1111 1111 1110 0000 0000 0000 0000 | /15 |
| 65.534 | 255.255.0.0 | 1111 1111 1111 1111 0000 0000 0000 0000 | /16 |
| 32.766 | 255.255.128.0 | 1111 1111 1111 1111 1000 0000 0000 0000 | /17 |
| 16.382 | 255.255.192.0 | 1111 1111 1111 1111 1100 0000 0000 0000 | /18 |
| 8.190 | 255.255.224.0 | 1111 1111 1111 1111 1110 0000 0000 0000 | /19 |
| 4.094 | 255.255.240.0 | 1111 1111 1111 1111 1111 0000 0000 0000 | /20 |
| 2.046 | 255.255.248.0 | 1111 1111 1111 1111 1111 1000 0000 0000 | /21 |
| 1.022 | 255.255.252.0 | 1111 1111 1111 1111 1111 1100 0000 0000 | /22 |
| 510 | 255.255.254.0 | 1111 1111 1111 1111 1111 1110 0000 0000 | /23 |
| 254 | 255.255.255.0 | 1111 1111 1111 1111 1111 1111 0000 0000 | /24 |
| 126 | 255.255.255.128 | 1111 1111 1111 1111 1111 1111 1000 0000 | /25 |
| 62 | 255.255.255.192 | 1111 1111 1111 1111 1111 1111 1100 0000 | /26 |
| 30 | 255.255.255.224 | 1111 1111 1111 1111 1111 1111 1110 0000 | /27 |
| 14 | 255.255.255.240 | 1111 1111 1111 1111 1111 1111 1111 0000 | /28 |
| 6 | 255.255.255.248 | 1111 1111 1111 1111 1111 1111 1111 1000 | /29 |
| 2 | 255.255.255.252 | 1111 1111 1111 1111 1111 1111 1111 1100 | /30 |
Note: The first and last IP addresses of an IP address range (e.g., 192.168.0.0 to 192.168.0.255) represent the network address (192.168.0.0) and broadcast address (192.168.0.255). These addresses cannot be assigned to any host. Therefore, the number of IP addresses must be reduced by two to determine the correct number of usable IP addresses.
The four decimal digits of each IP address correspond to a 32-bit value. The subnet mask is 32 bits long, just like any IP address. Each bit of the subnet mask is assigned to a bit of an IP address. The subnet mask consists of a contiguous sequence of 1s and 0s. At the point where the subnet mask changes from 1 to 0, the IP address splits into the network address and the host address.
| Decimal Representation | Binary Representation (Bit) | |||||||
|---|---|---|---|---|---|---|---|---|
| IP Address | 192 | .168 | .0 | .1 | 1100 0000 | 1010 1000 | 0000 0000 | 0000 0001 |
| Subnet mask | 255 | .255 | .255 | .0 | 1111 1111 | 1111 1111 | 1111 1111 | 0000 0000 |
| Net Address | 192 | .168 | .0 | .0 | 1100 0000 | 1010 1000 | 0000 0000 | 0000 0000 |
| Host Address | 0 | .0 | .0 | .1 | 0000 0000 | 0000 0000 | 0000 0000 | 0000 0001 |
| Broadcast Address | 192 | .168 | .0 | .255 | 1100 0000 | 1010 1000 | 0000 0000 | 1111 1111 |
The subnet mask is applied to the IP address like a template to determine the network address and host address. Information about the network address is important for the delivery of an IP data packet. If the network address is the same for the source and destination addresses, the data packet is delivered within the same subnet. If the network addresses are different, the data packet must be routed to a different subnet via the default gateway.
Notation of IP Address and Subnet Mask
There are two notations for the subnet mask in combination with the IP address.
| IP Adress / Subnet mask | 192.168.0.1 / 255.255.255.0 |
|---|---|
| IP Adress / Suffix | 192.168.0.1 / 24 |
In the first notation, the IP address and subnet mask are written one after the other. In the second notation, the suffix is used instead of the subnet mask. The suffix after the IP address indicates how many 1s follow one after the other within the subnet mask in bit notation. Therefore, 24 means 255.255.255.0.
Example 1
To find a subnet mask that combines 192.168.0.0 and 192.168.1.0, you need a mask that covers both networks. Since these are contiguous Class C networks, a /23 mask would be suitable. This results in a subnet mask of 255.255.254.0.
Explanation
192.168.0.0 and 192.168.1.0 are Class C networks:
In a standard Class C network, the first three octets of the IP address are the network ID, and the last octet is the host ID.
Combining two contiguous Class C networks:
To combine these two, you need to make the network portion of the IP address smaller so that it can accommodate both networks.
/23 Mask
A /23 subnet mask is equivalent to 255.255.254.0. This mask makes the network part of the IP address smaller, allowing it to include both 192.168.0.0 and 192.168.1.0 within the same subnet.
Network Address
The network address for the combined subnet using a /23 mask would be 192.168.0.0.
Answer
To combine the networks 192.168.0.0 and 192.168.1.0, use a subnet mask of 255.255.254.0 or /23.
This mask will allow you to use all the addresses within the 192.168.0.0 and 192.168.1.0 networks as part of a single subnet.
Example 2
Finding the most appropriate subnet mask for two IP address blocks, 192.168.10.0 and 192.168.100.0, when combined.
What you’re given IP address block 1: 192.168.10.0 and IP address block 2: 192.168.100.0.
How to solve?
Determine the overlapping network bits in both IP addresses and find the corresponding subnet mask.
1. Convert IP addresses to binary
– 192.168.10.0 in binary is 11000000.10101000.00001010.00000000
– 192.168.100.0 in binary is 11000000.10101000.01100100.00000000
2. Identify common network bits
The first two octets (192.168) are the same for both IP addresses, indicating a common network portion.
Comparing the third octet (10 and 100), the common bits are 11000000.10101000.0000, meaning the first 16 bits are the same for both IP addresses.
The fourth octet (0) is different for both IP addresses.
3. Determine the subnet mask
Since the first 16 bits are the same, a subnet mask of 255.255.0.0 (or /16) would cover both IP address blocks.
Answer
The subnet mask for the combined IP address blocks of 192.168.10.0 and 192.168.100.0 is 255.255.0.0