Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
37 views5 pages

PrepLogic Subnetting

Learn to subnet tips

Uploaded by

ma gre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views5 pages

PrepLogic Subnetting

Learn to subnet tips

Uploaded by

ma gre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

www.preplogic.

com 1-800-418-6789

Take a longer binary number, such as the


First the Basics octet, 11111101. If you are familiar with
Binary Arithmetic counting in binary you will know immediately
that this number is 253. If you are not familiar with
If you understand how binary numbers work, you can skip this counting in binary, dont despair: it is not that hard.
section and go to the next. But, if you dont, you need to spend a Consider the table below.
bit of time here to get a basic understanding of binary numbering.
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
All numbering systems work the same way. The one we are most 128 64 32 16 8 4 2 1
familiar with, Base 10 (decimal), works the same way as Base 1 1 1 1 1 1 0 1
2 (Binary) or Base 16 (Hexadecimal) for that matter. Lets take a
random number, such as 1,234. We know immediately what that 128+ 64 + 32 + 16 + 8 + 4 + 0 + 1 = 253
number is. It is so obvious to us that it seems trite to say that
the number is the sum of one thousand plus two hundred plus But there is an even easier way to convert this number to
thirty plus four. However, we can express this sum in another, decimal. We know that the binary number 11111111 is 255 in
more interesting way: decimal (you just have to memorize this). When we look at a
number like 11111101, all we have to do is subtract 2 (in this case)
(1 * 10^3) + (2 * 10^2) + (3 * 10^1) + (4 * 10^0) = 1,234 (The ^ from 255 to arrive at our decimal conversion, 253.
symbol indicates raised to the power of, eg 10^3 means 10
raised to the power of 3, or 10 * 10 * 10) Although a TCP/IP address is 32 digits long, the address is broken
up into 4 equal groups of 8 digits (4 groups of single bytes) to
It should be pretty obvious why we can refer to this number make it easier to work with. So, here is a tip for working with
system as Base 10. We have 10 digits to work with (0 9). binary numbers in TCP/IP addresses: draw out the first 8 positions
as in the table above. If you use that table, you will be able to
Binary (Base 2) numbering is like decimal (Base 10) numbering convert any decimal TCP/IP address to binary and vice versa. One
except that we have only 2 digits to work with: 0 and 1. Lets final tip: practice converting binary to decimal and vice versa;
take a typical binary number, such as 1101. Like Base 10 numbers, check your results in the Windows calculator in scientific mode.
we can express a binary number as a sum of other numbers. In
the case of the example (1101), we can express the number thus: Calculating Subnet Masks
(1 * 2^3) + (1 * 2^2) + (0 * 2^1) + (1 * 2 ^ 0) = 8 + 4 + 0 + 1 = 13. What are subnet masks and why do we need them? To answer
(By the way, any number raised to the power of 0 is 1.) these two questions, we have to spend a little time discussing
some basics about TCP/IP. A TCP/IP address, such as 172.16.8.1,
As with decimal numbers, we can easily internalize a lot of the work we is composed of at least two parts: a section that denotes the
have to do by looking at the positions of the digits in a particular number. network portion of the address and a section that denotes the

PrepLogic Whitepapers | www.preplogic.com 1


host portion of the address. As an analogy, you can think of Lets say we decide to use the entire 3rd octet of the address
a postal address: one part of the address refers to a street; to extend the number of subnets on our network. I would
another part refers to a particular house. In order for the use a subnet mask of 255.255.255.0. That would give us
address to work properly, both parts have to be unique. How approximately 254 possible networks, each with approximately
does your computer know which portion or the TCP/IP address 254 hosts. (I say approximately because the actual and precise
represents the network and what portion represents the number of hosts and networks depends on your hardware and
hosts? It looks at the subnet mask for the address. The subnet software, but this is a technicality best left to people who
mask distinguishes the network from the host portion of the support routers or are studying for their Cisco certifications.)
address (e.g., 172.16.8.1/16). Any bits in the address that are
masked by the subnet mask will represent the network portion Given this subnet, a host with an IP address of 172.16.8.1/24
(172.16.) of the address; the remaining bits represent the host is on a different network from a host with an IP address of
portion (.8.1) of the address. 172.16.9.1/24. This means that both hosts need to be
separated by and reachable through a router. If the subnet mask
When people look at a TCP/IP address, they often think about were 255.255.0.0, both hosts would be on the same network.
the class of address it represents. In our example above, the
IP address 172.16.8.1 is a Class B address. For a Class B AND IP Addresses
address, the default subnet mask is 255.255.0.0. This simply
means that the first two octets, 172.16, represent the network Okay, weve seen the need to extend the subnet mask, but how does
portion of the address, and the last two octets represent the TCP/IP know whether hosts are on the same or different networks?
host portion of the address. To determine if an address is a Whenever a computer is instructed to communicate with another TCP/
Class A, Class B, or Class C address and the default subnet IP host, it ANDs its address and the destination address with the
masks for these addresses, you can consult the following table: subnet mask and compares the result. If the result is the same, the
TCP/IP stack will do an ARP (Address Resolution Protocol) broadcast
First Octet (dec. & binary) Class Subnet Mask to determine the MAC (Media Access Control) address of the network
adaptor of the destination host. Once it has the MAC address of the
1 - 126 (0xxxxxxx) A 255.0.0.0 adaptor, the computer will start communicating with the host. If,
128 191 (10xxxxxx) B 255.255.0.0 however, the result of the ANDing is different, the source host will
do an ARP for the MAC address of router on the network, which is
192 223 (110xxxxx) C 255.255.255.0
usually the configured default gateway. (Of course, your computer
maintains an ARP cache in memory, and it will not do an ARP if it first
For a Class A address, the first octet represents the network; for
finds the information in the ARP cache).
a Class B the first two octets represent the network; and for a
Class C the first 3 octets represent the network. If you keep in What is ANDing? ANDing is similar to multiplication, except it
mind our postal address analogy, it should be clear that there is used for logical operations. There are 4 logical operations we
a few Class A streets, but a huge number of houses on each can perform with binary numbers: AND, OR, XOR (exclusive-or)
street. There are more Class B streets and fewer houses on and NOT. Here is why ANDing is like multiplication. A 0 ANDed
each street, and so on. with a 1 results in a 0. A 1 ANDed with a 1 results in a 1.
Lets go back to our sample TCP/IP address, 172.16.8.1/16. Lets go back to our sample extended network. A computer
The default network portion of the address is represented by the with an IP address of 172.16.8.1/24 is trying to establish
first two octets, which can be expressed as 172.16.0.0/16. an HTTP session with a computer that has an IP address of
The /16 represents the number of bits used for the subnet 172.16.9.1/24. The question we need to answer is: Are these
maskin this case, it is 16 bits (11111111.11111111.00000 computers on the same or a different network?
000.00000000 = 255.255.0.0). In fact, it is now standard
practice to refer to all IP addresses this way. We are left with 16 Lets look at the subnet mask of the source computer. It is
bits to represent the host portion of the address. With 2^16 or using 24 bits as the subnet mask, which can be expressed as
65,536 (give or take one or two) possible address to represent 255.255.255.0 or as 11111111.1111111.11111111.0.
the hosts on the 172.16.0.0/16 network, we obviously have To determine if the two computers are on the same or a
lots of room for growth. different network, your TCP/IP stack will AND 172.16.8.1 and
172.16.9.1 with 255.255.255.0. We need only consider
But, hold on, that is way too many computers to place on a single the third octet. We dont have to consider the first two octets
cable. Furthermore, if we put the maximum number of hosts that we because they are identical.
could physically accommodate on an Ethernet cable, we would waste
a lot of addresses. Thats where a custom subnet mask comes into 8
play. We can borrow bits from the host portion of the address and 255
00001000 AND11111111 =00001000
use them to represent the network portion of the address. In effect,
what we can do is subdivide our street into a number of smaller 9
streets, or subdivide our network into smaller subnets. 255
00001001 AND11111111 =00001001

PrepLogic Whitepapers | www.preplogic.com 2


Because the result of the AND is different for the source and As we learned in section one, the TCP/IP stack will AND the
host address, the source computer will ARP for the router source and the destination IP address with the subnet mask and
interface. Once it has the MAC address for the router, it will start compare the results. If the results of the ANDing are the same,
communicating with it, and the router will send the packets on the two hosts are on the same network. If the results of the
to another router or the final destination. ANDing are different, the two hosts are on different networks.

What if our subnet mask were something different, like Lets do the ANDing for 172.16.32.1/19 and 172.16.64.1/19.
255.255.252.0? Given this subnet mask, are these two We can ignore the first two octets, since they are identical for
machines on the same or a different network? If we AND the both addresses. The octet of interest is the 3rd octet.
addresses, here is what we get:
32 224 32
8 00100000 AND 11100000 = 00100000
252
00001000AND11111100 =00001000 64 224 64
01000000 AND 11100000 = 01000000
9
252 Given a subnet mask of 255.255.224.0, the two hosts are on
00001001 AND11111100 =00001000 different networks. One way you can think about subnet masks
is this: any time there is a change in the bits used to represent
Because the result of the AND is the same for both addresses, the network portion of the address, you have a separate
your TCP/IP stack will assume that the two hosts are on the same network. In the case of a custom subnet mask of 224, we create
network and do an ARP for the MAC address of the final destination. at least 6 networks. (I say at least because the actual number
depends on the hardware or the software. This is a rather
As it turns out, ANDing is something a computer is very good technical issue that you neednt concern yourself with right
at (it needs ANDing to route packets properly, for example) now. For the time being, we are going to assume that neither the
Fortunately, though, we dont have to AND addresses with subnet network nor the host portion of the address can be all 0s or all
masks to determine if hosts are local (on the same network) or 1s, as per the original 1985 standard for subnetting, RFC 950.)
remote (on different networks). There are easier ways to do this,
so easy in fact that you should not have to use a calculator or Here are the possible network IDs in the 3rd octet for our
software to calculate subnet masks. Calculating subnet masks 255.255.224 subnet mask:
neednt require anything more than your brain and pencil and
paper. In section two we will take a look at a simpler method for 00000000 0 (Normally not allowed according to RFC950)
calculating subnet masks. 00100000 32 172.16.32.0/19
01000000 64 172.16.64.0/19
Learn to Subnet Section Two 01100000 96 172.16.96.0/19
10000000 128 172.16.128.0/19
Lets take a look at an example of two hosts on a Class B
network trying to communicate with one another. Lets assume 10100000 160 172.16.160.0/19
the IP address of the source host is 172.16.32.1/16 and the 11000000 192 172.16.192.0/19
destination host address is 172.16.64.1/16. Because we 11100000 224 (Normally not allowed according to RFC950)
are using the default subnet mask of /16 or 255.255.0.0,
172.16.32.1/16 and 172.16.64.1.16 are on the same Remember, we are dealing only with the 1st 3 left-most bit
network. As long as there is no change in the network portion positions. A subnet mask of 224 masks off these bits to represent
of the address, the two hosts are on the same network. The the network. For any two IP addresses, if the values in these bit
network portion of the address is determined by the subnet mask positions change, the IP addresses are on different networks. So,
of 255.255.0.0, which tells the TCP/IP stack that the first two for example 172.16.64.1/19 is on a different network from
octets, 172.16.0.0, represent the network portion of the address. 172.16.100.1/19. However 172.16.32.1/19 is on the same
However, what if we need more than one network, perhaps network as 132.16.63.254/19. Just write out the 3rd octet
because we have remote locations or we have more hosts than in binary for both numbers. Do the bits representing the network
we can place on a single cable? It makes sense to sub-divide portion of the change? If the answer is yes, then the addresses
the network into smaller networks. What if we needed to create are on different networks. If not, the hosts are on the same network.
6 subnets from our larger, single network? In a case like this,
we would need to extend the default subnet mask by borrowing Lets go back to our example subnet of 255.255.224.0. Consider
some of the bits from the host portion of the IP address. To the table representing the possible network IDs above. Notice
create at least six subnets from the 172.16.0.0/16 network, any patterns? One pattern that stands out is the difference
we need to borrow at least 3 bits. So, our subnet mask would be between one Network ID and another: the difference is 32. That
255.255.224.0. In binary, the subnet mask would look like this: is, starting with the first network ID of 172.16.32.0/19, we
increment by 32 in the 3rd octet to arrive at the next network ID
11111111.11111111.11100000.00000000 of 172.16.64.0/19 and so on up to 172.16.192.0/19.

PrepLogic Whitepapers | www.preplogic.com 3


Heres another relationship to consider. Have a look at the Anytime you are in a situation, such as a Microsoft exam, where
subnet mask expressed in binary. you might have to calculate subnets, draw out this table.
128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
1 1 1 0 0 0 0 0 = 128 + 64 + 32 = 224
1 1 1 1 1 1 1 1
The value of the lowest order bit for the subnet mask is 32. This is not 192
a coincidence, if you consider the permutations in the table above.
224
So, here is a general rule for calculating subnet masks. Use 240
the low order bit for the subnet mask to determine the starting 248
network ID for your subnets and the value used to increment
252
from one network ID to the next. In our example, the value is 32.
254
Here is another general rule for calculating subnet masks. The
number of bits used to represent the custom subnet can be Here is how you use the table. Lets say in an exam situation,
used to calculate the number of possible networks. The formula you need to determine if two particular hosts are on the same
is this:2^(no. of bits used for subnet) 2 = number of possible or different networks. Lets take two IP addresses at random,
subnets. So for our example, we used 3 bits to give us (2^3)-2 such as 172.16.36.1/20 and 172.16.43.254/20. The
= 6 networks. We subtract 2 because the all 0 and the all 1 subnet mask is 20 bits long: 255.255.240.0 (11111111.11
subnet may or may not be allowed, depending on your hardware 111111.11110000.00000000).Take a look at the low order
or software. (If your hardware or software supports the all 0 bit used for the subnet mask in the 3rd octet. A value of 240
network, great. Instead of writing me, you can adjust the formula means that the low order bit is 16 (just follow the lines on the
to suit your circumstances.) chart). If the low order bit is 16, that means the first network ID
is 172.16.16.0/20, the next is 172.16.32.0/20, followed
These two rules may be applied to any subnet mask. Consider
by 172.16.48.0/20, and so on. In other words the network ID
the two IP addresses 172.16.32.1/20 and 172.16.40.1/20.
starts at x.y.16.0 and increments by 16 for each network. The two
Are these hosts on the same or different network? To determine
hosts are on the same network.
this, draw out the bits for the subnet mask.

255 255 240 0 Lets take this a little farther. Given a Class B address
11111111.11111111.11110000.00000000 of 172.16.0.0/16, how many subnets are created by
extending the subnet mask by 4 bits into the 3rd octet to
The value of the low order bit for the subnet mask is 16. 128 64 255.255.240.0? The answer is 2^4 2 = 14. (This number
32 16 8 4 2 1 1 1 1 1 0 0 0 0 = 128 + 64 + 32 + 16 = 240. Here are assumes that our hardware and software do not support the all
the valid network IDs for the 172.16.0.0/20 subnets (excluding the 0 or the all 1 subnets.)
all 0 and all 1 subnets)
How many hosts can we have on each subnet? With a Class B
172.16.16.0/16 address and a subnet mask of /20, we have 12 bits left over
172.16.32.0/16 to represent the host addresses on each network. Therefore,
172.16.48.0/16 the number of addresses on each network is 2^12 2 = 4094.
...172.16.224.0/16 Like our network addresses, we are going to be consistent and
say that the host portion of the address cant be all 0sthat
Any two hosts between 172.16.32.1/20 and represents the network ID. Nor can the host portion of the
172.16.47.254/20 are on the same network. So, our two hosts address be all 1sthat number represents the broadcast address
(172.16.32.1/20 and 172.16.40.1/20) are on the same Any on the subnet.
two hosts between 172.16.32.1/20 and 172.16.47.254/20
are on the same network. So, our two hosts (172.16.32.1/20 What is a valid range of host address on our 172.16.32.0/20
and 172.16.40.1/20) are on the same network. However, what network? Keeping in mind that the host portion of the address
if our subnet mask is /21 (or 255.255.248.0)? Our two hosts cant be all 1s or all 0s, the valid range of host addresses is
are on different networks. How can we tell this easily? Look at 172.16.32.1 172.16.47.254. Why do we end at x.y.47.254?
the low order value for the subnet mask. For a subnet mask of Because the next network ID is x.y.48.0, and we cant have all 1s
248, the value is 8. So, starting at 8 the valid network IDs are in the host address, which rules out x.y.47.255.
172.16.8.0/21, 172.16.16.0/21, 172.16.24.0/21 and
Lets look at one last example before we move on. Assume we have
so on up to 172.16.240.0/21. How many subnets does our
been given a Class C address of 192.168.100.0/24 and need
extended mask give us? We borrowed 5 bits from the host portion
to create at least two subnets from this address. How many bits
of the address; therefore, the possible number of subnets we
borrowed from the last octet will give us two subnets? 2 bits
create is 2^5 2 = 30.
(2^2-2=2). Consulting the table above, we see that borrowing
two bits gives us a subnet mask of 255.255.255.192.

PrepLogic Whitepapers | www.preplogic.com 4


Assuming that we cant use the all 0 or the all 1 subnet, what is Where do we use supernetted addresses? Normally, w e would
our first network ID? Consulting the table above, we see that the not use supernetted addresses on client computers. Supernetted
low order bit for the 192 subnet is 64. Therefore, the first network addresses are used on routers to aggregate multiple entries in
ID is 192.168.100.64/26. What is the next network ID for this their routing tables into single entries. Here is how it works. Lets
subnet mask? Look at the value of the low order bit for the subnet say we have a large block of class C networks that is reachable
mask and add that to the first network ID to determine the next through a single router, Router A. Router A will advertise to
network ID. The next network ID is 192.168.100.128/26. its neighbor routers that it has routes to a bunch of class C
networks. Lets say Router A advertises routes for each network
Now for the tricky part. What are the valid ranges of in the range 192.168.8.0/24 192.168.15.0/24. In other
host addresses for the subnets of 192.168.100.0/26? words, Router A has 8 individual entries in its routing table.
The valid host ranges are 192.168.100.65/26
192.168.100.126/26 and 192.168.100.129 This is precisely the situation where CIDR blocks can be used.
192.168.100.190/26. If the numbers in the last octet look CIDR stands for Classless InterDomain Routing. Think about
a little strange, write them out in binary. Keep in mind that that term for a bit. In the previous section on subnetting, we
for host addresses we cant have all 0s or all 1s in the host dealt with classfull addresses, that is addresses that could be
portion of the address. So, for example, 01000000(or 64) is characterized as Class A, B, or C. With those addresses we cared
an invalid host address because the last 6 positions are 0s. (to some extent) what the default subnet mask for a particular
Likewise 01111111(127) is an invalid address because the last 6 address is. For Classless Interdomain Routing, we really dont
positions (the host portion of the address) are all 1s. care about the default subnet mask. All we are interested in is
determining the mask that will allow us to describe a group of
If you practice calculating subnet masks, you will find after a contiguous networks as a single network. In other words we are
while it becomes fairly easy, especially if you use the table. You going to use the same techniques for supernetting as we used
will also find the table pretty handy for exams where you have to for subnetting, except we are going to ignore the class of the
know subnetting. When you get into the exam booth, write out the addresses we are dealing with and their default subnet mask.
binary table with the subnets. If you want, copy out these simple
rules. The lowest order bit in the subnet mask determines the Lets go back to our example router that contains entries
starting network ID and the value that you can add to the network for 8 routes to networks between 192.168.8.0/24
ID to determine the next network ID. To calculate the number of 192.168.15.0/24. We want to replace these 8 entries with
hosts orthe number of networks, use this formula: 2^(no. of bits) a single entry. From the table we used for subnetting, we know
2 = number of hosts/networks. You shouldnt have all 0s or all 1s that if we were dealing with a Class B address (instead of a
in the network or host portion of the address. Keep in mind that Class C), we could describe this range of addresses as a single
some hardware/software may create exceptions to this last rule. network with the subnet mask 255.255.248.0. Look at the
difference between 15 and 8 to determine the low order bit for
Thats it. I think its pretty easy, and it sure beats memorizing the mask. Since 8 is the closest value, we know that we need 5
tables or performing complicated arithmetic. As a final test of your bits in the 3rd octet for the mask (11111000 = 248). It doesnt
ability to subnet, here is one final teaser. What are the first 10 matter that we are dealing with Class C addresses since this
possible subnets for this subnetted network: 172.16.0.0/25? is classless addressing. With CIDR blocks I can now advertise a
Hint, the first network ID is 172.16.0.128/25 and there are 2^9 route to these 8 networks as a single entry: 192.168.8.0/21.
2 possible subnets. What are the ranges of valid hostaddresses
for the first few subnets? Not all routers can support CIDR blocks. For a router to support
CIDR blocks, it must also support a routing protocol such as RIP
CIDR Block Rules or Supernetting Made Easy v 2 or OSPF.Both of these protocols provide information about the
subnet mask when they communicate with other routers. That
You thought we were finished, didnt you? If your brain hurts not only makes CIDR blocks possible, but it also makes the all 0
from the previous section, put this aside and come back to networks possible, along with Variable Length Subnet Masks.
it again. But, do come back. Knowing about CIDR blocks and
supernetting, not to mention Variable Length Subnet Masks
(VLSM), may be important to you someday. Furthermore, none of
these topics is much more difficult than subnetting, if you spend
some time with them.

If you know how to subnet, you know how to supernet, even


though you might not think you can. A supernetted address is
one in which bits are borrowed from the network portion of
the address, rather than the host portion of the address. But,
aside from this difference, the arithmetic works the same for
supernetted addresses as for subnetted addresses.

PrepLogic Whitepapers | www.preplogic.com 5

You might also like