In the post, https://nepcodex.com/2020/05/what-is-subnetting/, we talked about what subnetting is. Similarly, in the previous post, we understood about subnet mask, IP address, Network ID and Host ID. Now, we are going look at some examples to divide a network.

## Example 1 – Subnet a network with equal number of hosts

Firstly, we are going to divide a network such that each network has an equal number of hosts. Let’s assume, we have a network **103.5.150.0/24** to divide. This is the address of Pulchowk Campus, IOE, Nepal. This means we get the space for 256 addresses. Also, the requirement is that each network can have at most **26** hosts.

Now, in the previous post, we know that each network has an address to identify it and another address for broadcasting. Hence, the total number of IP addresses per network is **26 + 2 = 28**. Furthermore, the nearest number with a raised exponent of 2 is **2 ^{5} = 32**. So, we can use the last 5 bits for the hosts, and first 3 bits for the network. Hence, there will be 23 = 8 networks with capacity of 32 – 2 = 30 hosts. So, let’s convert the last octet of addresses into the binary system.

**103.5.150.0 = 103.5.150.00000000**

Also, the subnet length prefix is 24, which means the subnet mask is **255.255.255.0 = 255.255.255.00000000**

As we have said we are going to borrow the first 3 bits of the last octet for each subnet. Therefore, the range of subnets will be as follows.

**103.5.150.00000000 – 103.5.150.00011111 **having subnet mask **255.255.255.11100000**.

i.e. **103.5.150.0 – 103.5.150.31** having subnet mask **255.255.255.224**

i.e. **103.5.150.0/27**, Net-ID = **103.5.150.0**, Broadcast Address = **103.5.150.31**

**103.5.150.00100000 – 103.5.150.00111111 **having subnet mask **255.255.255.11100000**.

i.e. **103.5.150.32 – 103.5.150.63** having subnet mask **255.255.255.224**

i.e. **103.5.150.32/27**, Net-ID = **103.5.150.32**, Broadcast Address = **103.5.150.63**

Similarly,**103.5.150.01000000 – 103.5.150.01011111 **having subnet mask **255.255.255.11100000**.

i.e. **103.5.150.64 – 103.5.150.95** having subnet mask **255.255.255.224**

i.e. **103.5.150.64/27**, Net-ID = **103.5.150.64**, Broadcast Address = **103.5.150.95**

And, so on. To summarize, the networks will be:**103.5.150.0/27, 103.5.150.32/27, 103.5.150.64/27, 103.5.150.96/27, 103.5.150.128/27, 103.5.150.160/27, 103.5.150.192/27, 103.5.150.224/27**

## Example 1 – Subnet a network with different number of hosts

The above example is the simplest to understand the process. Now, suppose we have a requirement that each network can have different hosts. For example, there are 5 departments in a college, say A, B, C, D, E. There are 4 routers to connect the departments with each other. Again, the network is **103.5.150.0/24**. The number of hosts for the networks are as follows:

**A: 12, B: 60, C: 31, D: 28, E: 15, A-B: 2, B-C: 2, C-D: 2, D-E: 2**

Since we have to take account of the network ID and broadcast address, we have to add 2 addresses in the requirement. i.e.**A: 14, B: 62, C: 33, D: 30, E: 17, A-B: 4, B-C: 4, C-D: 4, D-E: 4**

Now, we have to arrange the required number of hosts in descending order. i.e.**B: 62, C: 33, D: 30, E: 17, A: 14, A-B: 4, B-C: 4, C-D: 4, D-E: 4**

So, the actual total number of hosts for each network are:**B: 64 = 2^{6}, C: 64 = 2^{6}, D: 32 = 2^{5}, E: 32 = 2^{5}, A: 16 = 2^{4}, A-B: 4 = 2^{2}, B-C: 4 = 2^{2}, C-D: 4 = 2^{2}, D-E: 4 = 2^{2}**

This means that we have to borrow **8 – 6 = 2** bits for networks **B** and **C**, **8 – 5 = 3** bits for **D** and **E**, **8 – 4 = 4** bits for A and **8 – 2 = 6** bits for the router links.

So, converting the last octet of the addresses to the binary system, we get.

Network IP address: **103.5.150.0 = 103.5.150.00000000**

Subnet Mask: **255.255.255.0 = 255.255.255.00000000**

### Departments

For network B:**103.5.150.00000000 – 103.5.150.00111111** with subnet mask **255.255.255.11000000**

i.e. **103.5.150.0 – 103.5.150.63** with subnet mask **255.255.255.192**

i.e. **103.5.150.0/26**, Net-ID = **103.5.150.0**, Broadcast Address = **103.5.150.63**

Similarly, for network C:**103.5.150.01000000 – 103.5.150.01111111** with subnet mask **255.255.255.11000000**

i.e. **103.5.150.64 – 103.5.150.127** with subnet mask **255.255.255.192**

i.e. **103.5.150.64/26**, Net-ID = **103.5.150.64**, Broadcast Address = **103.5.150.127**

For network D:**103.5.150.10000000 – 103.5.150.10011111** with subnet mask **255.255.255.11100000**

i.e. **103.5.150.128 – 103.5.150.159** with subnet mask **255.255.255.224**

i.e. **103.5.150.128/27**, Net-ID = **103.5.150.128**, Broadcast Address = **103.5.150.159**

Similarly, for network E:**103.5.150.10100000 – 103.5.150.10111111** with subnet mask **255.255.255.11100000**

i.e. **103.5.150.160 – 103.5.150.191** with subnet mask **255.255.255.224**

i.e. **103.5.150.160/27**, Net-ID = **103.5.150.160**, Broadcast Address = **103.5.150.191**

For network A:**103.5.150.11000000 – 103.5.150.11001111** with subnet mask **255.255.255.11110000**

i.e. **103.5.150.192 – 103.5.150.207** with subnet mask **255.255.255.240**

i.e. **103.5.150.192/28**, Net-ID = **103.5.150.192**, Broadcast Address = **103.5.150.207**

### Router Links

For router links, A-B:**103.5.150.11010000 – 103.5.150.11010011** with subnet mask **255.255.255.11111100**

i.e. **103.5.150.208 – 103.5.150.211** with subnet mask **255.255.255.252**

i.e. **103.5.150.208/30**, Net-ID = **103.5.150.208**, Broadcast Address = **103.5.150.211**

For router links, B-C:**103.5.150.11010100 – 103.5.150.11010111** with subnet mask **255.255.255.11111100**

i.e. **103.5.150.212 – 103.5.150.215** with subnet mask **255.255.255.252**

i.e. **103.5.150.212/30**, Net-ID = **103.5.150.212**, Broadcast Address = **103.5.150.215**

For router links, C-D:**103.5.150.11011000 – 103.5.150.11011011** with subnet mask **255.255.255.11111100**

i.e. **103.5.150.216 – 103.5.150.219** with subnet mask **255.255.255.252**

i.e. **103.5.150.216/30**, Net-ID = **103.5.150.216**, Broadcast Address = **103.5.150.219**

For router links, D-E:**103.5.150.11011100 – 103.5.150.11011111** with subnet mask **255.255.255.11111100**

i.e. **103.5.150.220 – 103.5.150.223** with subnet mask **255.255.255.252**

i.e. **103.5.150.220/30**, Net-ID = **103.5.150.220**, Broadcast Address = **103.5.150.223**

Hence, in this way, we can divide a network according to the requirements. As we can see that, we didn’t oversupply the departments with the IP addresses. Therefore, we have some addresses available and ready to be allocated in future.

## Conclusion

In this way, we can subnet a network. Check out the others posts for more contents.

## 1 thought on “How to subnet a network?”