In this lesson, we’ll take a look at what subnetting is and why we use it. Remember our class A, B and C networks?
Class A: 16777216 addresses in total.
Class B: 65536 addresses in total.
Class C: 256 addresses in total.
A subnet is a sub-network of a network that falls within the class A, B or C range.
For example, 172.16.0.0/16 is a class B network. This network is pretty big, it starts with 172.16.0.0 and ends with 172.16.255.255.
Instead of one big network, we can use a smaller “portion”. An example is 172.16.1.0/24. This subnet falls within the 172.16.0.0/16 class B network so that’s why it is called a “sub”net.
Why would you want to do this? Let me show you a picture:
Above we have a small company network with four routers. Each router represents a site for this company. Behind each router, we find a switch with a host. We are using the following class C networks:
- R1: 192.168.1.0/24
- R2: 192.168.2.0/24
- R3: 192.168.3.0/24
- R4: 192.168.4.0/24
- R1-R2: 192.168.5.0/24
- R1-R3: 192.168.6.0/24
- R1-R4: 192.168.7.0/24
Technically, this will work; but why is using these networks a poor choice? There are two reasons:
- There’s a limited amount of class C (private) networks. We can choose between 192.168.0.0/24 and 192.168.255.0/24. What if we have more than 256 sites? There’s not enough space so you will have to pick another network range.
- The links in between the routers are point-to-point links so we only need two IP addresses, one for each router. When we use a /24 subnet mask, we are wasting 252 IP addresses. This is no problem when we use private IP addresses but it is an issue when we use public IP addresses. Public IP addresses are very limited so you’ll have to use smaller subnets so that you don’t waste any.
We could improve this network somewhat by using subnets from the class A or B range. Here’s an example:
We are now using subnets from the class B 172.16.0.0/16 network. This network offers so much more space, the private range starts with 172.16.0.0 and ends with 172.31.255.255. You can get a lot of subnets out of that…
We are still wasting a lot of IP addresses though with the links in between our routers so there’s room for improvement.
When we talk about subnetting, there’s two things we have to do:
- Creating a design: like the examples above, you have to think of how many subnets you need and which ones you are going to use. For example, if we add R5…what subnet are we going to use? What if we create multiple VLANs on SW1? What subnets will you use for these VLANs? You need to think about this beforehand or things will get messy.
- Calculations: Above, I used a /24 subnet mask which is easy but not efficient. In between the routers, you might want to use a smaller subnet with only enough IP addresses for the two routers. These calculations can be done with subnet calculators (you can find dozens with a google search) but on (Cisco) exams, you have to calculate these on your own.
Let’s look at an example so that I can explain the choices we have to make when designing a network.
Let’s look at the network we used earlier:
Can we say anything about the number of subnets that we need here? Not really, the only thing we can (probably) tell is that we need a subnet in between each router pair.
What we need to know additionally is:
- How many VLANs are there? Each VLAN requires a different subnet.
- How many hosts do we have in each VLAN?
- What is the expected growth of this network?
Let’s say we get the following answers to our questions:
- R1: four VLANs, each with 100 users.
- R2: two VLANs, each with 30 users.
- R3: three VLANs, each with 20 users.
- R4: two VLANs, each with 10 users.
They expect that the number of VLANs and users could double. Maybe, two additional sites will be added sometime in the future. What are we going to do?
Single Subnet Size
The largest VLAN has 100 users and they expect it to double, this means we have to use a subnet that permits 200 IP addresses. We can use a /24 subnet mask since it has 254 usable IP addresses. Our network could look like this:
In the picture above, I added the VLANs for each site, I am using /24s everywhere.
If this is an enterprise network, you probably use private IP addresses on your LAN. Some VLANs only required a subnet for 10 users (20 when taking growth into account) so we could have picked smaller subnets.
It is however far more convenient to use the same subnet size everywhere. People are familiar with /24 subnet masks, the first usable IP address starts with .1 and the last usable one ends with .254. One of the two can be used as your default gateway for each VLAN.
There’s plenty of IP space so it’s not really required to use small subnets. I also left plenty of space in between the sites. Behind R1, we can use 172.16.0.0 – 172.16.9.255. Behind R2, they only required two VLANs (four when taking growth into account) but I also reserved plenty of space here.
The only exception are the router links. I decided to start with 172.16.100.0 here so that we can use 172.16.0.0 – 172.16.99.255 for sites. Since we only need two IP addresses in between the routers, I decided to pick the smallest subnet we can use, a /30.
Multiple Subnet Sizes
What if the network we just talked about was not a LAN but a service provider network that uses public IP addresses? Each router could represent a different site, each VLAN could be a different customer. In this case, we have to be as efficient with IP addresses as possible…
Let’s look at our requirements again:
- R1: four VLANs, each with 100 servers.
- R2: two VLANs, each with 30 servers.
- R3: three VLANs, each with 20 servers.
- R4: two VLANs, each with 10 servers.
Let’s say that the number of sites, VLANs, and servers could double. We will need to design a subnetting plan that accounts for:
- R1: eight VLANs, each with 200 servers.
- R2: four VLANs, each with 60 servers.
- R3: six VLANs, each with 40 servers.
- R4: four VLANs, each with 20 servers.
And reserve space for potential sites R5, R6, R7 and R8.
Let me explain why I picked the subnets you see above:
- The VLANs behind R1 will have 200 servers, this means we need a /24 at least since it allows 254 usable IP addresses.
- The VLANs behind R2 will have 60 servers, the smallest subnet we can use is a /26 which allows 62 usable IP addresses.
- The VLANs behind R3 will have 40 servers, the smallest subnet we can use is a /26 which allows 62 usable IP addresses.
- The VLANs behind R4 will have 20 servers, the smallest subnet we can use is a /27 which allows 30 usable IP addresses.
- In between the routers, we can use /30 since it allows 2 usable IP addresses. I decided to start with 77.60.30/30 since we used the 126.96.36.199 – 188.8.131.52 space for these four sites. If the number of sites would double, we’ll probably use something like 184.108.40.206 – 220.127.116.11. I picked 18.104.22.168 to reserve a bit more space.
Keep in mind this is just an example but it should give you an idea of what you need to think about when making a subnetting plan.
You have now learned what subnetting is and why we have to use it. In other lessons, we will take a look how you can calculate subnets, how to determine the network address, broadcast address and more.