IP Subnetting
IP Subnetting
IP Subnetting
1
2
Table of Contents
Technical Editors
Also from Reality Press
Subnetting–What Is It and Why Learn It?
Your Subnetting Journey
Introduction to 2018 Edition
About Me
How the Books Are Laid Out
What You Will Learn in Part 1
What You Will Learn in Part 2
Subnetting Video Course
How to Read These Books
Part 1
IP Addressing
How Binary Works
How Hexadecimal Works
Have a Try
IP Version 4
Powers of Two
IP Addressing
Summary
Subnetting
Address Depletion
How to Subnet
How to Write Out Subnet Masks
Changing the Subnet Representation
Variable-Length Subnet Masking (VLSM)
Classless Inter-Domain Routing (CIDR)
Supernetting
How Many Subnets and How Many Hosts?
Subnet Zero
Shortcut Method
Exam Questions
Subnetting Cheat Chart
Answer These Questions
Part 2
The Easy Way to Subnet
Class C Subnetting
Class B Subnetting
Subnetting in Your Head
Class A Subnetting
Superfast Subnetting
How Many Subnets / How Many Hosts?
Wildcard Masks
IP Version 6
Hex Numbering
IPv6 Addressing
IPv6 Address Representation
Variable Length Subneting Masking (VLSM)
VLSM Practice
Chopping Down
Summary
Congratulations!
Subnetting Resources
COPYRIGHT & LEGAL NOTICE
ALL RIGHTS RESERVED: No part of this book may be reproduced or transmitted in any form
whatsoever, electronic or mechanical, including by photocopying, recording, or using any
informational storage or retrieval system, without express, written, and signed permission from the
author (with the exception of brief quotations as used in reviews or discussion groups, with attribution
to the author and source).
ISBN - 9781731241740
Technical Editors
Thanks to the below technical editors who donated their time to improve this
book.
John DeGennaro
Mario Salinas
Charles Burkholder
Steve Quan
Elmarine Jimenez
Thierry Merle
Frank Faith
Charles Pacheco
Jeff Echano
John S. Galliano
Timothy A. Clark
Carol Wood
Michael A. Sisson
Roy Thelin
Ellsworth Wilson
Georgia E. Jaeger
Tim Peel
Also from Reality Press
Good question. Let me ask you one back. Are you in the IT industry already,
or are you hoping to get into the IT industry and in particular into some sort
of helpdesk, PC support, networking, or other technical role?
Subnetting is used all over the world on almost every network (including
your home network). It’s the process of taking a standard network address
and making smaller (sub)networks from it. It’s just like cutting a cake into
slices, but we are doing it with address ranges instead of food.
Unfortunately, there are special rules you need to follow in order to avoid
getting into trouble and assigning the incorrect address to the wrong device or
part of your network. These rules have been frustrating IT students and
engineers for decades.
If you want to be in the IT industry, you must understand how to subnet. You
will be challenged on subnetting questions in:
I spent many weeks trying to learn the process of subnetting when I started
studying for the CCNA exam. I took the exam and failed miserably, my (lack
of) understanding of IP subnetting letting me down.
A few years later I began teaching IT courses and invented my own way of
subnetting. This easy way to subnet will get you through any IT exam,
technical interview, or real-world subnetting problem. If you spend just a few
hours reading this book and following my examples, you will be able to
subnet very quickly and accurately. I guarantee it in fact.
Your Subnetting Journey
Just the same as learning how to drive or ride a bike, you need learn how to
subnet only once. After that I recommend spending around one hour per
month brushing up on my easy subnetting method so you stay sharp.
What you’ll learn in the next few hours will help you for years to come. I
know that very well as understanding how to subnet has been a huge help to
me from working on a helpdesk, doing network support, and eventually
consulting for large companies. When I started teaching networking and
Cisco courses, I shared this method with others, who found it equally useful.
In this book you will learn how network addressing works and how to easily
and quickly determine which subnet a particular host belongs to. You will
learn how to quickly and easily resolve IP addressing issues while other
engineers around you are busy surfing the net looking for subnet calculators.
For my job interview for Cisco Systems I was asked by two senior network
engineers to answer subnetting questions on a whiteboard. The questions
lasted for about 45 minutes. I used the easy method you will learn here to
answer all the questions.
You will discover how to avoid common mistakes that have cost many
network engineers their jobs (I’ve seen it happen), and mistakes many exam
candidates make when answering subnetting questions.
You are going to learn what most network engineers skip, overlook, or
simply don’t know. By the end of this journey you will know more than 95%
of network engineers currently employed in the IT industry! I should know—
I have worked on hundreds of networks and met over a thousand IT engineers
throughout my time as a Cisco TAC specialist and through my Cisco and
networking training courses.
You’ll be very surprised at just how easy all this stuff really is. It really isn’t
complicated at all to be honest (once you see the easy way to subnet). The
problem for many years has been that very technical people have tried to
make something that is easy appear very difficult. Why they do that I will
never know. Perhaps they want other people to think that subnetting is some
mysterious skill that only a few engineers can master, or perhaps they
understand something only when it is explained in a complicated way.
Does all this sound too good to be true? Let me take what is seemingly a
huge and complicated subject and show you how easy it all really is.
Introduction to 2018 Edition
It’s hard to believe that I first wrote this book in 2006. So much has changed
since then, including my having three children and emigrating from the UK
to Australia.
So much has also changed in the world of IT. Cloud computing has exploded
onto the scene, and IPv6 is now ubiquitous. As an IT engineer you are
expected to know so much more now. Whereas back in the day you could
afford to be an expert in just one area, now the typical IT person should know
about wireless, IPv6, security, cloud, mobile technology, IoT, and much
more.
This new edition reflects changes from feedback I’ve had from the many
thousands of students who have used my easy subnetting method to pass their
exams, ace technical job interviews, and solve problems at work as an IT
engineer.
About Me
I eventually got a job at the Cisco TAC, where I worked for 2 years doing
router architecture support and then WAN support. We were all made
redundant in 2002, so I started my own IT consultancy and training company.
I now own www.howtonetwork.com, which teaches IT certification courses
via video, and www.101labs.net, which is a hands-on IT training site that is
all practical and zero theory.
After weeks of frustration I penciled out a few subnetting ideas myself and
quite by accident discovered a very simple, accurate, and easy way to work
out subnetting problems. I also developed the Subnetting Cheat Chart, which
you will see explained in great detail in Part 2. This is the exact method I’ve
used for years to teach the students in my classroom courses and IT books.
How the Books Are Laid Out
You start with the basics, such as binary math, hexadecimal, and how to
convert between that and decimal. You learn where subnetting actually
comes from and why. You will learn the longhand way of working out
subnetting problems before progressing (in Part 2) to learn the quick and easy
way which I recommend you use in exams, IT interviews, and
troubleshooting live network issues, where time is of the essence.
By the end of Part 2 you will have a firm grasp of all subnetting principles
and be able to apply everything you know in exams and real-world situations.
https://www.howtonetwork.com/courses/tcp-ip/ip-subnetting-zero-to-
guru/
How to Read These Books
Did you know that the way we are taught to learn in school is probably the
worst method possible! Have you ever just sat there staring at a book trying
to force the information in or reading a few pages and completely forgetting
what you have just read? Our recall is less than 40% an hour later and less
than 20% 24 hours later.
May I be so humble to suggest that trying to force new information into your
brain by staring at the page and hoping it sinks in won’t work? Try the
following way instead and see how much your understanding and retention
improves.
Step 1—Flick through every page in Part 1 and Part 2, just glancing over it
and not actually reading the text. Just pick up the main headers and subjects
covered. Take no more than about 5 seconds per page.
Step 2—Flick through the pages again, but this time spending about 10
seconds per page and glancing at the first few sentences under each main
heading.
Step 3—Do the same again, but this time take about 30 seconds. Casually
take in the main themes of each page and a few sentences as well. Enjoy the
process and tell yourself that you don’t really care how much information
goes in or how quickly.
Step 4—Take a break and do something else. Subnetting is a skill you will
have for life, so there is no hurry.
Step 5—This time have a more thorough read through each page. Take about
1 minute per page and avoid subvocalizing (reading the words out in your
head as if you were speaking out loud). Reading out the words in your head is
actually going to slow you down quite a bit.
Make a mental note of the content and subject matter, but let it soak in at the
speed that feels natural for you. The mind has 100% perfect retention and
picks up every sentence, word, and letter. The bit we sometimes struggle with
is the recall!
Step 6—Take about 2 minutes per page, and if it helps, put a small tick next
to the areas of major interest to you. Enjoy the process.
Take a break and the next day do Step 6 again. Keep following Step 6 and as
you pass over the pages time and time again, you will find that the material
goes in effortlessly. You will also find that you have the ability to recall and
apply the information with amazing accuracy.
Set a goal to spend about 20 minutes per day (no more than 30) learning the
material. You wouldn’t expect to learn juggling in an hour, so why expect to
understand all of this in the same time? Let the knowledge sink in at the right
pace for you to be sure it stays in. I know that this is the easy way to subnet,
but it isn’t a quick fix. You must still invest some time to learn how to apply
the skills.
If you want to learn more about speed reading, I recommend Evelyn Woods’s
speed reading books or home study course if you can find it on the web or on
eBay. It will be time well invested.
Part 1
IP Addressing
In order to do this, we start at number 1 and then for every binary value we
add we double the decimal value—i.e., 1 to 2 to 4 to 8 to 16 and so on into
infinity if we wish, but we start on the right and move left. It’s easiest to do
this by writing two rows with the decimal at the top and binary underneath.
You can see below that with two binary digits we can count up to 3 in
decimal. We just place a 0 or a 1 in the column to decide if we want to use
that value or not.
We will start with only two binary values in the columns, 1 and 2 to the left.
The top row is the decimal, with the binary values underneath, which can be
turned on or off by adding a 1 or 0.
If we use 8 binary bit places (an octet), we can get any number from 0 up to
255. You can see that we start our numbering from the right and move across
to the left.
If we add a 0 to each of these columns, we have a value of 0 in decimal.
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
So logic dictates we can actually make any number from 0 to 255 by placing
an on or off bit (a 0 or a 1) in the various columns.
32 + 8 + 4 = 44
The octet is ubiquitous in IT, and as you’ve seen, it’s made from 8 bits. Four
octets are used for an IPv4 address, which, as you will see, turned out to be
insufficient for modern requirements. Half an octet is 4 bits and is referred to
as a nibble, although it’s pretty rare to hear this term nowadays.
In this table I start on the left and add 1 in each line. This is where the subnet
numbers come from in your octets.
Make up some of your own binary numbers to ensure you understand this
fully. Feel free to search for some binary teaching apps, such as Binary Grid
Puzzle – Math Game.
In exams such as CompTIA Network+, A+, and CCNA you can expect to be
asked to convert binary to decimal or decimal to hex.
0123456789ABCDEF
When converting binary to hex, it makes the task easier to break the octet into
two groups of 4 bits. So 11110011 becomes 1111 0011. 1111 is 8 + 4 + 2 + 1
= 15 and 0011 is 2 + 1 = 3. 15 is F in hex and 3 is 3 in hex, giving us the
answer F3. You can check Table 1.2 (above) to confirm this.
Hex to binary is the same process. 7C can be split into 7, which is 0111 in
binary, and C, which is (12 in decimal or) 1100 in binary. The answer is
01111100.
Hex is used exclusively in IPv6 addressing because the size of the address is
128 bits, which would be next to impossible to write out in binary. Here is an
example from Wikipedia:
We will refer to hexadecimal once again when we cover IPv6 addressing.
Have a Try
Here are some examples for you to try. If you get stuck, you can find the
answers overleaf. A very useful thing to do would be to write out the charts
for working out hex and binary—i.e., for hex a 1 column, then a 16 column,
then a 256 column, and so on.
It would be useful in any IT exam to write out Table 1.2 to help you work out
any binary to hex to decimal conversions.
Conversion Answers
Convert 1111 from binary to hex and decimal:
Hex = F; Decimal = 15
IPv4 uses four octets in a group to create an IP address and each octet is
made up of 8 bits or 1 byte. Therefore every IP address is 32 binary bits (4 ×
8 = 32) or 4 bytes.
IPv4 was designed so that there would be enough IP addresses for the
foreseeable future. No one predicted the huge growth in IT that was to come,
so this scheme in its initial incarnation had to be amended to cater for the
demand.
11000011.11110000.11001011.11111100
1st octet 2nd octet 3rd octet 4th octet
Each grouping of eight numbers is an octet, and the four octets give us a 32-
bit IP address.
IN THE REAL WORLD: It is worth remembering that routers
and PCs do not see an IPv4 address as four octets; they just see
32 bits. Octets just make things easier for us to see.
Powers of Two
In order to really understand IP addressing you should understand the powers
of two. While it may appear confusing initially, you simply start with the
number 2 and keep doubling the previous number. That’s all there is to it.
1×2=2
2×2=4
4×2=8
8 × 2 = 16
21 = 2 × 1, which is 2
22 = 2 × 2, which is 4
23 = 2 × 2 × 2, which is 8
24 = 2 × 2 × 2 × 2, which is 16
25 = 2 × 2 × 2 × 2 × 2, which is 32
and so on.
This process will become important when you are asked to work out how
many subnets and hosts per subnet are generated with a particular subnet
mask.
IP Addressing
So now we understand that an IP address is made up from binary numbers
which are grouped into octets. The reason for this is that when IP addressing
was first conceived, it was determined that this number would be more than
enough for many years to come. Unfortunately, the huge growth of home and
mobile devices and business computing was never anticipated. IPv6 has 340
trillion trillion trillion available addresses, so that should last well into the
future.
IP (version 4) addresses are broken down into classes. Classes were used
when IP addresses were first developed. How large your organization was,
dictated which class of IP address you were given. Large organizations were
allocated Class A, medium ones Class B, and small ones Class C.
Class A Addresses
Historically, these were given to the largest organizations, which would need
a tremendous number of IP addresses since they owned more computers than
everyone else. Class A addresses use only the first octet to identify the
network number. The remaining three octets are left for identifying the hosts
on the network.
Network.Host.Host.Host
10.2.5.4
nnnnnnnn.hhhhhhhh.hhhhhhhh.hhhhhhhh
00001010.00000010.00000101.00000100
IN THE REAL WORLD: You would pronounce the above IP
address as ‘ten dot two dot five dot four’.
The last possible network number is 127 (check by adding all the values
together). Network number 127 cannot actually be used because the value
127.0.0.1 is reserved for troubleshooting. You can ping the loopback address
to check if TCP/IP is working on your host.
For the hosts we can start at number 1 until every single possible value is
used up. We will use an address starting with 10 to illustrate the example.
00001010.00000000.00000000.00000001
10. 0. 0. 1
00001010.11111111.11111111.11111110
Now you can see why we use decimal. It would take a long time to write out
addresses in binary, and be almost impossible to remember them. You can
change Cisco router settings to display all addresses in binary, but there is no
reason ever to do this.
Why can’t we have 10.255.255.255 as a host? Because when all the binary
values have a 1 in the host part of the address, this tells the network that it is a
broadcast packet. We will learn how this works later.
Class B Addresses
Class B addresses were reserved for large organizations that needed a lot of
host numbers but not as many as the largest ones. Unfortunately, when a
Class B address was assigned to an organization, it resulted in thousands of
wasted host addresses.
Class B addresses have to have the first two binary values in the first octet
reserved with a 1 and a 0 next to it.
So the first network number is 128. We have all the available network bits in
the first octet turned off.
The last available Class B network number is 191 (add the values together).
Here we have turned the all network bits on (in the first octet).
For Class B addresses we use the first two octets for the network address. For
example, in the address 130.24.5.2, 130.24 is the network number and 5.2 is a
host on that network. The rule still is that the first number you see will
always be between 128 and 191 inclusive.
If we use the powers of two rule, in the first two octets we will see that we
can have a possible 65,536 (216) networks. We are, however, not allowed to
use the first 2 bits of the first octet because they are reserved for showing the
10 (binary) value, remember? So this leaves us with 6 + 8 digits. 214 gives us
16,384 networks.
We have the full two octets to use for hosts, so 8 + 8 bits gives us 216 =
65,536 hosts per Class B network. We actually have to take 2 away from this
value for the broadcast and subnet (more on this later), so technically it is
65,534 host addresses.
This will start to make more sense as we work through some subnetting and
network design examples. We’re just laying the foundation at the moment.
Class C Addresses
These were originally reserved for any organization that was not large
enough to warrant having a Class A or B address. A Class C address has the
first 3 bits reserved, so the network device can recognize it as such. The first
3 bits must show as 110.
The first network number is 192. All the other network bits are off (0).
The last is 223. This time all the network bits are on (in the first octet).
An example of a Class C address is 200.2.1.4: 200.2.1 is the network address
and .4 is a host on that network. So we can see that there are lots of available
network numbers to assign to companies; however, we have a limited
quantity of numbers that are free to use for the hosts on our networks.
For Class C networks we have to take the first 3 bits (110) from the first
octet, giving us 5 + 8 + 8 = 21 (network bits).
221 = 2,097,152
For the hosts we have 28, giving us 256 per network (only 254 are usable
though).
Multicast addresses are used by routing protocols such as EIGRP and OSPF,
and IPv6 uses several for routing and device identification and auto-
addressing features.
Private Addresses
In order to help prevent wastage of IP addresses certain addresses were
reserved for use on private networks. Any individual can use these addresses
on their network provided they do not try to get out to the internet. The
address allocation scheme was suggested in RFC* 1918, ‘Address Allocation
for Private Internets’.
Summary
We can condense what we know so far to:
Class A – first bit set to 0, address range 1–126 (127 is reserved for testing)
Network.Host.Host.Host
We only need to look at the number in the first octet to recognize which class
address we are dealing with.
10.1.2.1 = Class A
190.2.3.4 = Class B
220.3.4.2 = Class C
You will observe in the above figure that bit counts start at zero, which can
often confuse new IT students.
10.0.0.0 – 10.255.255.255
172.16.0.0 – 172.31.255.255
192.168.0.0 – 192.168.255.255
Subnetting can be one of the most difficult subjects to master for many IT
people. There is a long way to subnet and a very short and easy way. It is
vital you understand how the long way works first, but then in real life you
will use the short one (the easy way).
Address Depletion
Shortly after the IPv4 addressing scheme was implemented, it became
apparent that there were not enough addresses to meet the demand. More and
more organizations were using computers and networking equipment, and the
current scheme was wasting thousands of addresses.
Example
A company is given a Class A address. Class A addresses can only be
allocated to 126 companies. The first octet is used for the network, and the
other three octets are free for use on the network.
So we have three octets that are free for hosts on the network, giving us 3
times 8 bits, which equals 24.
Don’t worry about the math yet. I just want to illustrate the huge wastage
involved in how IP addresses were first allocated and before steps were taken
to try to extend the life of the IPv4 addressing method.
For a Class B address the story was very similar. For Class B networks, the
first two octets are reserved for the network address, which leaves two for
host addressing. This gives us over 65,000 host addresses available per Class
B IP address.
216 is 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 = 65,536
hosts.
How to Subnet
The problem with the initial way of using IP addresses was that we were
fixed with having certain parts of the address for the network and certain
parts for the hosts.
Class A addresses were fixed with 8 bits for the network and 24 for the hosts.
Class B addresses were fixed with 16 bits for the network and 16 for the
hosts. Class C addresses were fixed with 24 bits for the network and 8 for the
hosts. There had to be some way for host addresses to be conserved. The
answer came with the introduction of subnetting.
Subnetting allowed bits that were normally used for the host part to be used
for the subnet part of the address. ‘Subnetting’ is short for ‘subnetworking’
and ‘subnet’ is short for ‘subnetwork’. In order to let the routers or PCs know
that subnetting was being used, another number had to be applied to the IP
address. This number is known as the subnet mask and is also a binary value.
Each bit on the subnet mask is compared with the bits on the IP address to
determine which parts belong to the network and which belong to the host. A
default subnet mask is allocated to each class of address. If you do not want
to use subnetting, simply add the default subnet mask to the end of the IP
address. It is not possible to enter an IP address onto a PC or router without
also entering the subnet mask. Many actually fill the default value in for you
once you enter the IP address.
We can see that the first octet for Class A addresses is reserved for the
network number. This is the default anyway, like the first two octets for Class
B and the first three for Class C.
A rule for subnet masks is that the 1 and 0 network and host bits must be
contiguous—i.e., connect without a break. So you can have:
11111111.11111111.0000000.000000
11111111.000111111.00000000.00000000
We can also see how important it is to remember that the router or PC sees
numbers in binary.
What we now have is a situation where each part of the IP address is matched
with the subnet mask to determine which bits are part of the network
identification and which bits are part of the host identification.
Example
10001100.10110011.11110000.11001000 140.179.240.200 Class B
11111111.11111111.00000000.00000000 255.255.0.0 Subnet mask
---------------------------------------------------
10001100.10110011.00000000.00000000 140.179.0.0 Network address
How did we get this number? The router performs a process known as logical
ANDing. It compares the 1s and 0s to establish which numbers belong to the
network and which belong to the host.
So all the values are compared and everything apart from a 1 and a 1 equals
0. Check the above example again to make sure you understand how it works.
Because you now know which are the network addresses and which are the
hosts, you can start assigning IP addresses to hosts on your network. If all the
host bits are 0, then you cannot use this to put on a network host. The part
with all 0s represents the subnet; we shall see why and how shortly.
If you want to start using host addresses on your network, you can simply
start with number 1 and count up.
You can keep adding hosts until both the third and fourth octets are (almost)
full.
140.179.0.255 is still a valid host number.
140.179.1.255 is still okay.
140.179.255.254 is the last host number you can use.
Why can’t we use the last bit for a host? An IP address with all 1s in the host
portion is reserved to tell the network that the packet is a broadcast packet. A
broadcast packet is a packet that must be examined by all hosts on the
network (or, more specifically, all of the hosts on this portion of the network
—i.e., the subnet). The number below is a broadcast packet to every host on
the 140.179 network.
Broadcasts are normal on networks; however, too many can indicate you
need to upgrade the network, or can signify a fault on a device, such as a
failing network card on a server or PC.
So now we can see that we are not permitted to use all 0s for the hosts since
this is the network and we cannot use all 1s because this is reserved for a
broadcast. For every network or subnet, two of the available addresses can’t
be used for host or interface addresses. Armed with this information, we will
be able to decide how many available hosts we have per network or subnet.
We will use the powers of two formula to work out how many hosts we get
on our subnet. For now, we will simply raise 2 to the power of how many
host bits we have and take away 2, one for the network of all 0s and one for
the broadcast address of all 1s. Later, we will use the Subnetting Cheat Chart
to get the answer in a few seconds.
For our example of 140.179.0.0 255.255.0.0 we can see that we have the last
two octets free (0.0) to allocate to hosts on the network. That is two lots of 8
binary bits, giving us 16 host bits in total. Using longhand, you take the
number 2 and double it 16 times: 2, 4, 8, 16, 32, etc.
The formula is 2n - 2:
216 - 2 = 65,534
Do you think it would be practical to have one network with over 65,000
hosts? We cannot break this network down into smaller units, and if we have
a broadcast on the network, each and every single host on the network will
have to stop what it is doing to listen to the broadcast packet to see if it is the
intended recipient.
Let’s start subnetting and steal some bits from the host part of the address and
make a subnetwork from those bits. I will write out the network address in
longhand to make it easier to understand:
140.179.00000 000.00000000
[16 bits] [5 bits] [11 bits ]
[network][subnet][host bits ]
We have stolen 5 of the host bits to use them to make our subnet. The
advantage is that we now have more than one subnet we can use and we have
fewer wasted hosts per subnet. We can use the powers of two formula to
work out how many subnets we have and how many hosts there are per
subnet. We do not have to take 2 away for the subnets.
Why would we want to do this? You have fewer hosts using the bandwidth
on your network segment. It is far easier to administer smaller subnets than to
administer one huge network. Additionally, it is desirable to limit the number
of broadcasts on a given subnet because each and every host on a subnet must
examine the contents of a broadcast packet, whether it is the intended
recipient or not.
Remember: the more host bits you steal, the more subnets you get, but each
of those subnets is capable of supporting a lower number of hosts. Deciding
how many hosts you need and how many hosts there are per subnet is part of
the network design phase. The more host bits we steal, the more subnets and
the fewer host bits become available; this is the trade-off.
Table 1.3 below shows the possible values for a Class B network. Remember
that for Class B addresses we are looking at the third and fourth octets for the
bit pattern. The first two octets are used for the network address and cannot
be stolen. The CIDR column stands for Classless Inter-Domain Routing. This
allows you to represent the subnet mask in bits instead of longhand, so /16
means there are 16 binary bits in the subnet mask, or 255.255.0.0. We will
cover CIDR in more detail later.
How to Write Out Subnet Masks
We do not write out the subnet mask bits in binary; we have a way of writing
subnet masks when entering them on network equipment and when writing
them out by hand.
If we steal 5 host bits from the third octet, we have to add the binary values
together. Our Subnetting Cheat Chart will make this easier, but it’s important
we know where these numbers come from!
Remember that we are using a Class B example here and so are working with
the third octet. We are not allowed to alter the first two octets; they are fixed
for the network.
255.255.248.0
This tells the router that we are subnetting and that we are using the first 5
host bits to carve out our subnets.
Things can get a little bit (more) complicated and we can no longer rely on
what our eyes are telling us because the router is looking at a binary value
and we are looking at a decimal value. Don’t worry too much though because
we will look at the quick and easy way to work out subnetting later.
In order for the router to know if a host is on a certain subnet, it looks to the
masked bits. If all of the masked bits match, then it follows that the host must
be on the same subnet. If the subnet bits do not match, then the hosts are on
different subnets.
Again we have a Class B address and are stealing 5 bits for subnetting. We
know we have stolen 5 bits because 248 in binary is 11111000, which is 5
masked bits. Please work that out on paper now; we will use a cheat chart
later for speed and accuracy.
10000001.00001010.10010011.00010000 129.10.147.32
10000001.00001010.10010100.01010101 129.10.148.85
We can see that the subnet bits in the example above both match, so the host
addresses belong to the same subnet and you could safely use them for hosts.
Now look at the below example:
10000001.00001010.10011010.00000010 129.10.154.2
This time one of the subnet bits has changed: the last value for the subnet is
now 1 instead of 0. The router or PC can see it is a different subnet.
Unfortunately, when we write it out in decimal, it is not very easy for us to
see that this third IP address is in a different subnet. This is why learning
subnetting can be problematic. It can look right but actually be wrong
inasmuch as the hosts belong to different subnets.
Please read the above paragraph again. We have just encountered the reason
why millions of IT students and engineers can’t work out how to subnet!
RouterA#terminal ip netmask-format ?
RouterA#
bit-count Display netmask as number of significant bits
decimal Display netmask in dotted decimal
hexadecimal Display netmask in hexadecimal
As we have seen, there are only certain values available to use as a subnet
mask due to binary mathematics. This is illustrated in Table 1.4 below.
If you calculate a subnet mask and it is some other value, such as 160, it is
clearly wrong!
Using VLSM, we no longer need to worry about the class system for
addressing networks. You can use a Class C subnet mask with a Class A
network address, for example. So if you see 10.10.10.0 255.255.255.0, don’t
be surprised. We will use these examples later on in this book.
Instead of writing out the subnet in decimal, engineers in the real world use
something called a slash address or CIDR. They write out how many bits are
used for subnetting. If you are reading out such an address to a colleague, you
will literally say ‘slash’, so for example, ‘192 dot 16 dot 8 dot 1 slash 24’.
I only mention this to prepare you for when you hear a colleague, customer,
or other support engineer saying this. CIDR is used with ALL IPv6 addresses
in fact because the concept of a subnet mask doesn’t apply to these address
types, so it’s best you get used to it now.
Examples:
255.255.0.0 can be expressed as /16 because there are 16 binary bits used in
the subnet mask:
11111111.11111111.00000000.00000000 = 16 on or masked bits
I’m sure you get the idea. We are no longer thinking about what class an IP
address is anymore but what the CIDR value is. You still need to know how
to write this out in full as a subnet mask because you could be asked to do
this in an IT exam or job interview.
Also, many equipment vendors for routers, firewalls, and servers force you to
write out the subnet mask in longhand but your design sheet may have the
values in CIDR.
Supernetting
CIDR allows for a feature known as route aggregation, whereby a single
route in a routing table can represent several network addresses, saving
bandwidth, router CPU cycles, and routing table size.
Route summarization works only if you work out the addresses in binary
first. Take the below four networks as a simple example:
All of the bold parts of the address are common and can be aggregated with
one subnet mask to advertise them all. There are 22 common bits, so we can
use the mask 255.255.252.0 or /22 to advertise the entire block of addresses.
You would usually use the lowest network number with the supernet value.
Now imagine you have 250 networks to advertise out to the internet or to a
HQ router. You could supernet networks 172.16.0.0 to 172.16.250.0
inclusive as 172.16.0.0/16, saving a huge amount of resources on your
network. This is why learning how to subnet is so useful to you in your IT
career.
CIDR allows the use of the slash system for representing subnet masks—e.g.,
/26 instead of 255.255.255.192. Table 1.5 below is a Class C subnetting chart
with CIDR representation.
Given a network ID and subnet mask, how many subnets can we form, and
how many hosts are there per subnet?
It all boils down to the powers of two (I told you knowing this would come in
handy later).
255.255.224.0
11111111.11111111.11100000.00000000
[16 bits ] [3 bits] [13 bits]
[Network] [Subnet] [Host]
So in the Class B example above we have 3 subnet bits to use and we can use
every combination of three binary numbers to make up different subnets. I
mention the fact it’s Class B only so you know that the first two octets are
reserved for the network already.
000,001,010,101,011,110,100,111
23 (2 × 2 × 2) = 8
The total number of subnets will always be 2 to the power of subnet bits.
So for this subnet mask we can see we have eight subnets and each subnet
has 8190 hosts available for use.
I know this seems somewhat long-winded, but I want to ensure you know
how and why this is all happening before you move into the fast way. You
need to know in case you are asked by your customer to explain or in a
technical IT job interview when they wonder how you got the answer so
quickly!
Example
What are the host addresses and broadcast address for the below subnet?
We have a Class B address and are taking 3 bits from the host bits (3 binary
bits is 11100000, which is 128 + 64 + 32, or 224). There isn’t room to fit in
every permutation, so we have had to shorten the output and skip a lot of host
addresses (indicated by ‘keep going’ below).
Because the IP address changed from 32.1 to 33.255 and all the way up to
63.254, it is easy to look at it and mistake them for different subnets. When
we write out the addresses correctly, we can see that all of the hosts above are
on the same subnet.
In the above example, the first subnet would be 131.107.0.0, which we refer
to as the zero subnet. We will look at this in more detail shortly. For now I
just want you to follow along with my examples.
All the hosts on the same subnet (for example, the 131.107.32.0 subnet) will
have to be attached to one router interface or be in the same VLAN. You
cannot decide to put half of your addresses on one side of the router and half
on the other. Many engineers have made this mistake and wasted hours trying
to troubleshoot the problem.
Shortcut Method
Writing out IP addresses and subnets in binary is very time consuming. There
is an easier way to do it. Just follow five simple steps. Once we go through
this shortcut method a few times, we will move on to an even easier
subnetting method using the Subnetting Cheat Chart.
If we skipped to the cheat method first, you could already answer subnetting
questions, but you wouldn’t actually understand what is happening behind the
scenes, which would make you a substandard network engineer and we can’t
have that, can we?
Example
Which subnet is 131.107.32.1 255.255.224.0 in?
255.255.224.0 is 11111111.11111111.11100000.00000000 in binary.
We could actually write this out with a slash mask of /19 (19 masked network
bits or 1s). You can see that we are subnetting in the third octet here (and of
course 131 is Class B, so the first two octets are fixed for network bits).
We now know that we have eight valid subnets and each subnet will be an
increment of 32. We can start at 0 for the first subnet, so 0, 32, 64, 96,
128,160,192, and 224. 224 is also permitted.
This part is crucial. If you get it wrong, then all of your subnetting will be off,
so double-check it. Some people make the mistake of doubling the numbers
—i.e., 32, 64, 128, etc.
So now we know we can use any number, including the 224 subnet. It is
fairly clear from the list above that the host address we are looking for is on
the second subnet (where I put ), so we can look at the available host
numbers on this. The host numbers are everything after the subnet value and
before the broadcast address.
Subnet - 131.107.32.0
1st Host - 131.107.32.1
2nd Host - 131.107.32.2
3rd host - 131.107.32.3…We could keep going but there are over 8000 hosts.
Last host - 131.107.63.254 (take 1 away from the broadcast to get this value)
Broadcast - 131.107.63.255 (take 1 away from the next subnet to get this
value!)
For the third or .64 subnet we follow the same process of writing out the
subnet and broadcast address. We can work out the broadcast address by
writing out the next subnet address and taking 1 away. The subnet starting
131.107.64 is the third of our eight subnets. We then take 1 away from that to
determine the broadcast address for the previous subnet.
Subnet - 131.107.64.0 (take 1 away to get the broadcast for the .32 subnet)
1st host - 131.107.64.1
Last host - 131.107.95.254
Broadcast - 131.107.95.255
We could go on, but can you see that we have gone past the IP address we are
trying to find, which is 131.107.32.1?
It is pretty easy to work out if you write out the subnets first.
Without being able to see the whole thing in binary it does look a little
strange. You just have to have confidence that the method works, and if in
doubt, go back to binary. We can prove that the broadcast address is such by
checking to see if it is all 1s in binary. The last host will be the last number
we can use without having all 1s (255 in decimal).
The underlined bits are the subnet bits. The .254 subnet has all the bits apart
from 1 turned on. The broadcast address has all the host bits turned on. This
tells the network that it is a broadcast packet to the subnet.
You already know by now I’m sure, but each octet starts at 0 and rolls up to
the maximum value of 255. As it rolls up, the left one can count up by 1. If I
write this out in decimal:
2.0
And of course it goes backwards, so this is how you work out the broadcast
address from the next subnet. I’ll write out a broadcast address, but I got it
from rolling back the next subnet address by 1. We’ll presume the subnets are
going up in increments of 32.
Example
Which subnet is host 10.20.1.23 255.240.0.0 in?
We have taken 4 bits from the second octet (240 in binary is 11110000 or bits
turned on in the 128 + 64 + 32 + 16 columns) to make subnets. Class A
addresses normally have the default 8 bits (255.0.0.0 is
11111111.0000000.0000000.00000000 in binary), which is how you
determine that 4 bits have been used.
Note also that I’m continuing past the step where we found the answer, which
was back in Step 3. I’m teaching you how to subnet before we drill down to
just answering exam questions.
Exam Questions
In IT exams you will often have one of two types of subnetting questions.
The first type you have just seen. You are given a certain network number
and subnet mask and you need to determine which subnet the IP address is in.
The second type of question is to design a subnet mask to give a customer a
certain number of hosts and a certain number of subnets.
The Subnetting Cheat Chart will answer both types very quickly, but we will
cover the longer methods first so you can see how the binary math works
behind the scenes.
We will now shorten the previous five steps. It does help though to go
through them to answer any type of subnetting question.
Example
Which subnet is host 192.168.21.41/28 in?
The first task is to work out how to change the /28 mask into a full subnet
mask. You already know that each octet is 8 binary bits, and 8 + 8 + 8 = 24
binary bits, which is 255.255.255.0. We need to add 4 to 24 to get 28, which
is 128 + 64 + 32 + 16 binary places or 11110000 or 240.
Example
Which subnet is host 10.65.2.5/10 in?
Turn /10 into a subnet mask. 255 is 8 binary bits, so we need to add 2 to get
to 10 and 2 binary bits is 128 + 64, which is 192 or 11000000.
Let’s use the Subnetting Cheat Chart to answer the next question.
It’s worth noting that in IT exams you are usually given an A4-sized
whiteboard and marker pen. You can use these to write out the below chart
and then refer to it to answer any subnetting problem. Just rub out the ticks
and use it over and over. I’ve used it for my CompTIA Network+, CCNA,
CCNP, and MCSE exams.
I devised the Subnetting Cheat Chart while I was preparing to teach my first
CCNA classroom course in 2002. I just stumbled across it, to be totally
honest. I started to see patterns in the subnetting questions I was writing and
realized that you could write a simple chart to represent everything.
This chart formed the basis of a best-selling Amazon subnetting book and a
video training course which have been used by many thousands of students
over the last 16 years.
Let’s break the chart down into two and three components. The upper half is
used to answer any ‘which subnet is host X in?’ question or similar ones. It
could be ‘what is the broadcast address for subnet X?’ or ‘which of the
following hosts belong to subnet X?’ It’s all the same thing as far as the top
portion is concerned.
The bottom half is to answer design-style questions. These are ‘how many
hosts / subnets per host’ type questions, where you have to work out how
many of each value a certain subnet mask or CIDR value gives you.
The very top row I’m sure you’ve already noticed is purely an octet—i.e.,
eight binary places. We use this for the octet we are subnetting in. If we have
to subnet in two octets, we just use this for the last octet. We just add a ‘+8’
in the top leftmost box. You will see how this works later.
If you use 4 bits for subnetting, you will tick four places in the Bits row. This
gives you your subnet increment, which in this example would be 16. You
start with the zero subnet and then count up in 16s. You would usually stop
when you get to the subnet AFTER the one you find the host in.
Next is the top left column. This represents the subnet value. If you were told
that the subnet mask applied to a Class C network was /27, and wanted to
know what it was in longhand, you would tick down three places. /24 is the
default, and to get to /27 you need three.
You would do this as a sanity check to avoid making mistakes in the exam or
if you are rushed at work with a troubleshooting issue but want to ensure you
are accurate.
Finally, the bottom half contains two columns. These represent the powers of
two. How many host bits you steal you tick down the Subnets column. How
many host bits are left you tick down the Hosts - 2 column.
If you had the mask /28 applied to a Class C network, you know 4 bits are
stolen for use in subnetting, leaving 4 bits for hosts. Ticking down four in
each column would give you 16 subnets, and each subnet would have 14
hosts.
For this part of the Subnetting Cheat Chart, you start with the number 2 and
just keep doubling it. I tend to stop at 16,384 to save time. If you need to tick
down more than 14 places, then just keep doubling the value. It would be
pretty unfair in any exam for them to get you ticking down 20 or more places.
As with any tool, the more you use it, the easier the task becomes, so let’s do
some examples. From now on we will just refer to the Subnetting Cheat
Chart to answer all questions. If you had to explain your working out in an
interview or to a customer, you could revert to the slow method.
Example
Which subnet is 192.168.100.203/27 in?
This is a Class C network address. We know that three binary octets (24 bits)
are the default mask for this network and to get to 27 we need to add 3. Tick
down three numbers in the top subnetting column in the chart. This will give
you the value of 224. So our subnet /27 is 255.255.255.224. We can then tick
three (the same value) across the top to get the subnet increment, which is 32
(or just take 224 away from 256 if you prefer).
These ticks represent how many bits we have stolen to create subnetworks. In
this example it’s three. We don’t need to use the bottom section of the chart
because we aren’t trying to figure out how many subnets and hosts per subnet
there are.
We are subnetting in the fourth octet, so we just count up in increments of 32
until we get to the one with the host number 203.
Let’s count up in increments of 32. Remember that we are looking for host
number 203. You would typically count up to the next subnet after the one
you think the host number is in just to make sure. Again, this is especially
important if you are counting up in small increments, where it’s easy to make
mistakes.
Another reason to do this is you may be asked to work out the broadcast
address for your subnet. The way to do this is to find the next subnet value
and then subtract 1. For subnet 1 below, for example, the broadcast address is
31, which is the next subnet value minus 1.
In an IT exam you will be shown four or five choices, and one of these will
be correct of course.
We will work through a lot more subnetting examples, but I wanted to briefly
show you how the bottom half of the Subnetting Cheat Chart works. Before
we do that, let’s take another look at the entire chart.
What the Subnetting Cheat Chart helps you to do is to easily and quickly
work out how many bits are being used for subnetting, which subnet the host
is on, how many hosts there are per subnet, and how many subnets there are.
Example
How many subnets and hosts does the network and mask 192.168.2.0/26 give
us?
We are taking an extra 2 bits from the normal 24-bit mask. Tick off two
numbers down in the left-hand Subnets column (128 and then 192), which
gives us a mask of 192 or to be more specific 255.255.255.192. You don’t
actually have to do this step because they aren’t asking you to write the
subnet mask out in full in this question, but I wanted to show you how the
chart works in full.
You can work out that it is 2 bits being used if you remember that each octet
count is 8. 255.0.0.0 is 8 binary bits, 255.255.0.0 is 16, and 255.255.255.0 is
24. If we have a /26 mask, then we need to add 2 onto the 255.255.255.0
mask, which is 24 bits plus 2 more or 255.255.255.192.
We have taken 2 bits for the subnets, so in the Powers of Two column on the
bottom left tick down two places (2 and then 4). This gives us four subnets.
This would usually be your first step for any design-type question (such as
this one).
Now we know we have 6 bits left for the hosts (8 - 2 = 6 bits remaining), so
tick down six places in the Powers of Two column to get our number of hosts
per subnet. Six down gives us 64, and taking 2 away for the subnet and
broadcast gives us 62 hosts per subnet. Easy, isn’t it?
Our answer then is that 192.168.2.0/26 gives us four subnets and each subnet
has 62 host addresses available. We don’t need to list the available subnets
because we weren’t asked to for this question.
Go back to the chart and tick down the powers of two until you get to a
number that gives you the eight subnets. Two and four won’t be enough, but
eight is perfect. So now we know we need to steal 3 bits for subnetting. Tick
down three places in the top Subnets column (starting at 128, then 192) and
we get 224.
Stealing 3 bits leaves us 5 bits for hosts per subnet. If you tick down five
places in the hosts per subnet column, you will see that this gives us 30 (32 -
2) hosts per subnet, which is enough for our requirements.
The answer is you need subnet 255.255.255.224 (or a /27 mask) to get your
eight subnets. If you tick down three in the lower Subnets column, you can
tick down three in the upper Subnets column to determine the correct subnet
mask.
Part 1 is the foundation we will build on in Part 2. You know now how
subnets are built, how binary math works, what the address classes are, and
how to subnet and work out how many subnets and hosts there are.
In Part 2 we will streamline the entire process so you can answer exam and
technical interview questions in a rapid-fire format.
Answers
1. 11100000
2. 10
3. 192-223
4. 10.x.x.x, 172.16.x.x-172.31.x.x, 192.168.x.x
5. /30
6. 192.168.2.128
7. 255.255.255.252
8. 199 and 11000111
9. IPv6 uses eight 16-bit hexadecimal number fields representing a
128-bit address.
10. Multicasting
Part 2
By the end of this guide you will be well on your way to being able to answer
most subnetting questions in your head in seconds. Make sure you have read
through Part 1 before you launch into this part of the book. I am presuming
you have read through that at least once and understood some of the
fundamentals, such as the powers of two and binary mathematics.
I know I keep telling you this, but just relax and enjoy the learning process.
Some of you will pick this up on the first read, but for the rest of us we have
to keep rereading until we get some light-bulb moments. Just remember that I
had to invent this entire process after failing my CCNA exam!
Class C Subnetting
Here are the possible Class C subnets:
Logic tells us that the more host bits we steal, the more subnets we have but
the fewer hosts we have available per subnet. As you see the number of
subnets increase, you will see the hosts-per-subnet value decrease.
We know from Part 1 that if we subnet the longhand way, we need to follow
five simple steps in order to answer any subnetting question. The five steps
are as follows:
The first subnet of a Class C address we can use involves taking 1 bit from
the available 8 host bits. If you aren’t sure of what is happening with the
binary numbers, then go back to Part 1. For the quick method we won’t have
time to write things down in binary.
Important Note:
In all the following examples I show you how to determine which subnet a
host is in as well as how many subnets and hosts per subnet are generated.
It’s important to remember that in any exam or interview, just answer the
question you are given. Don’t spend extra time working out how many hosts
and subnets there are if you are asked only which subnet a host is in. It’s
wasted time.
My other book 101 Labs – IP Subnetting does this all the way through—just
getting to the answer without any messing around.
Example
Host 192.168.1.200 255.255.255.128 (or /25)
I know we are not supposed to have 1 bit for subnetting, but there are
exceptions. It is slightly awkward to start with an exception, but we need to
address it and there is no time like the present. You would use this subnet if
you wanted two subnets each containing 126 hosts on a Class C subnet.
The Subnetting Cheat Chart works for this example. We can use the zero
subnet, which is the first bit off, and the second subnet, which is the first bit
on. I’ll present the answer in table format for now to make it easy on your
eyes.
We have taken 1 bit to use for the subnets, so tick down one place in the top
Subnets column, which gives us the value 128 and in turn the subnet mask
255.255.255.128 (which would be useful if you had only been given the /25
mask i.e. in CIDR).
You then tick one place across the Bits row to reveal the increment our
subnets go up in, which in this instance is 128. We can use the zero subnet, so
our two subnet values end in 0 and 128.
If you were asking how many subnets and hosts per subnet there are, you
would then tick one place down in the lower Subnets column to show that we
have two subnets. We have 7 bits left for the hosts, so tick down seven places
in the Hosts - 2 column to reveal that we have 126 (128 - 2) hosts per subnet.
If the above example doesn’t make sense at the moment, then leave it for now
and come back to it later. It will still be here and will make more sense after
you go through the examples below.
Example
255.255.255.192 or /26
I’ve left off the host number for now because I want to ensure we know how
to use the chart first. In this example we will cover a few possible questions.
In reality it will more likely be just one aspect of the following which will
form an exam question.
Next, we can tick down two boxes in the Subnets column, giving us four
subnets
22 = 4
x.x.x.0
x.x.x.64
x.x.x.128
x.x.x.192
That was fairly simple, wasn’t it? If you follow the Subnetting Cheat Chart,
you can’t go wrong.
If you are asked in the exam which subnet host 192.16.150.76/26 is in, you
will see that it is within subnet 192.16.150.64 because 192.16.150.0 is too
low and 192.16.150.128 is too high. The subnets will be:
Example
Which subnet is host 200.100.206.99/27 in?
I’ll also cover how to work out how many subnets and hosts per subnet there
are, but this question didn’t ask us to answer that. I just want to give you as
much exposure as possible to this way of working out subnetting problems.
Tick down three boxes in the lower Subnets column, which gives us eight
subnets.
2. How many hosts per subnet?
We have 5 remaining bits for the hosts. Tick down five places in the Powers
of 2 column to get 32, and take away 2.
25 - 2 = 30
256 - 224 = 32
The above boxes represent the last octet, so if you wanted to write the subnets
out in full, you would have:
200.100.206.0
200.100.206.32
200.100.206.64 (we still haven’t reached the .99 host)
200.100.206.96 host 99 here
200.100.206.128 (we have the answer, so stop here)
Can you see how simple the process is? You must be careful to tick the right
boxes in the Subnetting Cheat Chart to start with, or your subnetting results
will be entirely wrong.
Example
What is the broadcast address for the subnet host 190.200.200.167/28 is in?
This question never actually matters when you use the Subnetting Cheat
Chart because we simply follow the same process and the correct answer will
be revealed.
We can see that we have to convert the /28 address into a subnet mask. The
subnet mask for /24 is 255.255.255.0, and we need to add 4 to 24 to get 28.
We have stolen 4 bits for subnetting, so you need to tick down four boxes in
the upper Subnets column to get to 240. Our subnet mask is 255.255.255.240.
You should know the drill now. Tick down four boxes in the Powers of 2
Subnets column.
2. How many hosts per subnet?
We have 4 bits left for the hosts.
24 - 2 = 14
Following the same process, we can see that the broadcast address for host
190.200.200.167 is 192.200.200.175 and the subnet address is
190.200.200.160.
Example
Which subnet is host 200.100.55.86/29 in?
By now you should be familiar with ticking down in the Subnetting Cheat
Chart. Make sure you continue to use it for the examples. We need to work
out how many to add to /24 to get to /29; the answer is 5 of course, so tick
down five in the Subnets column to get your mask of 255.255.255.248.
200.100.55.0
200.100.55.8 multiply 8 by 10 (jump strategy)
200.100.55.80, hosts 81-86 host 86 here
200.100.55.88
Example
Which subnet is host 210.25.200.165/30 in?
We use a 30-bit subnet mask for subnets that need only two hosts. A point-to-
point connection is ideal for this.
You should now write out your own Subnetting Cheat Chart to get into the
habit you will need for the exam. There is a blank Subnetting Cheat Chart at
the end of Part 2 for you to use; you do need to write it out by hand in IT
exams or interviews though.
We need to get to /30 from the default /24 mask, so tick down six in the top
Subnets column, which gives you a mask of 255.255.255.252.
Subnet 210.25.200.0
Subnet 210.25.200.4
Subnet 210.25.200.8
Subnet 210.25.200.16 jump here (16 × 10 = 160)
Subnet 210.25.200.160, hosts 161-162 (broadcast 163)
Subnet 210.25.200.164, hosts 165-166 (broadcast 167) host 165 here
Subnet 210.25.200.168
Class B Subnetting
The principles for subnetting Class B addresses are exactly the same as those
for Class C. You just need to remember that the default subnet mask for Class
B addresses is 255.255.0.0, so the subnetting will take place from the third
octet onward.
Here are all the possible Class B subnets:
Example
255.255.128.0 or /17
We need to get the hard one out of the way first. The usual rules do not apply,
so read through and then come back to this later.
We can use the 0 subnet in the third octet as long as we have some hosts bits
turned on in the fourth octet. Unfortunately, you have to think in binary to
understand this example.
The /17 part indicates that we have added 1 bit to the default /16 mask to use
it for subnetting. Tick one down the upper Subnets column, which gives us
the mask 255.255.128.0. We don’t write the chart out twice to generate 16
host bits. I put ‘+8’ on the top right to remind you that this is the third octet.
1. How many subnets?
Our increment is 128. This means we can have 0 and 128, so we get two
subnets (21 = 2). You can see this by the one tick we have added to the lower
Subnets column (for the 1 bit we have stolen).
215 - 2 = 32,766
We can’t really follow the rest of the subnetting questions for the 128 mask
because the /17 mask is the exception. We do know though that we can have
0 in the third octet as long as we have no bits turned on in the fourth octet.
Above you can see I refer to just the last two octets when quoting the host
numbers—for example, hosts 0.1 and 127.254. This notation makes sense to
me; other people prefer to write out the entire four octets when quoting the
addresses. Use what works for you.
Example
What subnet is host 150.200.155.23/18 in?
The trick is to remember that we are still subnetting in the third octet. The
default mask for Class B is 255.255.0.0, which is 16 binary bits. We need to
add 2 to 16 to get to our /18 mask, so tick down two in the top Subnets
column. Our subnet mask then is 255.255.192.0.
This will leave 6 host bits in the third octet and another 8 in the fourth octet
(6 + 8 = 14 host bits). I don’t need that ‘+8’ on the right of the chart because I
know where I am, so you can remove it anytime if you feel confident.
In this example we have stolen 2 bits from the third octet, which leaves 6 bits
in the third octet plus 8 in the fourth octet, giving us 14 bits. Tick down 14
host bits in the hosts column.
214 - 2 = 16,382
The above numbers are the third and fourth octets. You could write out the
entire subnet (as below), but this does take a lot longer.
Can you write out your own Subnetting Cheat Chart for this one yourself?
What do we have to add to /16 to get a mask of /19, and how many bits do we
tick down and across the top?
Can you look at the table above and see which subnet host 67.200 is in?
What if you were asked what the broadcast address for this subnet is?
Example
Which subnet is host 190.50.100.200/20 in?
0, 16, 32, 48, 64, and so on up to 240. We can’t fit them all in below.
Example
Which subnet is host 180.22.56.65/21 in?
Follow the procedure for the previous examples to determine the correct
mask for the /21 subnet.
180.22.0.0
180.22.8.0
180.22.16.0, etc.
We can’t fit all of the available subnets in, and in the exam, you will just
want to find the answer as quickly as possible. Anything before or after the
relevant subnet is of no concern to you (apart from working out the correct
subnet).
Are you starting to understand how it all works now? You may have
understood this in the first go, or it may take what seems like an age for it to
sink in. How long it takes has nothing to do with how clever you are.
Previous IT experience will help, but a lot of it will be down to when you last
studied and whether the left or right side of your brain is the dominant one.
Don’t force it in. Just follow the process over and over and you will get it,
guaranteed.
One more thing: Don’t be surprised if it clicks into place all of a sudden and
then goes away again. This is very common and a sign that the information is
passing from short- to long-term memory. It will come back again.
Example
Which subnet is host 180.100.60.85/23 in?
Use the Subnetting Cheat Chart to determine the subnet mask and subnet
increment, etc.
You could jump from 6.0 to 60.0, which would hit the 60.85 host
straightaway as the next subnet would be 62.0. Host 180.100.60.85 is in
subnet 180.100.60.0.
Example
Which subnet is host 130.100.200.121/24 in?
No, your eyes are not deceiving you. Don’t look at this subnet and think
Class C; it is in this instance 8 bits of subnetting being used for a Class B
address. Do not ponder too long over it; just follow the usual procedure.
0, 1, 2, 3, 4, 5, and so on up to 255
Example
Which subnet is host 191.20.56.65 255.255.255.128 in?
This one is a bit easier because the (/25) subnet is written out in longhand for
you already. Nine bits have been taken for use in subnetting. This is another
tricky example which does not fit neatly into the usual formula we use. We
can take 128 from 256 for the subnet increment but also count up in
increments of 1 in the third octet!
We are also allowed to have a 0 in the third octet if we have a bit turned on in
the fourth octet. For each value such as subnet 10 you get 10.0 and then
10.128. If you remember that, you will be fine. In the Subnetting Cheat Chart
you might want to put a ‘+8’ in the top LEFT box to remind you that we have
spilled over into octet 4 from octet 3.
0, 1, 2, 3, 4, 5, etc., 255
Because we are subnetting in the fourth octet, we can actually use the 0
subnet in the third octet. This is possible because if we have a bit turned on in
the fourth octet, we do not have all the host bits off. We can also use 255 in
the last octet.
If this doesn’t make much sense at the moment, there is no need for concern.
It is very doubtful you will come across this in exams or interviews, but then
again it is a useful subnet for use in the real world, so you never know! You
can write this out in binary later when you have time.
Example
Which subnet is host 180.100.1.220/27 in?
We have skipped the /26 subnet. The principles are exactly the same.
Remember to use the Subnetting Cheat Chart to save time and to make sure
that your answer is correct. You are hitting the fourth octet in this example,
so you would just tick down three places (because you can’t fit in the 8 bits in
the third octet in the chart).
Just bear in mind here that we have a Class B address with the default mask
of /16, which means we are using 11 bits for subnetting, leaving 5 bits for
hosts per subnet.
1. How many subnets?
211 = 2048
0.0, 0.32, 0.64, 0.96, etc., 255.32, 255.64, etc., 255.192, 255.224
We can manipulate the third octet due to the fact that we can have bits on and
off in the fourth octet. There are too many subnets to write out, but we can
write out some.
The above example works because as long as we can have bits turned on in
the fourth octet, we can have all the bits off in the third octet.
We can continue subnetting until we get to number 255 in the third octet. We
can go all the way up to subnet 255.224.
1.1.1.1.1.1.1.1|1.1.1.1.1.1.1.1|1.1.1.1.1.1.1.1|1.1.0.1.1.1.1.1
Subnet ---------------------------------------------------| Host bits
All the subnet bits we can turn on are on. We can’t have 1.1.1 for the first 3
subnet bits since this is the number 224, which is our subnet. When we turn
on the last 5 bits (the host bits), this is a broadcast in the 255.192 subnet.
If you want a superfast exam cheat method, then just ignore the fact we are
using a Class B address. Just focus on the last octet instead and count up in
increments of 32, fixing the first three octets as follows:
180.100.1.0
180.100.1.32
180.100.1.64, etc.
Example
Which subnet is host 150.60.200.107/28 in?
Use the Subnetting Cheat Chart again. The mask will be 255.255.255.240.
The chart will have to be used to represent the last octet. Taking the 12
masked bits we have stolen, we have to presume we have ticked across the
first 8 bits for the third octet and have spilled over to the fourth octet and tick
the remaining 4 bits.
1. How many subnets?
212 = 4096
0, 16, 32, 48, 64, 80, 96, etc., 208, 224, 240
4. What are the valid hosts per subnet / broadcasts?
The same rules apply as in the previous example. We can have all the bits off
in the third octet as long as we have subnet bits on in the fourth octet.
Example
What subnet is 192.168.10.90 255.255.255.192 in?
You should come to 64. If you start with the first subnet as 0, then you have
64, the next is 128, and the last is 192. You can see the host number is 90,
which is less than 128 and more than 64, so we know it is in the .64 subnet
somewhere.
Example
What subnet is 172.16.20.112 255.255.255.224 in?
Take 224 away from 256, which gives you 32. We can keep adding 32 until
we come to the subnet containing 112 as an address: not 32, not 64, could be
in 96, 96 plus 32 is 128—bingo! It is in the 172.16.20.96 subnet.
As I mentioned earlier, in the exam, just focus on the octet you are subnetting
in. Starting off with 172.16.0.0 is fine when you are in an office designing
subnets, but in the exam, start at the octet the last part of the subnet mask is
in.
In any exam or interview question, any of the subnets taken away from 256
will result in increments of 2, 4, 8, 16, 32, 64, or 128. As you do more
examples, you will remember what taken away from 256 equals what. You
will instantly know that 256 - 224 = 32 or that 256 - 240 = 16. Once you have
the result of that simple mental calculation, you have everything you need.
Simple, isn’t it?
Subnetting is like riding a bicycle: the more you practice, the more natural it
becomes. You will get to a point where you can look at an IP address and
subnet mask and instantly know which subnet it belongs to.
Class A Subnetting
The principles are exactly the same for Class A subnetting as they are for
Classes B and C. We just have more host bits available. We are going to keep
this section fairly short since by now you have everything you need to answer
any subnetting question.
Example
Which subnet is 10.100.100.93/10 in?
Remember that the default subnet mask for a Class A address is 255.0.0.0 (or
/8), so we have 24 bits available for hosts or for subnetting. We will need to
add 2 host bits to the Subnetting Cheat Chart to get to the /10 value and to
calculate the subnet and hosts per subnet.
1. How many subnets?
22 = 4
0, 64, 128, 192, or if you want to write out all the octets:
Note: Exams such as CCNA and CompTIA Network+ are usually pretty fair,
so I would be surprised if Cisco gave you a subnetting question that would
clearly take considerable time to work out (such as working out powers of
two to 22 places as above). It is always better to train using the hard
questions though, and then the exam questions will appear easy to you.
Example
Which subnet is host 10.210.204.70/12 in?
How many bits are we using for subnetting here? Are we subnetting in the
first, second, or third octet?
10.0.0.0
10.16.0.0
10.32.0.0 jump here (6 × 32 = 192)
10.192.0.0
10.208.0.0 host 10.210.204.70 in here
10.224.0.0
10.240.0.0
Example
Remember that we will have to use the chart for spillover bits from the third
octet. You would have ticked 8 bits for the subnets in the second octet,
leaving 4 bits to tick in the chart for the third octet.
I have written the subnets out in full this time, but I could have just as easily
written 0.0, 16.0, 32.0, etc.
10.0.0.0
10.0.16.0
10.0.32.0
10.0.48.0, etc.
10.1.0.0
10.1.16.0, etc.
10.1.240.0
10.2.0.0
10.2.16.0, etc., up to
10.255.240.0
There are far too many to write out here, so we will have to skip most of the
subnets.
Remember that the exam cheat method lets you fix parts of the network and
work only on the part the last subnet value is in. This would let us do this
instead:
10.200.0.0
10.200.16.0
10.200.32.0 jump here (3 × 32 = 96)
10.200.96.0 host 10.200.100.107 in here
10.200.112.0
It can get fairly hard when working out Class A subnets with what are
traditionally thought of as Class B or C subnet masks. I would recommend
working on these examples over and over until they start to make sense.
Example
Which subnet is host 20.100.55.3/26 in?
20.0.0.0
20.0.0.64
20.0.0.128, etc.
20.0.14.192
20.0.15.0, etc.
We could continue counting up, but getting to the subnet containing host
20.100.55.3 would take some time. It is to be found in subnet 20.100.55.0.
A superfast cheat method is to fix the first three octets and count up in octet
four in increments of 64, so:
You would still need to use the Subnetting Cheat Chart to get the increment,
etc., but doing it this way would reduce your subnetting time for this question
to under 60 seconds.
Superfast Subnetting
I’m sure that by now, your ability to answer common subnetting questions
has improved dramatically.
I’ve really been drilling you hard, but as I mentioned earlier, in the exam and
in technical job interviews, time is of the essence. For this reason you need to
be able to answer the specific question asked and then move on.
It’s not likely you will be asked to provide the subnet, hosts, broadcast, and
number of subnets and hosts all in the same question. It’s far more likely you
will be asked for just one of these pieces of information.
Example
Which subnet is host 192.168.1.244/28 in?
This time just tick for how many stolen bits there are and then count up until
you get the correct subnet. The default is /24, so we have stolen 4 bits. Our
increment then is 16.
Start at the zero subnet and count up in increments of 16 until you get to the
correct subnet. Jump up in the increment if you are going to be in a high
subnet number.
192.168.1.0
192.168.1.16 Jump up to 160 (16 × 10).
192.168.1.160
192.168.1.176
192.168.1.192
192.168.1.208
192.168.1.224
192.168.1.240 Host 192.168.1.244 is in here.
Example
Which subnet is host 172.16.27.100/27 in?
I know you can see a Class B address here, but we have stolen so many bits
that we are now into the fourth octet. You COULD start counting up your
subnets from 172.16.0.0, BUT this would take a long time and you would
reach the same answer as when using my shortcut method.
In exams, just look at the last octet the subnetting goes into and stay there.
This applies whether it’s Class A or Class B. The smart move here is to treat
172.16.27 as fixed and use the increment to find the subnet the number 100 is
in.
I’ve placed a ‘+8’ in the top left corner of the chart to remind you that we
have already stolen 8 bits (from the third octet). /27 from the default /16 is
11, and with 8 bits already taken we add another 3. Our subnet increment
then is 32.
172.16.27.0
172.16.27.32
172.16.27.64
172.16.27.96 Host 172.16.27.100 is in here.
172.16.27.128
If they tag on more information to the question, such as what the broadcast is,
then use the five-step method we’ve used so many times. Alternatively, take
1 away from the next subnet to get your broadcast address. The hosts are
located between the subnet and the broadcast address.
Example
Your client has been given address 192.168.1.0/24 and requires four subnets,
and each subnet must be able to provide at least 10 hosts.
Use the Subnetting Cheat Chart and tick down the lower Subnets column
next to the powers of two until you reach a value that will give you a
minimum of four subnets.
Ticking down two boxes gives you the required four subnets. You can now
tick down two boxes in the upper Subnets column to generate the correct
subnet of 255.255.255.192 (or /26). You have stolen 2 bits from the last octet
to generate the subnet mask, leaving 6 for hosts. Tick down six boxes in the
hosts column to find out how many hosts per subnet you have.
You have 62 (64 - 2) hosts per subnet, which more than meets the
requirement of the client.
Example
You have address 200.100.20.0/24, and the client wants to break this down
into at least nine subnets each having at least 10 hosts.
Here you need to generate AT LEAST nine subnets but not waste subnets.
Tick down the Powers of 2 Subnets column until you reach the closest
possible number to nine without wasting subnets.
The closest we can get is 16 because 8 is not sufficient. Tick down four
places in the upper Subnets column to generate a subnet mask of
255.255.255.240. You have taken 4 bits from the last subnet, leaving 4 for
hosts.
16 - 2 gives us 14 hosts per subnet, which is sufficient.
Example
Same deal, but remember that we are taking bits from the third octet.
We have to tick down five boxes in the Powers of 2 Subnets column to get
the value of 32, which is as close as we can get to 30 subnets. This leaves 3
bits in the third octet and 8 bits in the fourth octet for hosts (11 bits).
Tick down 11 places in the hosts column, which gives us 2046 hosts per
subnet.
Easy-peasy.
Wildcard Masks
Wildcard masks do belong under the umbrella of IP subnetting. Wildcard
masks are of particular relevance to network engineers who configure access
lists on routers or firewalls or implement OSPF routing on networks. If
neither of these applies to you, then please feel free to skip this section.
The wildcard mask can be confusing to anybody new to access lists. Just
remember that the router reads in binary instead of decimal. The wildcard
mask is there to tell the access list which parts of the address to look at. A 1
in binary means that part of the address can be ignored, and a 0 means it must
match.
Example
If I want to match all traffic from 172.16.2.x, then I will add the wildcard
mask 0.0.0.255, or in binary:
10101100.00010000.00000010.00000000 = 172.16.2.0
00000000.00000000.00000000.11111111 = 0.0.0.255
Match Match Match Ignore
In action this would mean any host from the network starting with 172.16.2.x
would match the access list. 172.16.3.x would not match the access list.
Example:
Here we have an access list permitting any traffic from the 10.x.x.x network:
There is an implicit ‘deny all’ at the end of Cisco access lists. When you
apply this to an interface, the only permitted network will be 10.x.x.x.
access-list 9 permit 10.0.0.0 0.255.255.255
(access-list 9 deny 0.0.0.0 255.255.255.255) This is present but you won’t see it.
It is the ‘deny any’ command.
Example
access-list 12 permit 172.16.2.0 0.0.0.255 172.16.2.x allowed
access-list 12 permit 192.168.1.0 0.0.0.255 192.168.1.x allowed
access-list 12 permit 10.4.0.0 0.0.255.255 10.4.x.x allowed
This access list permits three networks and denies traffic from any other
network.
Example
access-list 15 deny 172.16.0.0 0.0.255.255
access-list 15 deny 192.168.2.1 You can specify a host address.
access-list 15 permit any
If you want to deny a few networks, subnets, or hosts and permit the rest, use
the logic shown above. We are denying anything from the 172.16.x.x
network, but we can also specify a single host without using a wildcard mask.
Just enter the host number and the router will automatically add 0.0.0.0 to it.
Lastly, we have added ‘permit any’ to the end of the list. This is to prevent
the implicit ‘deny any’ from denying any other traffic. If you forget this line,
all traffic will be denied.
You can break wildcard masks down from the default subnet boundaries just
as you can use VLSM to change the default subnet mask for an IP address.
Example
If you wanted to deny the 192.168.100.96 255.255.255.224 subnet, you
would use the following wildcard mask:
0.0.0.31
So the access list matches the first 27 bits, and the last 5 can be any. The
simplest way to look at this is to swap each on bit with an off bit when you
are writing out the wildcard mask.
Example
10.1.64.0 255.255.192.0
If you wanted to permit or deny this subnet, you would need to create a
specific wildcard mask to match it. The wildcard mask needs to be the
reverse of the subnet mask to permit or deny this subnet.
So long as you get 255 when you add the two columns together, you know
the wildcard mask is correct. This is shown in the example above.
Example
What wildcard mask would deny the subnet 172.16.32.0 255.255.240.0?
Wildcard masks are commonly used with OSPF to advertise specific subnets.
The improvements made over IPv4 in IPv6 are increased addresses, reduced
routing table size, and improved security.
Hex Numbering
It may well be worthwhile to have a short memory jogger on hex numbering.
You can see that each numbering system starts with a zero, so:
Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Binary – 0, 1
Hex – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
When you write these addresses, you may not realize it but you are using
columns from right to left; the rightmost is the 1 column, and the next column
is the base number times the preceding column, so:
You can see that each successive column from the right increases in value.
For decimal numbering it is 10 multiplied by 1. For binary it is 1 and then 1
multiplied by the numbering system of 2 and of course for 16 the multiples
are 16. If you compare the three numbering systems up to the last hex digit,
you can begin to see why hex is the preferred format for IPv6 addressing.
In order to provide enough addresses for our needs many years into the
future, IPv6 has been designed to provide many trillions of addresses.
In order to do this, the numbering range has been expanded from 32 binary
bits to 128 bits. Every 4 bits can be represented as one hex digit (as can be
seen from the chart above). Logic then dictates that two hex digits give us 8
bits, which is a single byte, or octet.
An IPv6 address is 128 bits in length, and this is broken down into eight sets
of 16 bits each separated by a colon when written in full format. Every 4 hex
bits can range from 0000 to FFFF, with F being the highest digit available in
hex numbering:
IPv6 Addressing
As we already know, IPv6 uses 128-bit addresses. Because the address
format is different from the IPv4 address format that we are all accustomed
to, it is often confusing at first glance. However, once understood, the logic
and structure are very simple. The 128-bit IPv6 addresses use hexadecimal
values (i.e., numbers 0 through 9 and letters A through F).
While in IPv4 the subnet mask can be represented in either CIDR notation
(e.g., /16 or /32) or dotted-decimal notation (e.g., 255.255.0.0 or
255.255.255.255), IPv6 subnet masks are represented only in CIDR notation
due to the length of the IPv6 address.
Global 128-bit IPv6 addresses are divided into the following three sections:
The IPv6 global prefix is used to represent the IPv6 global address space. All
IPv6 global internet addresses fall within the 2000::/16 to 3FFF::/16 range.
The 16-bit provider-owned IPv6 prefix is assigned to and owned by the
provider. The assignment of these prefixes follows the same rules as prefix
assignment in IPv4. The provider-owned prefix falls within the 0000::/32 to
FFFF::/32 range.
The site prefix is the 16 bits following the 48-bit provider-assigned prefix.
The subnet mask length for a site prefix is /64, which includes the 48-bit
provider-assigned prefix. This prefix length allows for 264 addresses within
each site prefix. Figure 2.2 below illustrates the 16-bit site prefix:
Following the site prefix, 64 bits are used for interface or host addressing.
The interface or host ID portion of an IPv6 address represents the network
device or host on the IPv6 subnet. The different ways in which the interface
or host address is determined will be described in detail later in this module.
Referencing Figure 2.3, once customers have been assigned the /48 prefix by
the ISP, they are then free to assign and use whatever site prefixes and host or
interface addresses they want within that 48-bit provider-assigned prefix.
The sheer amount of address space available makes it impossible for any
single enterprise customer to require more than a single provider-assigned
prefix, while still allowing all devices within the enterprise network to be
allocated a unique IPv6 global address. NAT, therefore, will never be
required for IPv6.
While the preferred form or representation is the one most commonly used
for representing the 128-bit IPv6 address in text format, it is also important to
be familiar with the other two methods of IPv6 address representation. These
methods are described in the following sections.
When writing IPv6 addresses, hexadecimal characters are not case sensitive.
In other words, 2001:ABCD:0000 and 2001:abcd:0000 are the exact same
thing. The complete form for IPv6 address representation is illustrated in
Figure 2.4 below:
The following IPv6 addresses are examples of valid IPv6 addresses in the
preferred form:
0000:0000:0000:0000:0000:0000:0000:0001
2001:0000:0000:1234:0000:5678:af23:bcd5
3FFF:0000:0000:1010:1A2B:5000:0B00:DE0F
fec0:2004:ab10:00cd:1234:0000:0000:6789
0000:0000:0000:0000:0000:0000:0000:0000
Compressed Representation
Compressed representation allows for IPv6 addresses to be compressed in
one of two ways. The first method uses a double colon (::) to compress
consecutive zero values in a valid IPv6 address for successive 16-bit fields
comprised of zeros or for leading zeros in the IPv6 address. When using this
method, it is important to remember that the double colon can be used only
once in an IPv6 address.
When the compressed format is used, each node and router is responsible for
counting the number of bits on either side of the double colon to determine
the exact number of zeros it represents. Table 2.6 below shows IPv6
addresses in the preferred form and the compressed representation of those
addresses:
As previously stated, the double colon cannot be used more than once in a
single IPv6 address. If, for example, you wanted to represent the complete
IPv6 address for 2001:0000:0000:1234:0000:0000:af23:bcd5 in compressed
form, you could use the double colon only once even though there are two
consecutive strings of zeros within the address.
Table 2.7 below shows IPv6 addresses in the preferred form and how they
can be compressed using the second method of IPv6 compressed form
representation.
While there are two methods of representing the complete IPv6 address in
compressed form, it is important to remember that both methods are not
mutually exclusive. In other words, these methods can be used at the same
time to represent the same IPv6 address.
This is commonly used when the complete IPv6 address contains both
consecutive strings of zeros and leading zeros in other fields within the
address.
Table 2.8 below shows IPv6 addresses in the complete form that include both
consecutive strings of zeros and leading zeros, and how these addresses are
represented in the compressed form:
Because the same rules apply to both IPv4 and IPv6, as far as network
addressing is concerned, you can have only one network per network
segment. You can’t break the address and use some host bits on one part of
the network and some on another.
If you look at the addressing in the chart below, the situation should make
more sense:
You need never concern yourself about running out of host bits per subnet
because each subnet has over 18 quintillion hosts. It’s unlikely that any
organization would ever run out of subnets, but even if this were the case,
another global routing prefix could easily be provided by the ISP.
Let’s say, for example, that you are allocated the global routing prefix
0:123:abc/48. This address occupies three sections of a full IPv6 address, and
each section or quartet is 16 bits, so you have 48 bits used so far. The host
portion will require 64 bits, leaving you 16 bits for allocation as subnets.
You would simply start counting up in hex from zero (zero is legal) and keep
going. For your hosts you would do the same, unless you wanted to reserve
the first few addresses for servers on the segment, for example.
Let me use a simpler prefix for our example: 2001:123:abc/48. The first
subnet would be all zeros, and of course, the first host on each subnet would
be all zeros, which is legal (since you don’t reserve the all 0s and all 1s
addresses in IPv6). You would represent the all-zeros host by the abbreviated
format using double colons.
You have already noticed a difference from IPv4 addressing rules, I’m sure,
in that you can use the all-zeros subnet and the first subnet address is always
all zeros. Looking at a simple network topology, you could allocate the
subnets in the below fashion:
Can it really be that easy? If you recall from the IPv4 subnetting section, it
can become somewhat of a nightmare to figure that out as well as to work out
how many hosts and subnets there are and remember to exclude certain
addresses. IPv6 subnetting is far easier. You may not be allocated a 48-bit
prefix—it could be /56 for a home or smaller network—but the principle
would be the same.
You can also subnet off the bit boundary, but it would be most unusual and
unfair of Cisco to expect you to go into that amount of detail in the short
amount of time you have in the exam. Hopefully, the exam won’t be a mean
attempt to catch you out, but you never know. Just in case, here is an example
of a /56 prefix length address:
2001:123:abc:8bbc:1221:cc32:8bcc:4231/56
The prefix is 56 bits, which translates to 14 hex digits (14 × 4 = 56), so you
know that the prefix will take you to the middle of a quartet. This is where
you could make a mistake in the exam. You must zero-hex bits 3 and 4 in the
quartet before the prefix breaks:
2001:123:abc:8b00:0000:0000:0000:0000/56
I’ve underlined the quartet where the bit boundary is broken. In haste and due
to time pressure in the exam, you could well miss this important step.
Remember that you would also abbreviate this address (the first host on the
first subnet) to:
2001:123:abc:8b00::/56
If they do try to catch you out in the exam, it will probably be an attempt to
have you remove the trailing zeros from the quartet before the bit boundary is
broken:
2001:123:abc:8b::/56
You can steal bits from the host portion to use for subnets, but there should
never be a reason to and it would break the ability to use many of the features
IPv6 was invented to utilize, including stateless autoconfiguration.
Think of it as being given a large slice of cake. You can cut that slice of cake
into two (or more) pieces, or you could take one of the two slices and cut that
into smaller slices. It’s basically subnetting a subnet.
Today, a network administrator can have a Class B address with a
255.255.192.0 mask and further break down that subnet into smaller units
with more masks, such as 255.255.224.0. Instead of writing out the subnets in
decimal, engineers in the real world use something called a slash address,
writing out how many bits are used for subnetting. Some examples of this are
shown below:
255.255.0.0 can be expressed as /16 because there are 16 binary bits masked.
You may have spotted a few problems with the addressing scheme above.
The most important issue is the breach of the conservation of IP addresses.
If you are using RFC 1918 addresses (i.e., non-routable ones, such as
10.x.x.x), then perhaps you may not be worried about address wastage, but
this is very bad practice, and for Cisco exams, you will be expected to
conserve IP addresses.
With a /28 mask (or 255.255.255.240), you have 14 hosts per subnet. This
may be fine for your LAN on either end, but for your WAN connection you
need only two IP addresses, which wastes 12 addresses. You could change
the masks to /30 (or 255.255.255.252), but then for your LANs you will
obviously need more than two hosts.
The first workaround is to buy a separate network address for each network
(two LANs and one WAN), but this would prove expensive and unnecessary.
The other alternative is to break down the subnet further using VLSM, which
is actually what it was designed to do!
In Figure 2.7 above, you can see that the WAN link now has a /30 mask,
which produces two usable hosts. You also have a tighter addressing
allocation. If ACME Company expands (as companies often do), you can
easily allocate further WAN links and LANs.
In Figure 2.8 above, you can see that ACME Company has now grown and
added a remote office. Because you have taken the time to plan and allocate a
carefully thought out VLSM scheme, you can simply allocate the next block
of IP addresses.
But will the IP addresses clash? This is a very common question, and it’s a
valid one. Let’s say you have address 19.16.1.1/28 for one of your LANs.
You will not therefore be able to use the IP address 19.16.1.1 with any other
subnet mask. The IP address can be used only once, no matter which subnet
mask is attached to it.
The challenge is this: You have three serial connections, and each requires
only two usable host addresses. You also have four LANs that need between
20 and 100 hosts. If you design a mask to give you 20 to 100 hosts, you will
be wasting a lot of addresses. To get 100 hosts, tick down seven places in the
Hosts - 2 column, which will give you a mask of 255.255.255.128 (because
you have only one bit left to tick down in the Subnets column). This gives
you 126 hosts (128 - 2). You will then have two networks: one starting at
200.100.100.0 and one starting at 200.100.100.128. Not great, to be honest,
because you need seven subnets (three WANs and four LANs) and some
require only 20 hosts—so why waste 108 addresses?
Referencing the bottom half of the Subnetting Cheat Chart below, tick down
in the Hosts - 2 column until you find a number close enough to give you 100
hosts. The only number you can use is 128, which is seven ticks down, so
you are stealing 7 bits from the host portion, leaving you 1 bit for subnetting.
Using the upper part of the Subnetting Cheat Chart, tick down one place to
reveal the subnet mask of 128.
When you use the 128 subnet with ACME Company II’s IP address, you get
subnet 200.100.100.0 and subnet 200.100.100.128, both with a mask of /25,
or 255.255.255.128. For the network needing 100 hosts, you can use the
200.100.100.128 subnet. For the first host, you will use 200.100.100.129 and
so on up to 200.100.100.229. So now you have:
You need to allocate hosts to the three remaining LANs and the three WANs.
The other three LANs all need between 20 and 30 hosts. If you tick down
five places in the Hosts - 2 column, you will get 32 - 2, or 30 hosts. If you
steal 5 bits from the host portion, you are left with 3 bits for the subnet
(because there are 8 bits in every octet).
Tick down three places in the upper half of the Subnetting Cheat Chart to
reveal the subnet mask of 224. This mask will give you eight subnets (you
need only three for the LANs), and each subnet will have up to 30 available
host addresses. Can you see how this will fit ACME Company II’s
requirements?
If you tick across three places in the upper half of the Subnetting Cheat Chart,
you will see that the subnets go up in increments of 32, so the subnets will be
0, 32, 64, and 96; you cannot use 128 because it was used for the large LAN.
Next, you need IP addresses for the three WAN connections. WAN IP
addressing is fairly easy because you need only two IP addresses if it is a
point-to-point link. In the Hosts - 2 column, tick down two places to get 4 - 2,
or two hosts. This leaves 6 bits for the subnet.
Tick down six places in the upper half of the Subnetting Cheat Chart to get
252 as the subnet mask.
Network Addresses
As a network administrator, you will need to keep a record of the IP
addresses and subnets that have been used. So far, you have allocated the
following addresses:
WAN links
200.100.100.0/30 – WAN link 1 (hosts 1-2)
200.100.100.4/30 – WAN link 2 (hosts 5-6)
200.100.100.8/30 – WAN link 3 (hosts 9-10)
LAN hosts
200.100.100.32/27 – LAN 1 (hosts 33-62)
200.100.100.64/27 – LAN 2 (hosts 65-94)
200.100.100.96/27 – LAN 3 (hosts 97-126)
Chopping Down
VLSM principles will let you take a network and slice it down into smaller
chunks. Those chunks can then be sliced into smaller chunks and so on. You
will reach the limit only when you get to the mask 255.255.255.252, or /30,
because this gives you two usable hosts, which is the minimum you will need
for any network.
Consider network 200.100.100.0/24. If you change the mask from /24 to /25,
this is what happens:
Now you have two subnets. If you take the new Subnet 2 of 200.100.100.128
and break it down further by changing the mask from /25 to /26, you get this:
If you take the second subnet and break it down further by changing the mask
from /26 to /28 (for example), you get this:
Summary
Hopefully, this has helped you understand VLSM a bit more. It’s no mystery,
really. Please take the time to go over the examples above again, and then
have a go at the challenge below.
Well done on getting this far! Subnetting is one of the necessary skills for
network engineers, and yet it is also one of the most neglected. If you can
confidently subnet, you’re sure to be a useful addition to any network team or
a valuable help to prospective clients as a network consultant.
Make sure you periodically review the book and videos (if you have access)
to keep your subnetting skills sharp.
One last piece of advice: make sure you can write down the Subnetting Cheat
Chart from memory for use in IT exams or interviews.
Books
101 Labs – IP Subnetting
Video Training
https://www.101labs.net – Training course for 101 Labs – IP Subnetting
https://www.howtonetwork.com – Video training course matching this
book (under TCP/IP)
RFCs
RFC 1918 – Address allocation for private internets
RFC 1219 – On the assignment of subnet numbers
RFC 950 – Internet standard subnetting procedure
RFC 940 – Toward an internet standard scheme for subnetting
RFC 932 – Subnetwork addressing scheme
RFC 917 – Internet subnets