What is Subnetting?

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:

network subnetting example class c

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:

  1. 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.
  2. 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:

network subnetting example class B

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.

Subnet Design

Let’s look at the network we used earlier:

network subnetting example without subnets

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:

network subnetting example single subnet size

In the picture above, I added the VLANs for each site, I am using /24s everywhere.

Why?

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.

network subnetting example different subnet sizes

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 77.60.0.0 – 77.60.10.255 space for these four sites. If the number of sites would double, we’ll probably use something like 77.60.11.0 – 77.60.20.255. I picked 77.60.30.0 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.

Conclusion

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.

Tags:


Forum Replies

  1. I have a few questions around subnetting:

    • My understanding is that networks were broken into classes. This was inefficient. So CIDR was released to allow for “subnet” bits to be browed from the host and additional networks to be created. Is my understanding correct?
    • When subnetting do we always start from the default mask. i.e for a Class A network do I always start with a /8 and then subnet from there?
    • VLSM then allowed for these subnetworks to be variable in length rather then all being the same size. Is my understanding correct?
    • One confusion I have is arou
    ... Continue reading in our forum

  2. Hello Rick

    You got most of it, but I hope this clarifies it a bit more.

    CIDR is Classless Inter Domain Routing. This feature allows routing to occur not only between classful addresses but also between classless addresses. Classless addresses are those that allow a variable length subnet mask (VLSM), those that have a subnet mask other than the allowed classful address. So VLSM is the feature of IP addresses that allows CIDR to take place.

    ... Continue reading in our forum

  3. Thanks. What you have provided makes better sense. However when subnetting with the RFC1918 addresses Im still unclear,

    When subnetting a block into small subnets do you calculate from the classful subnet mask or the prefix.
    For example an 192.168.x.x. Do you subnet from /16 or 24. And this is the same for 172.16.x.x do you subnet from the /12 or /16.

  4. Hello Rick

    It all depends on what the requirements are. Remember that subnetting is something that you end up applying to a real world network so the network range you start off with can be anything. If you are given a network of 192.168.0.0/23 and you are asked to further subnet it to segments of /26 then that is what you will do. There is no rule that sa

    ... Continue reading in our forum

  5. Hi,

    Your responses have been really useful. And greatly appreciate your help.
    So based on all of this would mean…

    I have a 192.168.0.0/24. Im right in thinking I can get a maximum of 254 networks from this as the prefix is /16. The mask is /24. Therefore I have 8 bits as subnet bits to play with.

    Lets take another example:
    How many subnets and hosts per subnet can you get from the network 172.30.0.0 255.255.255.240 ? Its a class B so /12 bits are used for the network id. Therefore we have /16 subnet bits and 4 host bits. So this would give us… 65536 subnets with 14 hosts.

    Thanks

32 more replies! Ask a question or join the discussion by visiting our Community Forum