In this lesson,
we're going to discuss IPv4 addressing.
Now, IPv4, or Internet Protocol version 4,
is extremely popular, and it's the most common type
of IP addressing used in our networks.
In fact, if you're like most people,
you've probably seen an IPv4 address before.
When you look at them, they're written as a series
of four decimal numbers separated by dots.
Some examples of an IPv4 address
are things like 10.1.2.3
or 172.21.243.67
As you can see, each IPv4 address
is made up of four different parts to form that address,
and this is why we call it a dotted-decimal notation.
When you're referring to each
of those four parts individually though,
we call these an octet
because each of them is a decimal number that's being used
to represent eight bits of a binary number.
Now, since each octet uses a decimal number
to represent an eight-bit binary number,
each octet can be represented by value of 0 to 255
in each of those four octets of an IPv4 address.
Now, when all four octets are combined,
we get four octets that contain eight bits each
for a total of 32 bits of total addressable space
when using an IPv4 address.
Now, for example, let's say you have the IPv4 address
of 192.168.1.4
That is being written in dotted-decimal notation
to make it easier for you and I as humans to read it,
but to a computer, that actually isn't what it is.
Instead, they understand this as binary,
which is 11000000
.10101000
.00000001
.00000100
Now, as you can see, using the dotted-decimal notation
is a lot easier for us to read out loud and for us to type,
and so it's less prone for us experiencing human error
when we enter those numbers
into our network device configurations,
and it's a lot easier to memorize
the decimal version of this than the binary.
Now, each IPv4 address is actually going to be created
using two portions, which we refer to as the network portion
and the host portion of the address.
So when you get an IP address like 192.168.1.4,
it's actually broken down into these two portions,
the network and the host portion,
by using a second 32-bit number known as a subnet mask.
Now, when you look at a subnet mask in decimal form,
it's going to look a lot like an IPv4 address,
but if you look at it in binary form,
you're going to see there's actually continuous strings
of ones and zeros,
with the ones identifying the network portion
and the zeros identifying the host portion
of that IPv4 address that it's going to be married up with.
For example, let's say I have a subnet mask
of 255.255.255.0
Now, if we converted each of these octets into binary,
we would actually get 11111111.
11111111.
00000000
Notice we have three sets of eight ones
and then one set of eight zeros in our binary form
to represent the decimal equivalent of 255.255.255.0
Now, when you look at that subnet mask, and you see a one
in that binary representation of the subnet mask,
this becomes the network portion of the IPv4 address.
If you see a zero in the binary representation
of the subnet mask, this becomes the host portion
of the IPv4 address.
So let's put this together by showing both the IPv4 address
and its associated subnet mask.
First, we have our IPv4 address of 192.168.1.4
Next, we have our subnet mask underneath it
of 255.255.255.0
Now, anytime I see a 255 in my decimal representation,
this is representing all ones if we converted it to binary,
so it becomes part of that network portion
of the IPv4 address.
So in this case, the 192.168.1
is our network portion of the address.
Anytime I see an IPv4 address
that starts with 192.168.1.something,
this means that it's addressable
as part of this local network because all those things
are going to be part of this network portion.
Now, everywhere I see those zeros in the subnet mask,
this actually represents the host portion
of the IPv4 address.
In this case, that's the .4 portion of the address
of 192.168.1.4 that we had before.
And that .4 is going to represent this specific host,
like a server, a desktop, a laptop,
a tablet, a printer, or any other network device
that was assigned this IPv4 address.
So if I have an address like 192.168.1.50
with a subnet 255.255.255.0,
that device is on the same network
as our 192.168.1.4 device,
and they can communicate to each other using a switch,
and we wouldn't even have to use a router
because they're on the same network.
This means our switch will transfer data back and forth
between these two devices using just their MAC addresses,
and we're not going to have to route traffic
using a router between these two devices.
Now, on the other hand, if I had a device like 172.16.0.100
with a subnet mask of 255.255.255.0,
this tells me that that device is on a different network,
and specifically, it's on the 172.16.0.something network.
So we're not going to be able to communicate
with the original device at 192.168.1.4
without leaving its network, routing the traffic
to this new network of 172.16.0.something,
and that way you have to do that using a router
or a layer 3 switch to make that routing happen.
Now, if this doesn't quite make sense yet,
don't worry too much about it right now
because we're going to dive much deeper
into both subnetting and routing in their own lessons
because we have barely scratched the surface so far.
Now, the next thing we need to talk about
is that it's important to realize that IPv4 addresses
are going to be broken down into classes
or groupings of ranges that can be used,
and each class has its own default subnet mask.
Each class is going to be identified by a letter,
and there are five classes,
class A, class B, class C, class D, and class E.
To identify the class
for a certain IPv4 address that you have,
simply look at the first octet.
A class A network's first octet
will include a number between 1 and 127,
and they're going to have a default subnet mask of 255.0.0.0
This means that the network portion of the address
is the first octet, and the second, third, and fourth octets
will all make up the host portion.
This allows a class A address
to have up to 256 times 256 times 256 hosts
on a single network,
which means we have a total possible combination
of 16.7 million IP addresses available
for each one of our class A networks going from 1 to 127.
A class B network's first octet
is going to include a number between 128 and 191,
and they have a default subnet mask of 255.255.0.0
This means that the network portion of the address
is made up of the first and second octets,
and then the third and fourth octets will be reserved
for that host portion of the address.
This means that a class B network
can have up to 256 times 256 hosts on a single network,
which gives us 65,536 possible host IP addresses
for each of our class B networks.
Now, a class C network's first octet
is going to include the number between 192 and 223,
and these class C addresses
are going to have a default subnet mask
of 255.255.255.0
This means that the network portion of the address
is the first, second, and third octets,
and then that fourth octet
is going to make up your host portion.
Because we only have a fourth octet for our host portion,
this means a class C network will only be able to have
up to 256 hosts or IP addresses on a single network.
Now, a class D network's first octet
is going to include the numbers between 224 and 239.
Now, a class D address
does not have a subnet mask assigned to them
because these class D addresses are considered special,
and they're reserved for something known as multicasting
or multicast routing.
Now, a multicast address is simply a logical identifier
for a group of hosts in a computer network
that are available to process datagrams or frames
intended to be multicast for a designated network service.
So the actual multicast address
doesn't align to one specific host,
but instead it refers to a group of hosts.
Now, when you think about a multicast address,
think about it like a group chat.
You have a group chat name,
in our case, a multicast address,
and when you send a message to the group chat's name,
all of the members of that group are going to get a copy of it.
Well, the exact same thing happens in IPv4
when you're using multicast,
and that's what we use class D for.
Now, the last class we have is known as class E,
and class E's first octet is going to include a number
between 240 and 255,
and again, class E addresses
do not have a subnet mask assigned to them
because they are also special,
and they're reserved for experimental purposes
in terms of research and development only.
This experimental range contains
about 268 million IPv4 addresses
that are reserved for what they call, quote, future use.
Now, over the years, there have been a few proposals
to reallocate these class E addresses for general use
because we started running out of public IPv4 addresses
over time inside of the class A, class B, and class C ranges
because more and more devices have become connected
to the internet over time.
That said, to date, as of the time of me saying this,
these class E addresses still remain allocated
for experimental use only,
and most IP implementations inside of our networks
will consider any IP inside of the 240.0.0.0
all the way up to 255.255.255.255 range
to be considered invalid as the source
or destination within your datagrams,
and therefore, the datagram will be rejected
by your destination system.
For example, a Windows server or workstation
will simply refuse to communicate with any device
that's claiming it's in the class E address space
because class E addresses should not be used
in a production or workplace environment.
All right, now that I've briefly discussed
the concept of subnetting, I want to go ahead
and point out that subnetting is just a process
of taking a larger network portion
and subdividing it down into smaller portions.
Now, when it comes to subnetting and subnet masks,
we have two different types.
We have classful subnet masks and classless subnet masks.
A classful subnet mask is one that uses the default
with a particular IPv4 address.
For example, if you have an address like 10.0.0.0,
this is a class A address based on the first octet.
So if we use a classful subnet mask with it,
we're going to use 255.0.0.0,
and this gives us 16.7 million hosts
inside that single class A network.
For a class B address,
the default subnet mask is 255.255.0.0,
and this gives us 65,536 hosts
inside of the single class B network.
For class C addresses, the default subnet mask
is going to be 255.255.255.0,
and this gives us up to 256 hosts
in a single class C network.
Now, unfortunately, these classful subnet masks
often create network sizes
that are way too big for us to use.
For example, I probably don't need
16.7 million host IP addresses for a home network,
like a class A would provide me,
nor do I need 65,536 hosts, like a class B provides.
And to take it further,
most of us also don't need 256 hosts,
like a class C would provide.
So instead, we might want to break down
these larger networks into smaller portions
using what's known as a classless subnet mask
through a process known as subnetting.
Now, a classless subnet mask
is going to be used to borrow some of the host bits
from an IPv4 address by reassigning them to a one
in the binary representation of that subnet mask.
And that way, we can increase
the size of the network portion
and decrease the size of the host portion
for a given IPv4 address.
For example, let's pretend I have an IP address
of 192.168.1.0
with a classful class C subnet mask of 255.255.255.0
Now, this gives me 256 IPs for use in my network.
But if I only need to use 64 IP addresses,
I can instead borrow two bits from the host portion
and assign them to the network portion of that subnet mask.
And this gives me 255.255.255.192
as my subnet mask instead.
Now, since the default for a class C network
is 255.255.255.0,
and I'm choosing to use something else
besides that as my subnet mask,
I am now having a classless subnet mask.
This process is known as classless inter-domain routing,
or CIDR, and we usually abbreviate our IP addresses
and subnet mask into one combined notation
which we call CIDR notation,
which we pronounce CIDR notation.
For example, the IP address of 192.168.1.4
with a subnet mask of 255.255.255.0
could be abbreviated as 192.168.1.4/24
if I'm writing it in CIDR notation.
Now, you may be wondering,
why did I put /24 to represent 255.255.255.0?
Well, what we're really doing here is counting the number
of binary digits that are listed as a one
in the network portion of the address.
So if we have 255.255.255.0,
we actually have 24 ones followed by eight zeros,
so we write this as a /24
instead of having to write out 255.255.255.0
This /24 is considered to be a classful subnet mask
for any class c network.
On the other hand, if I have the classless subnet mask
of 255.255.255.192,
I would write this IP address as 192.168.1.4/26
Because, remember, we borrowed two host bits
and changed them to ones,
so they became part of the network bits.
So now, instead of having 24 ones and eight zeros,
I have 26 ones and only six zeros.
This gives me a /26 class C subnet mask,
which would be classless
as a subnet mask for a class C network.
Now, if you're using a class A subnet,
it has to be considered classful
if you have a /8 CIDR notation,
which is a subnet mask of 255.0.0.0,
to indicate that there are eight bits of ones
and 24 bits of zeros in that subnet mask.
For a class B subnet mask to be considered classful,
it must have a CIDR notation of /16
or a subnet mask of 255.255.0.0,
which indicates that it has 16 bits of ones
and 16 bits of zeros in that subnet mask.
For a class C subnet masks to be considered classful,
it must have a CIDR notation of /24
or a subnet mask of 255.255.255.0
to indicate that it has 24 bits of ones
and eight bits of zeros in its subnet mask.
So remember, IPv4 addresses are commonly used
inside of our networks, and these IPv4 addresses
are decimal representations of a 32-bit binary number
that we would write out our IPv4 addresses in,
our dotted-decimal notation,
to represent each one of the four octets.
These IPv4 addresses are further divided
into network and host portions of the address
based on their subnet masks.
Remember that these IP addresses are classified into classes
of class A, class B, class C, class D, and class E,
depending on the first octet in their address,
and then each of these classes
has its own default subnet mask.
When this default subnet mask is used,
we call this a classful subnet mask.
But if you use any subnet mask
that is not the default for that specific class,
we will call this a classless subnet mask instead.