Network part and host part
An IPv4 address has 32 bits. The mask says how many bits at the front identify the network; the rest numbers the devices in the network. /24 (255.255.255.0) means 24 bits network, 8 bits host.
| Prefix | Mask | Addresses | usable |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /30 | 255.255.255.252 | 4 | 2 (transit network between routers) |
The first address is the network address, the last the broadcast; the device addresses lie in between.
Example
The network 192.168.10.0/24 is to be split into four equal networks. Four networks need 2 more bits: /26. Each network has 64 addresses:
| Network | Host range | Broadcast |
|---|---|---|
| 192.168.10.0/26 | .1 – .62 | 192.168.10.63 |
| 192.168.10.64/26 | .65 – .126 | 192.168.10.127 |
| 192.168.10.128/26 | .129 – .190 | 192.168.10.191 |
| 192.168.10.192/26 | .193 – .254 | 192.168.10.255 |
VLSM: as needed
With VLSM (variable-length subnet masks) every network only gets as much as it needs. Start with the largest: 100 devices need /25, 50 devices /26, the router link /30. This keeps address space for later.
Private addresses for your own networks are listed in RFC 1918: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 (more in Special address ranges).
How many hosts?
With h host bits a network has 2^h addresses, of which 2^h − 2 are for devices (network address and broadcast are left out). The other way round: 50 devices need 2^h − 2 ≥ 50, so h = 6 (62 devices), the prefix is 32 − 6 = /26.
| Wanted | Calculation |
|---|---|
| network address | address AND mask (all host bits set to 0) |
| broadcast | network address with all host bits set to 1 |
| first host | network address + 1 |
| last host | broadcast − 1 |
CIDR and route summarisation
There used to be fixed classes: A (1–126, /8), B (128–191, /16), C (192–223, /24). Since CIDR (Classless Inter-Domain Routing, RFC 4632) any prefix length is valid; the classes are history.
CIDR also allows the opposite of subnetting: combining several networks into one route (summarisation, supernetting). Four networks 192.168.0.0/24 to 192.168.3.0/24 share the first 22 bits:
192.168.0.0 = 11000000.10101000.000000|00.00000000
192.168.3.0 = 11000000.10101000.000000|11.00000000
common: 22 bits → 192.168.0.0/22
A router then needs only one route 192.168.0.0/22 instead of four. That keeps routing tables small, which is especially important in the internet (RFC 4632). Summarising only works for contiguous blocks whose number is a power of two and which start on a matching boundary; otherwise the summary route also covers other networks.
How to do it in leyoNET
The same text as in the app’s help (F1 key).
Subnetting
A network can be split into smaller subnets by lengthening the prefix: 192.168.1.0/24 becomes two /25 or four /26. Each subnet loses two addresses (network and broadcast). With VLSM each subnet gets exactly the size it needs. The IP calculator does both.
IP calculator
Press I or the button next to an address field. It shows network, broadcast, first and last host, host count, wildcard and binary. Below it splits a network evenly or by need (VLSM). Apply writes the values straight into the device.
Practise
- ★★★☆☆ Subnets by need (VLSM) · 4 goals · Worksheet (German)
- ★★☆☆☆ Subnetting – Task 1: Four equal subnets · 12 goals · Worksheet (German)
- ★★★★☆ Subnetting – Task 2: Subnets by need (VLSM) · 9 goals · Worksheet (German)
- ★★☆☆☆ UE03 Router01 – Task 3: mask /25 · 6 goals · Worksheet (German)
In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.