- [Instructor] A lot of information
flows through networks via IPv4 addressing,
but before I can demonstrate
how to configure it on equipment,
I first must explain how it operates.
And this is easily one of the most difficult parts
of a fledgling engineer's studies.
An IPv4 address which I'll just refer to as an IP address
for the remainder of this chapter,
is a 32-bit number that's broken down into four octets.
So 32 divided by four tells me
that each octet is comprised of eight bits.
In an IP address each octet is separated by a period,
which is why it's called dotted decimal format.
Each octet can range from zero to 255 in decimal notation,
of from eight zeros to eight ones in binary.
IP addresses are converted to binary one octet at a time.
So only eight binary digits need to be managed at once.
With binary each position can be thought of
as on-off switch.
If it's set to zero then it's off, while a one denotes on.
Each binary position equals the numbers shown here.
Starting for the right each place is doubled
as it moves to the left.
So if the rightmost bit is on,
the decimal number it represents is one.
If I turn that bit off,
then flip on the second bit, then that decimal is two.
If I turn on both the first and second places,
the decimal number represented here is three.
In essence I take all the numbers
in the on position and add them up.
For example this number is 128 plus eight plus two plus one,
which totals up to a decimal value of 139.
Here's an example of the IP address
10.1.2.200 in binary form.
Another key component of IPv4 addressing
is the subnet mask or network mask.
In essence the subnet mask identifies
which portion of the address is the network,
and which is the host address.
A large chunk of addressing
can be further subdivided into smaller subnets.
And this is often simply called subnetting.
Knowing how to subnet is essential for any network engineer,
and to be honest was the toughest concept
for me to wrap my head around.
Though there are some rare exceptions,
subnet masks start from the left to the right
with bits on in binary.
For example, the subnet mask 255.255.0.0
looks like 16 ones followed by 16 zeros.
This allows for 65,534 hosts.
A subnet with that mask is often referred to as a /16
since the first 16 bits are all on.
A subnet mask of 255.255.255.0
would be 24 ones followed by eight zeros.
This allows for 254 hosts,
a much more manageable user subnet.
A subnet of this size is universally known as a /24
since the first 24 bits are all on.
And a lot of modern devices also allow the subnet mask
to be represented by slash notation
since it's a more efficient method of representing the mask.
Take the network 10.10.10.0/24
and this technically has 256 addresses from zero to 255.
I found the number 256
by taking the remaining eight bits in the subnet mask
and then converting them to decimal form.
And they aren't all usable for hosts though.
The very first address in the network
is known as the network address.
So in this example the network address is 10.10.10.0.
Also the very last address is dedicated
as the broadcast address and in this case it's 10.10.10.255.
The broadcast address is set aside so any hosts
that want to send broadcast traffic on this subnet
can use this special address.
If for some reason I wanted to break this /24 subnet in half
I would use the subnet mask /25.
This would produce two new subnets, 10.10.10.0/25,
and 10.10.10.128/25.
I cheat when I do a lot of this math
as I don't do any binary conversions.
If I have a network of /24
and I add a bit to the right making it a /25,
the one network now doubles to two.
If I take that /24 and turn it into a /26
the number keeps doubling,
so it goes from /24 which is one network,
then /25 which is two,
then /26 doubles again so now it's four.
As I keep adding bits to the right on the subnet mask,
I keep doubling the number of subnets.
The converse follows in the reverse order.
I use /24s a lot because they are good for user subnets.
So if I wanted to have eight /24 networks,
and I want to figure out
what larger network would represent this,
I would start calculating to the left.
A /23 is two /24 networks.
A /22 is four /24 networks.
And a /21 is eight /24 networks.
Remember, binary doubles or halves
as you add or remove bits.
Keep in mind that it's not a one-size-fits-all situation.
With my 10.10.10.0/24 subnet
I could divide this into multiple different
subnetted networks like 10.10.0/25
which will be one to 126 for hosts.
Then 10.10.10.128/29
which will be from 129 to 134 for hosts.
This is known as variable length subnet masks.
It's honestly a case of whatever works best
for the network at hand.
There are some shortcuts
to figuring out subnet mask and slash notation.
The way I learned was to memorize a few numbers
and to use my fingers.
I've actually used the same memorization trick
for the last 16 years.
Examine this chart.
Notice how there is a repeating number pattern.
0, 128, 192, 224, 240,
248, 252, 254 and finally 255.
I'll start with a simple example.
192.168.1.0/24.
Each octet in the subnet mask represents eight bits.
Eight times three is 24.
So I know the first three octets all have binary ones
and when an octet is all ones, it is 255 in decimal form.
This means the last octet is all zeros.
Which makes its decimal value zero.
So for this example it will be 255.255.255.0.
Now to complicate things.
I'll change my subnet mask to 192.168.1.0/27.
So since /24 is the start of the octet
I count up to 27 using my fingers,
25, 26, 27.
I now have three fingers up on my left hand.
Now I count out the numbers I memorized
three spots, 128, 192, 224.
This means my subnet mask is 255.255.255.224.
Now, using that subnet mask
I can determine how many addresses are available
in that subnet.
And this is done by taking 256
and subtracting the last octet from it.
So 256 minus 224 equals 32.
I'll subtract two from 32,
the very first entry 192.168.1.0 for the network address,
and 192.168.1.31 for the broadcast address.
And this leaves me with 30 usable IP addresses
that can be assigned to network devices.
I can also determine the next available subnet
by continuing to add 32.
So 192.168.1.0/27
then 192.168.1.32/27,
and 192.168.1.64/27 and so on.
The same subnet memorization works for even larger networks.
10.10.0.0/16 means all bits are on for the first two octets.
All bits on is 255 so the subnet mask is 255.255.0.0.
If I wanted to figure out
what 10.10.0.0/20 subnet mask would be
I go back to my fingers.
/16 is the nearest octet with all bits on.
So I'll start from there.
17, 18, 19, 20, counting on my fingers
that works out to 128, 192, 224, 240.
That makes my subnet mask 255.255.240.0.
Here's another trick to figure out
the next subnet without subtraction.
With my four fingers up
I start dividing in 1/2 starting from 256.
So 128, 64, 32, and last 16.
And this means every 16 digits
in this octet are the networks.
That would be 10.10.0.0/20.
Then 10.10.16.0/20.
Then 10.10.32.0/20 and so on.
Granted the previous method works too.
The subnet mask of 255.255.240.0,
I'll subtract 240 from 256
which gives me, you guessed it, 16.
With those little tricks
I can find and convert subnets in my head in seconds
without doing real math or referencing charts.
Again this was the single most difficult portion
of my CCNA studies
and I had to read many resources to get it to stick.
So while you shouldn't fret
about not immediately understanding it,
don't pursue the test until you do.