Now at this point of the course,
we're about to jump into the area
that most students dread when it comes to networking,
and this is known as subnetting.
Now, don't worry, I'm going to get you through it,
but this is probably one of the hardest
concepts on the exam.
You may need to go through this section
a couple of times to make sure you grasp it.
Now, what we're going to do is I'm going to go through
and we're going to do the hard way first,
so you understand the theory and how it all works.
Then, I'm going to show you a shortcut
and how to get through it for the exam a lot easier.
But please, don't skip the next couple of lessons
of going through the hard way first
'cause if you don't understand the hard way,
the easy way will make zero sense to you.
Subnetting is where we can take a large network
and we split it up into smaller networks.
When we do this, this is all about logical IP addressing.
The default class full subnet mask
is rarely going to be the optimal subnet for our subnet size.
So, instead, we use subnet masks to modify the subnets
and create networks that are much better in scope.
For instance, let's say I gave you a network
of 10.something.something.something.
This is a Class A address.
That means there are 16.7 million
IP addresses in that range.
You may have a large network,
but your network is probably not 16.7 million clients.
So, we would want to create subnets
that allow us to borrow bits from the original host portion
and then we can add them into the network portion
to make smaller networks for us.
So, for example, if I had a network like 10.0.0.0/8
that is a classful Class A subnet,
and it has 16.7 million hosts,
but I probably need something
like a couple of hundred hosts,
maybe 256 of them.
Well, if I wanted to do that,
I might use the Class C subnet mask of /24
and use that instead.
By using 10.0.0.0/24,
that's going to give me 256 IPs in that subnet,
and that means those other 16 million
can be used by other people.
Then, maybe I'm going to create a second subnet,
like 10.0.1.0/24,
and then I can create a third subnet
with 10.0.2.0/24.
And now, I've used three subnets of 256 IPs each,
and I still have millions of leftover IPs
that I can subnet out later.
This is why it's really important to use subnets
because it's an efficient use of the IP addresses you have
instead of just using the classful default.
Even in your home network, if you're using a Class C address
of something like 192.168.1.0/24,
this gives you 256 possibilities,
but you probably only have 5 or 10 devices
on your home network.
Now, by doing subnets,
this is going to allow us to create
additional VLANs and subnets
and allow separation of our networks for better security
and giving us better bandwidth control.
Here on the screen you can see a chart
that has the addresses for Class A, B, and C subnets
and their default masks,
which should be a review for you at this point.
Now, on the right side,
you're going to see the assignable number of IP addresses,
which is for class A of 16.7 million addresses,
for Class B 65,000 plus IP addresses,
and Class C 254 usable IP addresses.
That is a lot of IP addresses.
Now, we may want to start necking those down
into usable chunks,
and that is what we're going to use subnetting for.
If we're using private IPs, this really isn't a big deal
because they don't cost me anything,
but with public IPs, every public IP I paid for,
that's money out of my pocket
and you want to minimize that
to only getting the ones you need.
For example, my ISP charges $5 per month for a static IP.
If I need one, that's $5.
If I need 10, that's $50.
If I need 100, that's $500.
And so, that can add up pretty quickly, right?
By subnetting, it allows me to just get the things
that I need and the fewer IPs that I need.
Now, how do we do this?
Well, that's what we use a subnet mask for.
We talked about Class A, Class B, and Class C
default subnet masks back when we talked about it before,
and you'll see those on the screen in red.
They are the /8, /16, and /24.
Now, when you convert those to binary,
you can see that they're filled by all the octets
with either all 1s or all 0s, making them classful.
Now, the ones on the bottom of the screen
from 25 down to /30 are going to be smaller subnets.
These are called classless subnets
because they're going to use different things
besides all 1s or all 0s in that octet.
Now, as you can see,
we're borrowing bits from the host portion
and making all those 0s and taking some of those,
adding them over into the network portion as well.
And so, this borrowing is what we're doing with subnetting.
If you don't get it yet, don't worry,
we are going to dig deeper into it
as we continue through this lesson.
Now, let's take a look at some formulas
that we're going to need to understand
for calculating the number of subnets
and the number of assignable hosts.
If I'm calculating the number of subnets,
the formula is 2 to the s power,
where s is the number of borrowed bits from the host.
So, when I start taking those 0s from the host
and turning them to 1s
to make them a part of the network portion,
that is the s that we're talking about here.
For instance, if I'm using a /25 as my network,
I'm borrowing 1 bit from the host space
and putting it into the network space.
Now, this would make it 2 to the 1,
and that would give me 2.
And so, that tells me I can have 2 subnets by using a /25.
Now, if I'm looking at the number
of a assignable IP addresses,
this is going to be 2 to the number of host bits minus 2.
So, in my case of a /25 network,
there are 32 total bits in the address.
I have 25 of those being assigned for the network portion,
leaving me with 7 host bits.
So, if I take 2 to the 7th
and then I'm minus 2,
I get 128 minus 2, or 126 available.
Now, why do I have to have that minus 2 there?
This is a concept that a lot of students miss,
so really pay attention to it.
Every network out there
has to have two IP addresses to be a network.
The first is known as the network ID,
and it's the first IP in the range for that network.
And the other one is a broadcast ID,
which is the last IP in the network.
So, no matter what network you choose,
you always have to sacrifice the first one and the last one.
The first one is your network ID or network name,
and your last one is your broadcast.
Now, anytime you calculate this number of usable IPs,
it's always going to be the number minus 2
'cause you have to take away the network name
and the broadcast name.
Let's take a look at classful versus subnetting networks.
A classful network, if you remember,
are the ones like /8, /16, /24.
And if I use the example of 192.168.1.0/24,
this is a classful Class C network.
There is one network here because it is 2 to the 0
because I borrowed 0 bits because /24 is classful.
This means that there is 2 to the 8
minus 2 assignable IPs,
which gives me 256 IPs minus 2,
one for the broadcast, one for the network,
and that gives me 254 usable IPs.
As you can see here on the screen,
we have all the network bits, all 24 of them,
and therefore it is classful.
Now, we have 8 bits of the host.
And let's say that I wanted to make a smaller subnet.
How could I do that?
Well, I could borrow 2 bits from the host
and create a subnet.
This would make it a /26, for instance.
So, if I borrow those 2 host bits,
now it becomes 2 to the s or 2 to the second power,
which gives me four networks,
four subnets that I've created.
So, if I consider those four networks,
how many IPs can I have
in each one of those four networks I just created?
Well, in the original /24,
I had 256 hosts total or IPs total.
Now, I borrowed those 2 host bits
and gave them to the network,
and so now I have 2 to the 6th power,
that's going to give me 64 IPs per subnet.
So, if I have 64 plus 64 plus 64 plus 64,
that equals 256.
So, I took that one big network, that /24,
and I turned it into four smaller networks, those /26s.
But remember, each of those I have to give away two IPs,
the first one and the last one.
The first one is the network name,
the last one is the broadcast.
So, I only have 62 usable IPs
that I can assign to a server,
or a laptop, or a phone, or something like that.
And so, for each of these four networks I've created,
I now have 62 usable IPs,
and I have four of those that were made up
out of that original /24 network.
Now, if you look at the blue at the bottom of this,
you can see my original 256 possible IPs,
which does include my broadcast and my network.
If I subnet that down, I'm going to have 4 subnets
or 2 to the 2nd power.
Now, I'm going to have 62 possible IPs
because each one was 2 to the 6th minus 2
because I take away the first and the last
for the network name and the broadcast.
In our case, this is going to give us the four subnets
as their name of 192.168.1.0,
192.168.1.64,
192.168.1.128,
and 192.168.1.192.
Those are my four network names.
Now, for the broadcast,
it's going to be the last IP of each subnet,
so that's going to be the ones ending in .63,
.127, .191, and .255.
So, hopefully now you're starting to see
how these subnets start to work together.
If we want to calculate those IPs,
we're going to do that based on those subnet masks.
So, when we take those 32 bits,
which is the total number of bits minus whatever our slash
or CIDR notation is,
in this case 26,
we get that there are 6 host bits remaining.
That would be 2 to the 6th minus 2,
which is 64 minus 2, or 62 usable assignable IPs.
Now, I'm hoping that all of this
is starting to come together as we've gone through it.
Subnetting is a very complex topic
that a lot of students struggle with.
I want you to keep practicing it
and keep working through the problems
because I guarantee on test day
you're going to get some questions on subnetting.
Now, some of these questions
might ask you just to do the problem,
but most of them are going to be more about troubleshooting.
There's going to be some computers
that aren't talking to another,
and when you start looking at their IP addresses
and their subnet mask,
you're going to notice they're not on the same subnet.
And if there's no router there,
data won't go from one subnet to another,
and so this is an important concept.
Now, let's talk about how we list out these subnets.
Let's keep going with our example
of the 192.168.1.0/26,
and those four subnets we created of 62 usable IPs each.
Now, where does each network begin and end?
We kind of already went over this
by saying it was the .0,
the .64, the .128, and the .192
as our beginning of each network.
Now, where did I come up with those?
Well, I started with the original IP
of 192.168.1.0.
Now, zero is my first IP
and it is going to be the name of that network.
Each subnet we said was 64 IPs in length,
so if I take 0 plus 64, I get .64.
If I add another 64, I get .128.
If I add another 64, I get .192.
Now, how do I find the last IP for each of these?
Well, that's going to be my broadcast address.
All I need to do is add .63 to each of these numbers
because there's 64 IPs,
the first one is used for the name,
the last one, the plus 63, gets me to that broadcast ID.
And so, I get 63,
127, 191, and 255.
That's going to be the beginning and ending of each subnet.
It goes from 0-63,
64-127, 128-191, and 192-255.
Everything in between those,
for instance I might have something like 32,
is going to be a usable IP.
Those are things we're going to assign to clients,
and servers, and tablets, and laptops, and desktops,
and all those things.
Now, when we do all of these, we write these out,
we're going to write them out
with what's known as the slash notation.
So, we'd write 192.168.1.0
/192.168.1.127
That's pretty long to write that out
for each of the four subnets.
So, instead we have this shorthand notation
called a CIDR notation,
and this stands for the Classless Inter-Domain Routing.
Instead of advertising multiple individual routes,
we summarize all those as a single route.
We do this through CIDR notation,
and in this case we had the /26.
So, I can consolidate all of those
underneath them by doing a summary
of the continuous networks using route aggregation.
When I do this and I look at the /26,
I notice that the first 26 bits are all equivalent,
they're all the same for the subnet mask.
So, by consolidating those,
this allows me to put all those networks together
in one slash notation and simply write them down this way.
Next, we have a Variable-Length Subnet Mask, or VLSM.
This allows subnets of various sizes to be used.
Everything I've done so far has been equal.
I took a big chunk of 256 IPs
and broke them up into four equal 64-bit chunks,
but we don't have to do that.
I could actually break it up
and have a 16 chunk, and a 32 chunk, and a 64 chunk,
and that way I can do that to what's right for my network.
Now, this is going to require a routing protocol
that supports this, but all modern routing protocols do,
including things like RIP,
OSPF, IS-IS, EIGRP, and BGP.
Basically, Variable-Length Subnet Masking
is a subnetting of subnets.
Without VLSM, all subnets would have to be the same size.
But by using VLSM,
I can break them up into whatever chunks I want.
And I'm going to give you the key to subnetting here.
When you look at this chart,
this is your subnetting exam tip.
Write this down in your notes.
Now, the one I want you to memorize here
is this small chart off to the right.
You can do all the math on test day
and spend a lot of time trying to do 2 to the s
and 2 to the h-2,
or you can memorize this small chart on the right.
If you notice, it's going to start with /24,
and you have that as your subnet as a classful Class C,
you have 256 IPs.
You know this because we've talked about this a lot, right?
Now, if I add one to the CIDR notation, it becomes /25,
I increased the number of networks.
By adding 1, I borrowed a bit,
that's going to give me two subnets,
and that's going to take my 256 IPs
and divide it by 2, giving me 128.
Notice, I'm always going to have 256 IPs
as I go from /24 downward all the way down to /30.
So, every time my CIDR notation goes up by one,
my number of networks goes up by one,
and my number of IPs gets divided by two.
If you can remember this chart on the right,
this is going to help you on test day
get through a lot of the questions on subnets,
and it's really nice and easy.
Now, the good thing is for Network+,
they're not going to give you a lot of difficult subnets.
Almost all the ones you're going to get
are going to be /24 or higher.
The most they're going to give you
is something like a /23 maybe or a /22, but that's rare.
Generally, it's going to be /25, 26, 27, 28, 29, and 30.
That is the most common.
So, if they ask you something like you have a /28,
how many subnets are created?
It's pretty easy.
You look at this chart and you go, "Ah, the answer is 16."
If I go from 24 up to 28,
I keep doubling it, and I double it to get to 25,
I double it again to get to 26,
double it again to get to 27,
double it again to get to 16, right?
And that is where I get to /28 is 16
because I went 2, 4, 8, 16, and there we go.
Now, you might ask how many IPs you'd have in each subnet
if you had a /30.
Well, for a /30,
that's what we'll use for point-to-point connections,
and there's going to be four IPs,
but only two of those are usable
'cause again, our first one
is always the name of the network,
and the last one is always the broadcast.
So, you have four IPs, two of which are usable.
And if you remember this chart,
you're going to be able to do great on subnetting on the exam.
Now, before the test,
I want you to take lots of practice subnetting problems,
especially in your Class C range.
Everything from /24 to /30 is really fair game
for the Network+ exam.
Memorizing these slash notations and the CIDR
is going to help you answer any question they throw at you.
But as we go through this section,
I'm going to show you a shortcut
that you can do just using your hands as well,
and you're going to really like this,
but having this chart memorized
is going to help with that as well.
Now, for the exam,
something you may see is they might have you do
a variable-length subnetting problem.
Now, if they do a VLSM problem for you,
it might be they gave you an IP address with 256 IPs
because they're going to give you a /24,
and then they might say, "Hey, you have an IT department
that needs x number of IPs,
you have a HR department needs x amount of IPs,
you have a sales department that needs y amount of IPs,"
and you'll have to go through and do the slash notations
for each one based on the number of IPs they give you.
That is a totally fair question on the exam
and how you'd put this subnetting stuff
to work in the real world.