Sub Netting, variable length Subnet Masks (VLSMs)

subnetting and subnet mask

In the previous articles, we have learned how to define and find the valid host ranges used in Class A, Class B, and Class C network address by turning the host bits all off and then all on.

This is very good, but here’s the catch: we were defining only one network. What happens if you wanted to take one network address and create six networks from it? You would have to do something called Subnetting because that’s what allows you to take one larger network and break into a bunch of smaller network.

There are loads of reasons in favor of subnetting, including the following benefits:

  • Reduced Network traffic: We all appreciate less traffic of any kind. Networks are no different. Without trusty routers, packet traffic could grind the entire network down to a near standstill. With routers, most traffic will stay on the local network, only packets destined for other networks will pass through the router. Routers create broadcast domains. The more broadcast domains you create, the smaller broadcast domains and the less network traffic on each network segment.
  • Optimized network performance: this is a result of reduced network traffic.
  • Simplified management: it’s easier to identify and isolate network problems in a group of smaller connected networks than within one gigantic network.
  • Facilitated spanning of large geographical distances: because WAN links are considerably slower and more expensive than LAN links, a single large network that spans long distances can create problems in every area previously listed. Connecting multiple smaller networks makes the system more efficient.

Subnet Mask

For the subnet address scheme to work, every machine on the network must know which part of the host address will be used as the subnet address.

This is accomplished by assigning a subnet mask to each machine. A subnet mask is a 32-bit value that allows the recipient of IP packets to distinguish the network ID portion of the IP address from the host ID portion of the IP address.

The network administrator creates a 32 bit subnet mask composed of 1s and 0s. The 1s in the subnet mask represents the positions that refer to the network or subnet addresses.

Not all networks need subnets, meaning they use the default subnet mask. This is basically the same as saying that a network doesn’t have a subnet address.

The following table shows the default subnet masks for Class A, B, and C. These default masks cannot change. In other words, you can’t make a Class B subnet mask read If you try, the host will read that address as invalid and usually won’t even let you type it in. for a Class A network, you can’t change the first byte in a subnet mask; it must read at a minimum.

Similarly, you cannot assign, as this is all 1s broadcast address. A Class B address must start with and a Class C has to start with

Class Format Default Subnet Mask
A network.node.node.node

Classless Inter-Domain Routing (CIDR)

Another term you need to familiarize yourself with is Classless Inter-Domain Routing (CIDR). It’s basically the method that ISPs (Internet service providers) use to allocate a number of addresses to a company, a home or a customer. They provide addresses in certain block size, something I’ll be going into greater detail later in this article.

When you receive a block of addresses from an ISP, what you get will look something like this: This is telling you what your subnet mask is.

The slash notation (/) means how many bits are turned on (1s). obviously, the maximum could only be 32 because a byte is 8 bits and there are 4 bytes in an IP address. But keep in mind that the largest subnet mask available regardless of the class of address can only be a 30 because you’ve got to keep at least 2 bits for host bits.

Take, for example, a Class A default subnet mask, which is This means that the first byte of the subnet mask is all one (1s), or 11111111. When referring to a slash notation, you need to count all the 1s bits to figure out your mask. The is considered an 8 because it has 8 bits that are small 1s that is, 8 bits that are turned on.

A Class B default mask would be which is a /16 because 16 bits are one (1s).

Subnet Mask CIDR value /8 /9 /10 /11 /12 /13 /14 /15 /16 /17 /18 /19 /20 /21 /22 /23 /24 /25 /26 /27 /28 /29 /30

The /8 through /15 can only be used with Class A network addresses. /16 through /23 can be used by Class A and Class B network addresses. /24 through /30 can be used by Class A, B and C network addresses. This is a big reason why most companies use Class A network addresses since they can use all subnet masks, they get maximum flexibility in network design.

Subnetting Class C Addresses

There are many different ways to subnet a network. The right way is the way that works best for you. In a Class C address, only 8 bits are available for defining the hosts. Remember that subnet bits start at the left and go to the right, without skipping bits. This means that only Class C subnet masks can be of the following:

Binary Decimal CIDR
00000000 0 /24
10000000 128 /25
11000000 192 /26
11100000 224 /27
11110000 240 /28
11111000 248 /29
11111100 252 /30

We can’t use a /31 or /32 because we have to have at least 2 host bits for assigning IP addresses to hosts. In the past, I never discussed the /25 in a Class C network. Cisco always had been concerned with having at least 2 subnet bits, but now, because of Cisco recognizing the IP subnet zero command in its curriculum and exam objectives, we can use just 1 subnet bit.

Variable Length Subnet Masks (VLSMs)

I could easily devote an entire article to Variable Length Subnet Masks (VLSMs), but instead, I’m going to show you a simple way to take one network and create many networks using subnet masks of different lengths on different types of networks designs. This is called VLSM networking.

Classful and Classless Networking

Neither RIPv1 nor IGRP routing protocols have a field of subnet information, so the subnet information gets dropped. What this means is that if a router running RIP has a subnet mask of a certain value, it assumes that all interfaces within the classful address space have the same subnet mask. This is called a classful routing, and RIP and IGRP are both considered classful routing protocols. If you mix and match subnet mask lengths in a network running RIP or IGRP, that network just won’t work!

Classless routing protocols, however, do support the advertisement of subnet information. Therefore, you can use VLSM with routing protocols such as RIPv2, EIGRP, and OSPF. The benefit of this type of network is that you save a bunch of IP address space with it.

As the name suggests, with VLSMs we can have different subnet masks for different router interfaces. The following figure shows an example of why classful network designs are inefficient.

Looking at this figure, you’ll notice that we have two routers, each with two LANs and connected together with a WAN serial link. In a typical classful network design (RIP or IGRP routing protocols), you could subnet a network like this: = Network = Mask
Sub Netting, variable length Subnet Masks (VLSMs)

Our subnets would be (you know this part, right?) 0, 16, 32, 48, 80, etc. this allows us to assign 16 subnets to our internetwork. But how many hosts would be available on each network? Well, as you probably know by now, each subnet provides only 14 hosts.

This means that each LAN has 14 valid hosts available one LAN doesn’t even have enough addresses needed for all the hosts! But the point-to-point WAN link also has 14 valid hosts. It’s too bad we can’t just nick some valid hosts from that WAN link and give them to our LANs!

All hosts and router interfaces have the same subnet mask again, this is called classful routing. And if we want this network to be more efficient, we definitely need to add different masks to each router interface.

But there’s still another problem the link between the two routers will never use more than two valid hosts! This wastes valuable IP address space, and it’s the big reason I’m going to talk to you about VLSM network design.

VLSM Design

Let’s take the above figure and use a classless again which will become the new network shown in the picture below. In the previous example, we wasted address space one LAN didn’t have enough addresses because every router interface and host used the same subnet mask. Not so good.

What would be good is to provide only the needed number of hosts on each router interface. To do this, we use what are referred to as a Variable Length Subnet Masks (VLSMs).

Now remember that we can use different size masks on each router interface. And if we use a /30 on our WAN links and a /27, /28, and /29 on our LANs, we’ll get 2 hosts per WAN interface, and 30, 14, and 8 hosts per LAN interface nice! This makes a huge difference not only can we get just the right amount of hosts on each LAN, we still have room to add more WANs and LANs using this same network.

Sub Netting, variable length Subnet Masks (VLSMs)

Implementing VLSM Networks

To create VLSMs quickly and efficiently, you need to understand how block sizes and charts work together to create the VLSM masks. The table given below shows you the block sizes used when creating VLSMs with Class C networks.

For example, if you need 25 hosts, then you’ll need a block size of 32. If you need 11 hosts, you’ll use a block size of 16. Need 40 hosts? Then you’ll need a block of 64. You cannot just make up block sizes they’ve got to be the block sizes shown in the table. They are the same numbers we used with subnetting.

Prefix Mask Hosts Block Size
/25 128 126 128
/26 192 62 64
/27 224 30 32
/28 240 14 16
/29 248 6 8
/30 252 2 4

The next step is to create a VLSM table. The figure below shows you the table used in creating a VLSM network. The reason we use this table is so we don’t accidentally overlap networks.

You’ll find the sheet shown in the figure very valuable because it lists every block size you can use for a network address. Notice that the block sizes are listed starting from a block size of 4 all the way to a block size of 128. If you have two networks with block sizes of 128, you’ll quickly see that you can have only two networks.

With a block size of 64, you can have only four networks, and so on, all the way to having 64 networks if you use only block sizes of 4. Remember that this takes into account that you are using the command IP subnet-zero in your network design.

Now, just fill in the chart in the lower-left corner, and then add the subnets to the worksheet and you’re good to go.

So let’s take what we’ve learned so far about our block sizes and VLSM table and create a VLSM using a Class C network address for the network in the figure 3.6. The fill out the VLSM table, as shown in figure 3.7.

In the figure 3.6, we have four WAN links and four LANs connected together. We need to create a VLSM network that will allow us to save address space. Looks like we have two block sizes of 32, a block size of 16, and a block size of 8, and our WANs each have a block size of 4. Take a look and see how it has been filled out our VLSM chart in figure 3.7.

Sub Netting, variable length Subnet Masks (VLSMs)
Sub Netting, variable length Subnet Masks (VLSMs)

We still have plenty of room for growth with this VLSM network design.

We never could accomplish that with one subnet mask using class ful routing. Let’s do another one. Figure 3.8 shows a network with 11 networks, two block sizes of 64, one of 32, five of 16, and three of 4.

First, create your VLSM table and use your block size chart to fill in the table with the subnets you need. figure 3.9 shows a possible solution.

Notice that we filled in this entire chart and only have room for one more block size of 4! Only with a VLSM network can you provide this type of address space savings.

Keep in mind that it doesn’t matter where you start your block sizes as long as you always count from zero. For example, if you had a block size of 16, you must start at 0 and count from there 0, 16, 32, 48, etc. you can’t start a block size of 16 from, say, 40 or anything other than increments of 16.

Here’s another example. If you had block sizes of 32, you must start at zero like this: 0, 32, 64, 96, etc. just remember that you don’t get to start wherever you want; you must always start counting from zero. In the example in figure 3.9, I started at 64 and 128, with my two block sizes of 64. I didn’t have much choice, because my options are 0, 64, 128, and 192. However, I added the block size of 32, 16, 8, and 4 whenever I wanted just as long as they were in the correct increments of that block size.

Okay you have three locations you need to address, and the IP network you have received is to use as the addressing for the entire network. You’ll use ip subnet zero and RIPv2 as the routing protocol. Figure 3.10 shows the network diagram and the IP address of the Router A S0/0 interface.

Sub Netting, variable length Subnet Masks (VLSMs)
Sub Netting, variable length Subnet Masks (VLSMs)

from the list of IP addresses on the right of the figure, which IP address will be placed in each router’s FastEthernet 0/0 interface and serial 0/1 or Router B?

to answer this question, first look for clues in figure 3.10. The first clue is that interface S0/0 on Router A has IP address assigned, which makes for an easy answer.

A /30, as you know that, is, which gives you a block size of 4. Your subnets are 0, 4, 8, etc. since the known host has an IP address of 2, the only other valid host in the zero subnet is 1, so the third answer is down is what you want for the s0/1 interface or Router B.

The next clues are listed number of hosts for each of the LANs. Router A needs 7 hosts, a block size of 16 (/28); Router B needs 90 hosts, a block size of 128 (/25); and Router C needs 23 hosts, a block size of 32 (/27).

Figure 3.11 shows the answers to this question.

Once you figured out the block size needed for each LAN, this was actually a pretty simple question all you need to do is look for the right clues and, of course, know your block sizes.

One last example of VLSM design before we move on to summarization. Figure 3.12 shows three routers, all running RIPv2. Which class C addressing scheme would you use to satisfy the needs of this network yet save as much address space as possible?

Sub Netting, variable length Subnet Masks (VLSMs)
Sub Netting, variable length Subnet Masks (VLSMs)
Sub Netting, variable length Subnet Masks (VLSMs)