Instead of going through the different known methods for calculating subnets, such as using binary or decimals. Let’s try to learn subnetting techniques by using practical examples.
Scenario 1:
You have been given a network range of 172.16.1.0/24. You must manage this range and ensure following departments and hosts are connected.
- Administration – 20 hosts.
- Finance – 5 hosts.
- Students – 120 hosts.
How would you subnet your range to support this requirement ?
How many hosts in total can our original /24 support ? Well 24 out of 32 bits are used for the network part, which leaves us with 8 bits for the hosts, so 2^8=256. Of these 256 hosts, you must take out the 2 reserved addresses.
2^8-2=254
Reserved hosts are 172.16.1.0 which is the network address. And 172.16.1.255 is the broadcast address.
254 is enough to cover our campus total of 145 hosts and even have some spares for growth. But what about the splitting of networks, we still need to carve out 3 subnet out of the original /24.
Let’s start with the highest number of hosts, the students range. We have to think power of 2, and 128 is 2^7, so if we borrow one bit from the host part, we end up with 1+7. 1 bit for subnet, and 7 bits for hosts.
By borrowing one bit from the host part, we create 1 bit for the subnet and 7 for for hosts. We have effectively split a /24 into 2 equal /25, which results in 2 new subnets 172.16.1.0 and 172.16.1.128. The new subnet mask is now 25 and not 24. Each of these new subnets holds 126 hosts, so enough to cover students LAN.
Using the same logic, let’s create a new subnet for the Admin LAN. Closest power of 2 to 20 is 32. So 2^5 should give us 30 hosts, which is enough to cover our requirement and still have some room for growth.
Looking at 172.16.1.128 which now has 7 bits for host part, we can borrow a further 2 bits from it and add them to the subnet part. We end up with 3 bits for subnet and 5 for host part.
Out of 172.16.1.28/25, we have just carved out 4 new subnets (2^2), with each holding 30 hosts (2^5-2). The new subnet mask will be /27, or 255.255.255.224.
Once more, we further subnet one of the 4 new /27 networks, this time to support 6 hosts. Or if we expect aggressive growth, we could even go for 14 hosts. In which case a /28 or /29 will cover the requirement.
Scenario 2:
Given a subnet with decimal notation, how to workout the prefix format, network and broadcast addresses ?
255.255.255.240, take a look the last octet and note that 240 in binary is 1111 0000. 4 bits used from this octet, and 3×8=24 (from 255.255.255), so 255.255.255.240 can be represented as /28.
How many subnet can we extract from 192.168.1.0/28 ?
256-240=16, so now we can draft our network ranges starting from zero, and incrementing by 16.
network 1: 0, since following network address is 16, then this network’s broadcast address is 16-1, so 15. Valid hosts are what is in between [1-14]
network 2: 16, broadcast address is 32-1=31, valid hosts are [17-30].
.
.
.
network 16: 240, broadcast is 255 and valid hosts in [241-254]
You will memorise subnets and equivalent prefix formats on below table in no time.
Subnet Mask | Prefix Format |
---|---|
255.255.255.0 | /24 |
255.255.255.128 | /25 |
255.255.255.192 | /26 |
255.255.255.224 | /27 |
255.255.255.240 | /28 |
255.255.255.252 | /29 |
255.255.255.252 | /30 |