-
Welcome to Jeremy’s IT Lab. This is a free,
complete course for the CCNA. If you like
-
these videos, please subscribe to follow along
with the series. Also, please like and leave
-
a comment, and share the video to help spread
this free series of videos. Thanks for your
-
help.
-
In this we will be talking about ‘subnetting’.
This is a very big topic for the CCNA, but
-
not just for the test, it’s an essential
skill for a network engineer. Many people
-
have trouble understanding subnetting, but
let me assure you, it is NOT difficult. Subnetting
-
is very simple if you take it step-by-step.
So, I’m going to split subnetting into 2
-
, or maybe even 3 videos so we can take our
time to really understand subnetting without
-
getting lost. Now, because subnetting is such
an important topic and many people have trouble
-
with it, there are already plenty of subnetting
videos on youtube. Of course feel free to
-
check out those videos too, there are some
different tricks and techniques people teach
-
that can speed up the subnetting process.
I, however, will simply outline the basic
-
steps involved in subnetting, I will avoid over-complicating the topic. My end
-
goal for these videos is that you understand
and can do subnetting. So let’s get started.
-
So, what will we cover in this video? Only
a couple things. First is C I D R, pronounced
-
CIDR, which stands for classless inter-domain
routing. What exactly is that? Well, remember
-
I introduced the IPv4 address classes, such
as class A, B, and C? Well, CIDR throws all
-
that away and lets us be more flexible with
our IPv4 networks. Then, of course, we’ll
-
cover the process of subnetting, taking it
step-by-step so you don’t get lost.
-
Now, before I get into CIDR, let’s review
these IPv4 address classes, so we can then
-
understand the need for classLESS IPv4 addressing.
There are five classes of IPv4 addresses,
-
A, B, C, D, and E. Class A addresses have
a first octet beginning with 0, and the rest
-
of the bits can either be 0 or 1. This leads
to a decimal range for the first octet of
-
0 to 127. Remember, an IPv4 address is 32
bits, so there are 4 octets, 4 groups of 8
-
bits, in an IPv4 address. This makes the class
A address range from 0.0.0.0 through 127.255.255.255.
-
Now, remember there are some special and reserved
addresses in these ranges that can’t be
-
used for normal IP addresses on a device,
but for this video we’ll just include all
-
of them in Class A. Class B addresses have
a first octet beginning with 1 0 , and the
-
other 6 bits can be either 0 or 1. This gives
a range for the first octet of 128 through
-
191. The address range for class B is 128.0.0.0
through 191.255.255.255. Class C addresses
-
have the first three bits set to 1 1 0, and
the others can be either 0 or 1. If you write
-
that range in decimal that is 192 through
223. The address range is therefore 192.0.0.0
-
through 223.255.255.255. Class D addresses
begin with 1 1 1 0 in binary, which gives
-
a range of 224 through 239 for the first octet
of the address. This means that the address range
-
for class D is 224.0.0.0 through 239.255.255.255.
Finally, class E address begin with 1 1 1 1
-
in binary, so the first octet range is 240
through 255, and therefore the address range is 240.0.0.0
-
through 255.255.255.255.
-
However, only the class A, B and C addresses
can be assigned to a device as an IP address,
-
as classes D and E have special purposes I
mentioned in the IPv4 addressing videos. Class
-
A addresses have a /8 prefix length, meaning
the first octet identifies the network and
-
the other three octets are used for individual
hosts within the network. Class B addresses
-
have a /16 prefix length, so the first two
octets identify the network, and the last
-
two octets identify individual hosts within
that network. Class C addresses have a prefix
-
length of /24, so the first three octets are
used to identify the network, and only the
-
last octet is used to identify individual
hosts within that network.
-
The different prefix lengths give different
characteristics to these classes. As you can
-
see, there are few class A networks available,
only 128, actually less than that because
-
some are reserved, like the 127.0.0.0/8 range,
which you may remember is used for loopback
-
addresses. Because only the first octet of
a class A address is used for the network
-
ID, there are three whole octets available
for addresses within each class A network,
-
so there are 16 million, 777 thousand, 216
addresses in each class A network. That is
-
2 to the power of 24, because there are 3
octets, 3 times 8 equals 24 bits. Class B
-
addresses are different, there more class
B networks, 16,384, but fewer addresses per
-
network, 65,536, which is still very many
addresses of course. Finally, there are very
-
many class C networks, 2 million 97 thousand
152 networks, but only 256 addresses per network.
-
So, how does a company get their own network
to use? Well, IP addresses are assigned to
-
companies or organizations by a non-profit
American corporation called the IANA, the
-
Internet Assigned Numbers Authority. The IANA
assigns IPv4 address and networks to companies
-
based on their size. For example, a very large
company might receive a Class A or Class B
-
network, remember there are lots of available
addresses to use for hosts in each class A
-
and class B network, while a small company
might receive a class C network, because there
-
are fewer addresses in each class C network,
only 256. However, this system led to many
-
wasted IP addresses, so multiple methods of
improving this system have been created. Let
-
me give you an example of how this strict
system of addresses can waste IP addresses.
-
So, here are two routers. As you can see,
R1 has three networks connected to it here.
-
Remember that routers are used to connect different
networks, so each of these links are separate
-
Layer 3 networks, different IP networks. R2
also has three networks connected here. Perhaps
-
each of these networks will have a few switches,
with many end hosts such as PCs and servers
-
connected to these switches. However, there
is one more network here. That’s this network
-
connecting these two routers. This is known
as a ‘point-to-point’ network, meaning
-
that its a network connecting two points,
in this case R1 and R2. For example, this
-
might be a connection between offices in different
cities, let’s say San francisco and new
-
york.
-
So, because this is a point-to-point network,
we don’t need a large address block, so
-
let’s use a class C network, 203.0.113.0/24.
Because this is a class C network, there are
-
256 addresses in the network. Minus 1 for
the network address, 203.0.113.0, minus one
-
for the broadcast address, 203.0.113.255,
minus one for R1’s address, which I’ll
-
assign as 203.0.113.1, and minus 1 for R2’s
address, which I’ll assign as 203.0.113.2.
-
That’s a total of 4 addresses used, and
252 addresses WASTED. Clearly, this is not
-
an ideal system.
-
Before introducing CIDR, here’s another
quick example of address waste. A company,
-
company X, needs IP addressing for 5000 end
hosts. This is a problem. Why? A class C network
-
does not provide enough addresses, so a class
B network must be assigned. Because a class
-
B network allows for about 65,000 addresses,
this results in about 60,000 addresses being
-
wasted.
-
When the Internet was first created, the creators
did not predict that the Internet would become
-
as large as it is today. This resulted in
wasted address space like the examples I showed
-
you, and there are many more examples that
I could show you. The total IPv4 address space
-
includes over 4 billion addresses, and that
seemed like a huge number of addresses when
-
IPv4 was created, but now address space exhaustion
is a big problem, there's not enough addresses. One way to solve, or remedy this is
-
CIDR. The IETF (Internet Engineering Task
Force) introduced CIDR in 1993 to replace
-
the ‘classful’ addressing system.
-
With CIDR, the requirements of ‘class A
address must use a /8 network mask, class
-
B must use /16, and class C must use /24’
were removed. This allowed larger networks
-
to be split into smaller networks, allowing
greater efficiency. These smaller networks
-
are called ‘subnetworks’ or ‘subnets’.
Let’s look at an example of splitting a
-
larger network into a smaller network so you
can see how it works.
-
Here’s the same point-to-point network we
looked at before. Previously, it was assigned
-
the 203.0.113.0/24 network space, but that
resulted in lots of wasted addresses. Let’s
-
write this out in binary. Here’s the binary,
with the dotted decimal underneath. Now, the
-
prefix length is /24, so here’s the network
mask, also known as the subnet mask, 255.255.255.0.
-
Remember, all ‘1s’ in the subnet mask
indicate that the same bit in the address
-
is the network portion. In this case, I made
the network portion blue, and the host portion
-
is red. Well, how many host bits are there? 8, because
it’s one octet. So, how many potential hosts, or how
-
many usable addresses are there? Well, the
formula is this. 2 to the power of 8, minus
-
2, equals 254 usable addresses. What is the
8? Well, it’s the number of host bits, which is
-
8 in this case. And why minus 2? Those are
the network address and broadcast address,
-
we can’t assign them to a device so we have
to remove them from the number of usable addresses.
-
So, we have 254 usable addresses, but we only
need two, one for R1 and one for R2.
-
However, CIDR allows us to assign different
prefix lengths, it doesn’t have to be /24.
-
Let’s get some practice calculating the
number of hosts with different prefix
-
lengths. 203.0.113.0/25. 203.0.113.0/26, 203.0.113.0/27,
/28, /29, /30, /31, and finally /32. I’ve
-
put /31 and /32 in red because they’re a
little bit special, you’ll see when you
-
try to calculate it. So, pause the video here
and try to calculate how many usable address
-
are in each network...okay, let’s check
out the answers.
-
So, here is 203.0.113.0, but this time with
a /25 mask. Notice that the network portion
-
of the address has extended into the first
bit of the last octet, and the mask
-
in dotted decimal is now written as 255.255.255.128.
I changed the color of the extra bit to purple,
-
but it is part of the network portion, the blue
part. If you don’t remember how to convert
-
from binary to dotted decimal, make sure you
review that, it’s very important for subnetting.
-
Now there are 7 bits in the host portion of
the address, so the number of usable addresses
-
is 2 to the power of 7, minus 2, which equals
126. Once again, we only need 2 addresses,
-
one for R1 and one for R2, so we will be wasting
124 addresses. That’s better than wasting
-
252 addresses with a /24 prefix length, but
still its wasteful.
-
How about a /26 prefix length? Notice that
it’s now written 255.255.255.192 in dotted
-
decimal, because two bits of the last octet
are now part of the network portion. Since
-
there are 6 host bits, there are now 62 usable
addresses in this network. If we were to use
-
a /26 network mask for the 203.0.113.0 network,
we would be wasting 60 addresses. Getting
-
better, but we can make this network even
smaller.
-
Now that you get the idea, let’s speed it
up. For a /27 prefix length, the mask is written
-
as 255.255.255.224 in dotted decimal. There
are now 5 host bits, so that means there are
-
30 usable addresses. As you can see, the address
space is getting smaller and smaller as we extend the
-
network mask.
-
For a /28 prefix length, the mask is written
as 255.255.255.240 in dotted decimal. There
-
are now only 4 host bits, so that means there
are 14 usable addresses. After assigning addresses
-
to R1 and R2 this would mean only 12 wasted
addresses. But we can make this address space
-
even smaller, to make our addressing even
more efficient.
-
If we use a /29 prefix length, the mask is
written as 255.255.255.248 in dotted decimal.
-
Now we have only 3 host bits, so that means
there are just 6 usable addresses. Again,
-
after we give R1 and R2 addresses there would
be only 4 wasted addresses.
-
If we use a /30 prefix length, the mask is
written as 255.255.255.252 in dotted decimal.
-
There are now only 2 host bits, so that means
2 usable addresses. So, this is perfect! There
-
are 4 total addresses, that's the network address,
the broadcast address, R1’s address, and
-
R2’s address. That means 0 wasted addresses!
-
Before moving on to /31 and /32 let me clarify
a little bit. So, instead of 203.0.113.0/24,
-
we will use 203.0.113.0/30, which is a subnet
of that larger class C network. 203.0.113.0/30
-
includes the address range of 203.0.113.0
through 203.0.113.3. Let me show you that
-
in binary. Here is 203.0.113.0 in binary,
the host portion all 0s. Here is 203.0.113.1,
-
203.0.113.2, and 203.0.113.3. These are the
4 addresses in the network, these two being
-
the two usable addresses which are assigned
to R1 and R2. So we took up 4 addresses with
-
this subnet, what about the other addresses
in the 203.0.113.0/24 range? The remaining
-
addresses in the address block, which are 203.0.113.4 – 203.0.113.255, are now available
-
to be used in other subnets! That’s the
magic of subnetting. Instead of using 203.0.113.0/24
-
and wasting 252 addresses, we can use /30 and
waste no addresses. Or, perhaps there is another
-
way to make this even more efficient? Let’s
look into it.
-
If we use a /31 prefix length, the mask is
written as 255.255.255.254 in dotted decimal.
-
There is now only 1 host bit, so that means...0
usable addresses. 2 to the power of 1 is 2,
-
minus 2 for the network and broadcast addresses,
means 0 addresses that we can assign to devices.
-
So, you used to not be able to use /31 network
prefixes because of this. HOWEVER, for a point
-
to point connection like this it actually
is possible to use a /31 mask. Let’s check
-
it out.
-
So here’s the 203.0.113.0/31 network, R1
is 203.0.113.0 and R2 is 203.0.113.1. The
-
203.0.113.0/31 network consists of the addresses
from 203.0.113.0 through 203.0.113.1...which
-
is actually only two addresses. Here they
are in binary. there’s 203.0.113.0, and
-
there’s 203.0.113.1. Normally this would
be a problem, because it leaves no usable
-
addresses after subtracting the network and
broadcast addresses, but for point-to-point
-
networks like this, a dedicated connection
like this between two routers, there is actually
-
no need for a network address or a broadcast
address. So, we can break the rules in this
-
case and assign the only two addresses in
this network to our routers. Note that, if
-
you try this configuration on a Cisco router,
you’ll get a warning like this, reminding
-
you to make sure that this is a point-to-point
link, but it is a totally valid configuration.
-
So, once again The remaining addresses in
the 203.0.113.0/24 address block, which are 203.0.113.2
-
– 255 are now available to be
used in other networks! But this time we’ve
-
saved even more addresses, using only 2 addresses
instead of 4 for this point-to-point connection.
-
People still do use /30 for point-to-point
connections at times, but /31 masks are totally
-
valid and more efficient than /30 so I recommend
this method!
-
But we still haven’t looked at the /32 mask.
A /32 mask is written as 255.255.255.255 in
-
dotted decimal, making the entire address
the network portion, there are no host bits.
-
If you calculate this using our formula, you
will get -1 usable addresses...clearly the
-
formula doesn’t work in this case. You won’t
be able to use a /32 mask in this case, and
-
you will probably never use a /32 mask to
configure an actual interface. However, there
-
are some uses for a /32 mask, for example
when you want to create a static route not
-
to a network, but just to one specific host,
you can use a /32 mask to specify that exact
-
host. Anyway, I’ll talk about that later
in the course, just know that /32 masks are
-
used at some points, but you don’t have
to worry about them for now.
-
Here’s a simple chart showing the dotted
decimal subnet masks, and their equivalent
-
in CIDR notation. That’s right, the way
of writing a prefix with a slash followed
-
by the prefix length, like /25, /26, etc.
is called CIDR notation, because it was introduced
-
with the CIDR system. Previously, only the
dotted decimal method was used. Note that
-
I’ve showed you only how to subnet a class
C network so far, but we will look at
-
class B and class A networks as well, with
prefix lengths like /17, /11, /9, etc.
-
I spent a lot of time on just that one
example, but I hope you can see the use of
-
subnetting, dividing a larger network into
smaller networks, called subnets. Instead
-
of using the whole 203.0.113.0/24 network
for the point to point connection, we can
-
use a /30 subnet and use only 4 addresses,
or even better use a /31 subnet and use only
-
2 addresses. I’ll give one more example
of subnetting before finishing up this video.
-
In the next video I’ll give you some practice
problems and walk you through them so you
-
can get some hands-on practice with subnetting.
-
So, here’s a scenario. There are 4 networks
connected to R1, with many hosts connected
-
to each switch. There are 45 hosts per network,
R1 needs an IP address in each network so
-
its address is included in the range. You
have received the 192.168.1.0/24 network,
-
and you must divide the network into four
subnets that can accommodate the number of
-
hosts required. First off, are there enough
addresses in the 192.168.1.0/24 network in
-
the first place? So, we need 45 hosts per network,
including R1, but also remember that each
-
network has a network and broadcast address,
so that’s plus 2, so we need 47 addresses
-
per subnet. 47 times 4 equals 188, so there’s
no problem in terms of the number of hosts.
-
192.168.1.0/24 is a class C network, so there
are 256 addresses, so we will be able to assign
-
4 subnets to accommodate all hosts, no problem.
-
Okay let’s see how we can calculate the
subnets we need to make. We need four equal
-
sized subnets with enough room for at least
45 hosts. Here, I’ve written out 192.168.1.0
-
with a /30 mask, 255.255.255.252. I skipped
/32 and /31, since these aren’t point to
-
point links, we can’t use /31, and definitely
cant use /32. Since there are 2 host bits,
-
the formula to determine the number of usable
addresses is 2 to the power of 2, minus 2.
-
2 to the power of 2 is 2 times 2, which is
4. So that means there are 2 usable addresses
-
in a /30 network. Clearly not enough room
to accommodate the 45 hosts we have.
-
How about if we use a /29 mask to make these subnets, can we fit
the 45 hosts we need? There are 3 host bits,
-
so the formula is 2 to the power of 3 minus
2. 2 to the power of 3 is 2 times 2 times
-
2, which is 8. Therefore there are 6 usable
addresses, not enough for 45 hosts.
-
How about if we use /28? There are 4 host
bits, so the formula is 2 to the power of 4
-
minus 2. 2 to the power of 4 is 2 times 2
times 2 times 2, which is 16. So, that means there are
-
14 usable addresses, once again not enough for 45 hosts.
-
How about /27? There are 5 host bits, so the
formula is 2 to the power of 5 minus 2. And 2 to
-
the power of 5 is 2 times 2 times 2 times
2 times 2, which equals 32. So that means
-
30 usable addresses, again not enough
for 45 hosts.
-
How about a /26 subnet mask? There are now 6
host bits, so the formula is 2 to the power
-
of 6 minus 2. 2 to the power of 6 is 2 times
2 times 2 times 2 times 2 times 2, which equals
-
64. That means there are 62 usable addresses.
So, it looks like we’ve found our number! /27
-
doesn’t provide enough address space. /26
provides more than we need, but we have to
-
go with /26. Unfortunately we can’t always
make subnets have exactly the number of addresses
-
you want. There might be some unused address
space. That’s actually fine, since its good
-
to have some room for growth anyway.
-
So I think this video has gone on long enough.
Instead of finishing this task in this video, I’ll make
-
it this week’s quiz. The first subnet (Subnet
1) is 192.168.1.0/26. What are the remaining
-
subnets? To help you out, here’s a hint. Find the broadcast address of Subnet
-
1. The next address after that is the network address
of Subnet 2. And then just repeat the process for Subnets
-
3 and 4. Post your answers in the comment
section, and I’ll also go over the answer
-
in the next video.
-
So, what did we cover in this video? We covered
CIDR, classless inter-domain routing, which
-
removes the rules of class A, B and C networks
and lets us be more flexible with network
-
addressing, according to the size of the network.
We also covered the process of subnetting,
-
but mostly just the basics. Hopefully you
understand the purpose of subnetting, and
-
know a little bit about how to do it. I’ll
clarify and expand upon many things in the
-
next video, but also feel free to ask any
questions you have in the comment section.
-
For today’s video there won’t be a practice
lab, that will be after I’ve finished explaining everything about
-
subnetting. There will be flashcards, however,
to help you review some of the things learned
-
in this video. You can download them from the link in the description.
-
I’ve also recently enabled the membership
feature for my channel. If you want to leave
-
a monthly tip to support me, this is another
great way to do so. Click join here under
-
the video to check it out.
-
For those who become a JCNP, aka Jeremy Certified
Network Professional, -level supporter, I’ll
-
give you a shoutout at the end of my videos.
So first of all, thank you so much to Vance Simmons. I just
-
enabled the membership feature and haven’t
said anything about it yet, and he became my first
-
JCNP-level supporter. Thank you so much for supporting
the channel, I hope the videos are helping
-
you out. And for my JCNA-level supporters,
thanks to you too.
-
Thank you for watching. Please subscribe to
the channel, like the video, leave a comment,
-
and share the video with anyone else studying
for the CCNA. If you want to leave a tip,
-
check the links in the description. I'm also
a Brave verified publisher and accept BAT,
-
or Basic Attention Token, tips via the Brave
browser. That's all for now.