Now, what about subnet masks?
I've mentioned subnet masks a few times.
What is a subnet mask?
What does it do?
Well, a subnet mask is used to determine which part of an IP address is the network portion and which
part of the address is the host portion.
This allows a PC, for example, to determine whether a device that it wants to communicate with is
a remote device or a local device.
So here's an example.
We have a PC with IP address, 10.1, 1.1 and another PC with an IP address of 10.1 to 2.1.
When the PC on the left wants to forward traffic to the PC on the right with IP address 10.1 to 2.1,
does the PC forward the traffic onto the local segment or does it forward it to its default gateway?
If these two devices are in the same subnet, they can communicate directly without the use of a default
gateway.
But if they're on different subnets, the PCs will forward their traffic to their default gateways,
which will do the inter VLAN routing if they're on the local LAN or local area network as an example
or route the traffic if the traffic is forwarded to a traditional router.
So a layer three switch may do the routing between two VLANs or a router may route the traffic between
these two devices if they are in different subnets.
But how would you determine if these two devices are on the same subnet or if they're on different subnets?
Now, I'm going to explain this in more detail in the next few minutes.
But as an example, 10.1, .1.1 and 10.1 or 2.1 are in the same subnet if they're using a slash 16 mask.
However, if they're using a slash 24 mask, that means that the devices are on different subnets.
So let me explain that in more detail.
A network mask allows a device to determine once again which portion of the address is the host portion
and which portion of the address is the network portion.
This allows a local PC as an example to determine whether the device it wants to communicate with is
on a remote network and is thus reachable via the default gateway.
Or if the device is on the local subnet and therefore does not require the use of a default gateway.
So if PCA and PCB are in the same subnet, no default gateway is required.
But if they're on different subnets, then a default gateway would typically be required to do the routing
between the two PCs.
So that's essentially what a network mask does.
Now, as I've explained, plus A, B and C, networks have default masks, which are also known as natural
masks in a Class A address.
The first octet is the network in a Class B address.
The first two octets are network and with a class C address, the first three octets are the network
portion.
I'll explain more complicated subnet masks in the subnet videos, but let's first start with some simple
examples.
In this example, we have a Class A network that hasn't been submitted in a Class A network.
The default mask is 255.0.0.0.
So if we look at a address such as 10.1, 1.1 and convert that into binary, it's going to look as follows.
Now look at the following mosque 255 in binary equates to eight binary ones.
Zero in decimal equates to eight binary zeros.
So converting the mosque into binary shows us that the network portion consists of contiguous ones or
continuous ones, starting from the left hand side.
A one in binary in the network mosque indicates network a zero in binary in the network mosque indicates
host.
So in this example, this portion of the address is a network and this portion of the address is host.
Hence this device with IP address 10.1 1.1 is on network ten .0.0.0.
This is the network portion and this is the host portion.
This device with IP address ten .1.1.1 is on network ten.
So when working out the network and host portions of an address, follow these two simple rules.
Any address bits that have a corresponding mosque but set to one in binary represents the network.
Any address bits that have a corresponding mosque but set to zero represents the host.
So one in binary means network zero in binary means host.
So in this example, ten is the network because there are ones in the mosque in binary.
So the network ID is set to ten notice.
These octets are populated by binary zeros.
That means host.
So the host ID is equal to 1.1.1.
So in summary, the network is ten.
The host portion of the address is 1.1.1.
He has another example.
Remember any address bits that have a corresponding mosque but set to one in binary represents network.
Any address bits that have a corresponding mosque but set to zero in binary represent node ID.
So here we've got a class A address 1.1.1.1.
But note the difference.
The network mosque in this case is 255225500.
So converting 1.1.1.1 to binary gives us the following.
Taking the network mosque and converting that to binary gives us the following notice 255 equates to
eight binary ones, which therefore means that this portion of the address is a network.
So the network ID is 1.1.
And looking at the remaining part of the address, which is populated with binary zeros in the network
mosque, means that 1.1 is the host portion of the address.
In other words, the network is 1.1.0.0 with a host portion of 1.1 on that network.
The mosque is 255.255.020.
In this example, it's easy to see the network portion of the address because we have 255.255 in the
network mosque.
Just be aware that things can get a lot more complicated than what we're seeing in these examples.
You'll see that when we get to the subnet videos.
These two examples are simple because it's easy to recognize which portion is a network and which portion
is host in the subnet videos.
I'm going to show you much more complicated examples.
And in those examples it's more difficult to determine which portion is network and which portion is
host.
So in summary, how does a device know whether another device is local or remote to itself?
So the first thing it will do is check the network portion of its local address and then compare that
to the address of the other host.
If the network portion of the address is the same, the local device knows that the other device is
local to itself.
If the network portion is not the same, the local device knows that the other device is remote.