Subnetting¶
Practical 3.1 subnetting-annex.pdf · PDF
Tramuntana Apps has 12 people and one network, 10.G.0.0/24. The intern's laptop can reach the accountant's printer. The guests' phones can reach the developers' test server. And every broadcast, like every ARP question, reaches all of them. What would you change?
You would give each department its own network: dev, design, admin, and one for guests. But you only have one /24. So you cut it into smaller pieces, called subnets. Every company network is planned like this, and subnetting is in the Unit 3 exam. The good news: with one table and one method, you can do it with a pencil, no calculator.
What you will learn
- Explain why a network is split into subnets
- Go from a prefix between
/24and/30to its mask, its block size and its number of hosts - Find network, broadcast, first and last host of any address with the block-size method
- Decide whether two addresses are in the same subnet
- Split a
/24into equal subnets, and into subnets of different sizes - Why a bigger prefix number means a smaller network
Why split a network?¶
A subnet is a smaller network made by cutting a bigger one. Each subnet has its own network address, broadcast address and range of hosts.
In the postal analogy, your /24 is one very long street with 254 houses. Subnetting cuts it into shorter streets, each with its own name. Two houses on different streets cannot hand letters to each other directly: they need the post office, the router. That is exactly what you want between the guests and the developers.
What you gain:
- Separation: devices of one department do not reach the other ones directly. A router in the middle decides what passes.
- Quieter networks: a broadcast stays inside its own subnet.
What it costs:
- Every subnet loses two addresses: its network address and its broadcast address.
- Every subnet needs its own router interface.
Borrowing bits¶
On the last page the border between network and host was always at a dot (/8, /16, /24). Now move it one bit to the right. The network splits into two halves. Each borrowed bit doubles the number of subnets and halves their size.
The block size is the number of addresses in one subnet: 2host bits.
Build this table once, from the powers of two, and keep it in front of you:
| Prefix | Mask (last octet) | Host bits | Block size = addresses | Hosts (block − 2) |
|---|---|---|---|---|
/24 |
.0 |
8 | 256 | 254 |
/25 |
.128 |
7 | 128 | 126 |
/26 |
.192 |
6 | 64 | 62 |
/27 |
.224 |
5 | 32 | 30 |
/28 |
.240 |
4 | 16 | 14 |
/29 |
.248 |
3 | 8 | 6 |
/30 |
.252 |
2 | 4 | 2 |
Two things to notice:
- On every line, mask + block size = 256. If you remember one, you have the other.
- A
/30has room for exactly two machines: perfect for a cable between two routers.
Careful: a bigger number is a smaller network
/30 is tiny (2 hosts) and /8 is huge (16,777,214 hosts). The prefix counts network bits: the more of them, the fewer bits are left for hosts.
The block-size method¶
Here is the method, slowly, on 10.3.0.77/26:
- Block size. 32 − 26 = 6 host bits, so 2⁶ = 64.
- Where do the blocks start? At the multiples of 64: 0, 64, 128, 192.
- Which block is 77 in? The one that starts at 64. Network:
10.3.0.64. - Broadcast = one before the next block: 128 − 1, so
10.3.0.127. - Hosts = everything in between:
10.3.0.65to10.3.0.126, 62 hosts.
flowchart LR
A["<b>10.3.0.0/26</b><br>.0 – .63"] --- B["<b>10.3.0.64/26</b><br>.64 – .127<br>77 lives here"] --- C["<b>10.3.0.128/26</b><br>.128 – .191"] --- D["<b>10.3.0.192/26</b><br>.192 – .255"]
It is not magic. It is the AND with the mask from IPv4 addressing, done as a shortcut. Check it once in binary:
If you ever doubt, write the last octet in binary: the mask's ones keep the bits, its zeros clear them.
Warm-up: four addresses¶
Try them before you read the answers:
| Address | Block | Network | First – last host | Broadcast | Hosts |
|---|---|---|---|---|---|
192.168.10.45/27 |
32 | 192.168.10.32 |
.33 – .62 |
192.168.10.63 |
30 |
10.1.0.193/26 |
64 | 10.1.0.192 |
.193 – .254 |
10.1.0.255 |
62 |
10.4.0.50/28 |
16 | 10.4.0.48 |
.49 – .62 |
10.4.0.63 |
14 |
10.1.20.95/27 |
32 | 10.1.20.64 |
.65 – .94 |
10.1.20.95 |
30 |
The last one is a trap: 95 is the broadcast address of its subnet. You could never give it to Marta's laptop.
Usual errors:
- Starting the blocks at 1 instead of 0.
- Giving the next network address as the broadcast (128 instead of 127).
- Using the block size as the number of hosts (forgetting the −2).
When the border is in the third octet¶
For prefixes below /24, do the same method on the third number, and treat the fourth as "all zeros" (network) or "all ones" (broadcast). Example: 10.0.70.9/20. 32 − 20 = 12 host bits: 8 in the last octet, 4 in the third. In the third octet the block is 2⁴ = 16 (mask .240). 70 is in the block that starts at 64; the next one starts at 80.
- Network
10.0.64.0, broadcast10.0.79.255. - Hosts
10.0.64.1to10.0.79.254: 2¹² − 2 = 4,094.
Same subnet or not?¶
Find the subnet of each address. Same subnet = same network address.
10.1.0.60/26and10.1.0.70/26:10.1.0.0/26and10.1.0.64/26. 64 is a border: different subnets.172.16.4.1/22and172.16.7.254/22: in the third octet the block is 4, from 4 to 7. Both are in172.16.4.0/22: same subnet.
Careful: classes A, B and C are history
Old tutorials say "192.168.x.x is a class C network, so it is /24". Classes fixed the border by the first number of the address. CIDR replaced them in 1993: today the prefix decides, and 192.168.1.0/26 is perfectly valid. If you read "class C", think "/24".
Subnetting itself became an Internet standard with RFC 950, in August 1985.
Designing: cutting a /24 into pieces¶
Now the other direction. Not "where is this address?", but "make me N networks".
Equal subnets¶
Borrowing n bits gives 2ⁿ subnets.
| Need | Borrow | New prefix | Block |
|---|---|---|---|
| 2 subnets | 1 bit | /25 |
128 |
| 4 subnets | 2 bits | /26 |
64 |
| 8 subnets | 3 bits | /27 |
32 |
Always check the other side: are the subnets still big enough for the hosts, plus network and broadcast?
Example: 192.168.1.0/24 into 8 subnets, so /27, block 32. The subnets follow each other with no gaps and no overlaps:
| Subnet | First host | Last host | Broadcast |
|---|---|---|---|
192.168.1.0/27 |
.1 |
.30 |
.31 |
192.168.1.32/27 |
.33 |
.62 |
.63 |
192.168.1.64/27 |
.65 |
.94 |
.95 |
… up to 192.168.1.224/27 |
.225 |
.254 |
.255 |
Careful: 4 subnets means 2 bits, not 4
2² = 4. Borrowing 4 bits would give 16 subnets of 16 addresses. Many people choose /28 here by mistake.
Subnets of different sizes¶
Real departments are not the same size. Then:
- For each need, take the smallest block that fits hosts + 2.
- Place them biggest first, one right after the other.
- A block of size B can only start at a multiple of B.
Example: 192.168.1.0/24 for a shop with 100 tills and PCs, 40 cameras and 20 office machines.
| Need | Hosts + 2 | Block | Subnet | Range | Broadcast |
|---|---|---|---|---|---|
| Shop, 100 | 102 | 128 | 192.168.1.0/25 |
.1 – .126 |
.127 |
| Cameras, 40 | 42 | 64 | 192.168.1.128/26 |
.129 – .190 |
.191 |
| Office, 20 | 22 | 32 | 192.168.1.192/27 |
.193 – .222 |
.223 |
The addresses from .224 to .255 are still free for later. Notice why biggest first matters: if you placed the 32-block first, the 128-block could not start at 32 (not a multiple of 128).
Practical 3.1
The Practical 3.1 sheet (the button at the top) asks you to analyse addresses, compare pairs, and design the subnets of Tramuntana Apps for your own group G: once in equal pieces, once in different sizes. Individual, pencil only: no computer, no phone, no AI. Keep the block-size table in front of you. When you study at home, check your rows with the Python one-liner from IPv4 addressing.
Key takeaways¶
- Subnetting cuts one network into smaller subnets: separation and quieter broadcasts, at the cost of two addresses and one router interface per subnet.
- Each borrowed bit doubles the subnets and halves their size. Block size = 2host bits; hosts = block − 2; mask + block = 256.
- Block-size method: blocks start at multiples of the block; the network is the start of the block, the broadcast is one before the next block.
- 2ⁿ subnets need n borrowed bits.
- Different sizes: smallest block that fits hosts + 2, biggest first, each starting at a multiple of its own size.
- CIDR replaced the old classes: the prefix decides, not the first number.
Quick check¶
1. What is the block size of a /27?
- 27
- 32
- 30
- 64
32 − 27 = 5 host bits, and 2⁵ = 32 addresses. 30 is the number of hosts (block − 2), not the block size.
2. What is the network address of 10.5.0.66/26?
- 10.5.0.0
- 10.5.0.66
- 10.5.0.60
- 10.5.0.64
A /26 has blocks of 64, starting at 0, 64, 128 and 192. 66 is in the block that starts at 64.
3. What is the broadcast address of 10.1.0.100/26?
- 10.1.0.127
- 10.1.0.255
- 10.1.0.128
- 10.1.0.100
100 is in the block 64–127. The broadcast is one before the next block: 128 − 1 = 127. .128 is the next subnet's network address.
4. You need 4 equal subnets from a /24. What is the new prefix?
- /25
- /28
- /26
- /22
4 = 2², so you borrow 2 bits: /24 + 2 = /26, with blocks of 64. Borrowing 4 bits (/28) would give 16 subnets.
5. Can 10.1.0.127/25 be configured on a PC?
- Yes, it is a normal host address
- No, it is the network address
- No, it is the broadcast address
- Yes, but only on the router
A /25 has blocks of 128: 10.1.0.0 to 10.1.0.127. The last address, .127, is the broadcast address, so no machine can have it.
6. Are 10.1.0.60/26 and 10.1.0.70/26 in the same subnet?
- Yes, because both are below 128
- Yes, because they share the first three numbers
- No, because 64 is a border between two blocks
- No, because a /26 cannot hold two hosts
With blocks of 64, 60 is in 10.1.0.0/26 and 70 is in 10.1.0.64/26. Different network addresses, different subnets: they need a router to talk.
7. Why does every subnet give you two fewer hosts than its block size?
- Because two addresses are kept for the switch and the router
- Because the first address names the subnet and the last is its broadcast
- Because the mask uses two addresses of every block
- Because the first two addresses are always private
In every subnet, host bits all 0 is the network address and host bits all 1 is the broadcast. The router does use a host address, but it is a normal one.
8. A school needs subnets for 50 students' PCs and 12 teachers' PCs, from 10.9.0.0/24. Select the two that are true.
- The students need a /26, because 50 + 2 fits in 64
- The teachers need a /28, because 12 + 2 fits in 16
- The teachers need a /29, because 12 fits in 8
- The students need a /25, because a /26 has only 50 hosts
Take the smallest block that fits hosts + 2: 52 → 64 (/26, 62 hosts) and 14 → 16 (/28, 14 hosts). A /29 has only 6 hosts.
Next: you chose addresses on paper. Before you type them into real machines, open a frame and see those addresses travel, field by field, in Wireshark: first capture.