Welcome to the ITFreeTraining video on subnetting. Understanding how to subnet is essential if
you want to deploy and maintain IPv4 networks.
In a previous video, I looked at how to convert from decimal to binary and binary to decimal.
This is an important skill to know when subnetting, so I will do a quick review. If I want to
convert the following binary number to decimal I would use the following table.
Each binary position has a value based on a power of 2. To convert the binary number,
it is just a matter of adding it to the table. Using this value will give us the last row
of the table. If the value is a 1, the power of 2 value is used, otherwise the total is
a zero.
Once all the totals have been worked out, it is just a matter of adding them up to get
the value. Now let’s have a look at converting decimal to binary.
Let’s consider the same value. To convert it to binary the powers of 2 are used again.
This time the value that is to be converted, 186 is compared with the powers of 2. If it
is higher, which it is, a 1 is recorded.
Since the value was higher, the powers of 2 value which is 128 is subtracted from the
value. The new value 58 is compared to the powers of 2 value. It is lower so a zero is
recorded. The process is repeated until all the values are calculated. This will give
the decimal number in binary. If you understand this process you are all set to start looking
into subnetting, otherwise I would suggest looking at our previous video of converting
decimals as it goes into this process in more detail.
Shown here are some examples of subnet masks. First, you can see subnet masks always have
1’s on the left hand side and zeros on the right hand side. Because of this, notice in
the first column, the last decimal in the IP Address. Since 1’s and 0’s must be
contiguous certain decimals will always be used.
Notice also the number of subnets and hosts that are available depending on which subnet
mask is used. As the number of 1 bits in the subnet mask decreases, more hosts are available
per subnet, however fewer subnets are available. Notice also that in the top two subnets there
are no subnets or hosts available. To understand more about subnets, let’s have a look at
why this is the case.
The subnet mask divides an IP Address into a network and host identifier. So what happens
when you are given an IP address like this one where all the subnet mask bits are set
to 1? First the IP Address and the subnet mask are applied. This will allow the network
prefix and host identifier to be found.
It is no surprise in this case that the host identifier will be 0.0.0.0. This is because
no bits have been assigned to the host part. When a subnet mask that is all 1’s is used,
the network prefix will always be the same as the original IP Address. So the question
remains, when is this useful?
This subnet mask is used when an exact match to an IP Address is required. Often you will
see this used in routing tables. When used in a routing table, it is used to ensure that
data gets routed a certain way.
To understand when this subnet mask may be used, consider this example. Let’s say the
administrator has a workstation on the network that is connected to a router. Users are also
on the same network as the administrator, and access a server on a remote network through
a router.
It is decided that the router will be changed to a device which supports secure connections
between clients and servers and also handles routing. There are still some problems with
the devices, and more configuration and testing is required before it can replace the router
on the network. For these reasons, the new device is given its own IP Address on both
networks.
The problem that now occurs is that the administrator wants to access the server using the new device,
but does not want to affect the other users. So essentially the administrator needs to
route a single IP Address to the new device.
To achieve this, a route is added to the local administrator’s workstation. Since the 255.255.255.255
subnet mask was used, only traffic for that server will be effected. You can see that
using this subnet mask creates an exact match ensuring only traffic that is destined for
that server will be routed through the new device. Any other traffic for any other network
will not match this new rule and will be sent to the router. You can see the administrator
has achieved the objective of not effecting any other users on the network and also making
sure all traffic from their workstation to the server is routed through the new device.
The next subnet mask I will look at is 255.255.255.254. This turns out to be an interesting subnet
mask and leads us into the next topic of network and broadcast addresses.
If I use the following two IP Addresses as an example. The next step would be to apply
the subnet mask. If I consider the left IP Address, when the subnet mask is applied the
following will occur. All the 1 bits, which in this case there are 31 of them, will become
the network ID. All the zeros bits on the right of the 1’s, which is only the 1 bit
in this case, will become the host identifier.
The right IP address, when the subnet mask is applied, will give the same network ID
but this time give a host identifier of 1. If a host identifier is all zeros or all one
bits, it is treated differently than the other host identifiers. Let’s see how.
Any host ID that is all zero bits is considered to be the network address. The advantage of
having such an address is that when this address is used, it is clear that only the network
is being referred to and not a host on the network. In contrast, any host id that is
all 1 bits is considered to be the broadcast address. A broadcast address, when it is used,
will transmit the same network transmission to all hosts on that network. So how does
this affect the number of hosts that can be on a network?
Shown here are 9 different subnet masks and the number of subnets and hosts per subnet
mask. Notice the number of useable hosts per subnet is always 2 less than the possible
addresses. This is because 2 of the addresses are always used for the network and broadcast
address.
The question worth asking however is, in the case of when 31 bits are used for the subnet
mask, when the network and broadcast addresses are allocated this leaves no hosts. So is
there a need to ever use this subnet mask? Let’s have a look.
When the internet was first developed there was not too much thought on being efficient
with IP address allocation. So, originally, you could not use this subnet mask. Nowadays,
with IPv4 address exhaustion, there is a drive to utilize what remains of IPv4 addresses
as efficiently as possible. For this reason, back in 2000 a method of utilizing this subnet
was developed.
A good example of when to use the subnet mask is when there is a one-to-one link between
devices. For example, you have a router in New York and another router in London that
is connected directly by the one connection.
This is a good example of when only two IP Addresses are required. One for each router.
So if you had a subnet mask that supported 2 IP Addresses this would be great and an
efficient use of IP Addresses. Nowadays the IPv4 standard allows this subnet mask to be
used in this scenario where previously it did not. So in this example, an IP Address
could be allocated to each router.
When this subnet mask is used, since it only supports 2 IP addresses, the network address
and broadcast address are lost. The network address is generally used mostly on network
maps and you will generally see them posted on the walls of IT departments. So its loss
is not that significant. The administrator only needs to know, when reading network maps,
to recognize it as a valid IP Address.
The loss of the broadcast address is a little more significant as it essentially means broadcasts
can no longer be sent. In this example, routers don’t generally send broadcasts to each
other. There are cases with routing protocols need to exchange information with each other,
but this is done using unicast, basically direct communication, or multicast where traffic
is destined for many addresses, but not broadcast. So in this case, the subnet mask will work.
The only problem is since this was added to the IPv4 protocol, old devices may not support
it. New commercial routers nowadays should have no problem supporting it. With older
routers you may need to perform an upgrade of the software in order to support it.
I have looked at one end of the subnet masks, next I will have a look at the middle range
of subnet masks.
In the real world, you will generally be given an address and subnet mask. You will need
to subdivide this address to meet your needs. In this case, the address is a private IP
address and 16 bits have already been used leaving us another 16 bits to work with.
To subdivide the remaining addresses I will use the following tables. The process involves
choosing how many bits you want to use for networks and how many bits you want to use
for addresses on those networks.
If for example, I was to choose 17, this would allow 2 networks with 32,768 addresses per
network. That’s a lot of addresses per network. If I was to instead choose a CIDR of 24, this
would give 256 networks with 254 addresses per network. This is a popular subnet mask
as it gives a decent amount of addresses per network and since it is on an 8 bit boundary
it is easy to work with. That is, since the subnet mask for CIDR 24 is 255.255.255.0 the
binary math is easy to work out. Let’s have a closer look at how you would use this subnet
mask.
This is a simple example so no binary math is required, but to show the whole process
I will first change the network that I was given to work with to binary.
The first 16 bits have already been subnetted. This is common practice. For example, perhaps
your company has already allocated IP Addresses for regions around the world. They then give
you a small part for allocation in an individual region. ISP’s will also do the same thing.
The ISP will be given a range of IP Addresses and assign a smaller part of this allocation
to a customer using subnetting. The customer is free to allocate and subnet what they are
given as they see fit.
The next 8 bits are free to be allocated by the administrator as required. In this case
8 bits have been chosen. The last 8 bits can be used by addresses.
So what does all this mean? Now that all the subnetting has been done, this allows us to
work out what networks can be utilized on the network. The first network will start
with 10.6 since this was the part of the address that was already subnetted. The next part
is the 8 bits that we can subnet, starting from all bits being 0 gives us 0. Lastly,
the addresses that are available on this network are 0 to 255. Remember that 0 and
255 cannot be used for hosts, leaving us with 254 useable addressees.
The next network will be the same as the first except the 3rd octet will be a 1. Notice also
the next network will be a 2. This will continue till the last network is 255.
In the old days of the internet, it was discouraged to use a subnet with all 0’s or all 1’s.
In this example the 0 and 255 subnet contains all 0’s or 1’s. Nowadays it is allowed
to use this subnet. You may have problems however if you use very old network equipment.
Well that covers it for the basics for subnetting. In the next video, I will expand on subnetting
by looking at some more complicated examples and how to use subnet calculators to make
your job easier. Until that video, I would like to thank you for watching.