2-3 Subnetting

advertisement
2-3 Subnetting
Home → Study Guides → CCNA Routing & Switching 200-120 → Chapter 2 – IP
Addressing and Subnets → 2-3 Subnetting
http://www.freeccnastudyguide.com/study-guides/ccna/ch2/2-3-subnetting/
In case of class A and B IP addresses, each of them provides for a large number of
hosts. For class A, the total numbers of hosts available are 224-2 or 16,777,216 hosts
(class A has 24 bits available for host component and each bit can have two values – 0
and 1. Out of the total value one address is for network address and the other for
broadcast. So two addresses are deducted).
Similarly a Class B addresses provides for 216-2 or 65,534 hosts. In the first chapter you
learned about disadvantages of large networks and why it becomes necessary to divide
them into smaller networks joined by routers. So creating a network with total number of
hosts allowed for class A or B addresses will cause a lot of problems. Meanwhile
creating small networks with class A or B addresses will waste a lot of addresses.
To overcome this problem with class-based addressing, subnetting was introduced.
Subnetting allows you to borrow some host bits and use them to create more networks.
These networks are commonly called subnets and are smaller in size. But since each
network has a network address and a broadcast address, some addresses get wasted.
To further understand how subnetting is useful consider a Class C address. Each class
C address has 28-2 or 254 host addresses available. If you wanted 2 networks with 100
addresses and used 2 class C networks, you would waste 308 addresses. Instead of
using two class C networks, you can subnet one to provide you two networks of 126
addresses each. This way lesser number of addresses would be wasted.
While some of the benefits of subnetting are discussed above, the following list
discusses all the benefits associated with it:

Reduced broadcasts – While broadcasts are necessary, too many of them can bring
down a network and the number of broadcasts is proportionate to the size of the
network. So subnetting a network to smaller subnetworks, helps reduce broadcasts
since routers do not forward broadcasts.

Increased Network Performance – The direct result of reduced broadcasts is a
network that has more bandwidth available to the hosts. More bandwidth and lesser
hosts result in a better performance of the network.
Easier Management – Managing and troubleshooting a large network is cumbersome
and difficult. Subnetting breaks a network into smaller subnetworks, making it easier to
manage each of them.

1

Scalability – A single large network spanning a large geographical location will be more
difficult and costlier to manage. WAN links connecting different locations are costly and
having broadcasts choking the network can result is wasted money. Hence breaking
down a large network makes is easier to scale a network across geographical locations.
Now that you understand the concept and benefit of subnetting, consider the problem
that arises with it. In case of class based subnetting, the first octet of the dotted decimal
address tells which part of the address is the network component and which one is the
host component. But when host bits are borrowed for subnetting, the class based
boundaries do not apply and it is not possible to say which bits are network bits. To
overcome this, a third component of IP addresses were added. These are called
the subnet masks.
Subnets masks, like IP addresses, are 32 bit long. The value of subnet mask represents
which bits of the IP address are network components and which are host component. A
value of 1 in a subnet mask shows that the corresponding bit in the IP address is a
network component while a value of 0 shows that the corresponding bit is a host
component. The following examples will help clarify this further:
1. An IP address of 192.168.10.1 with a subnet mask of 255.255.255.0
(11111111.11111111.11111111.00000000) shows that the first three octets of the IP
address are the network component while the last octet is the host component.
2. An IP address of 172.16.100.1 with a subnet mask of 255.255.128.0
(11111111.1111111.100000000.00000000) shows that one bit from the third octet has
been borrowed from the host component. Hence the network component is now 17 bits
long instead of the default 16 bit in a class B address.
3. An IP address of 10.1.1.1.1 with a subnet mask of 255.255.0.0
(11111111.11111111.00000000.0000000) shows that the entire second octet has been
borrowed from the host component and now the network component is 16 bits long
instead of the default 8 bit of a class A address.
One restriction that applies to subnet masks is that all network bits (1) and all host bits
(0) should be contiguous. So a subnet mask of
11001100.11110000.11110000.00001111 is not valid because the network and host
bits are not contiguous. Table 2-5 shows the valid subnet mask values is an octet.
Table 2-5 Valid subnet mask values in an octet
Binary Value Decimal Value
2
00000000
0
10000000
128
11000000
192
11100000
224
11110000
240
11111000
248
11111100
252
11111110
254
11111111
255
Subnets masks are commonly represented in two ways:
1. Dotted Decimal – 10.1.1.1 255.255.0.0
2. Classless Inter-Domain Routing (CIDR) notation – 10.1.1.1/16
Exam Alert: It is very important to be able to understand subnet masks with both the
dotted decimal as well as the CIDR format. Also remember that any mask not given in
Table 2-5 is not valid for an octet.
By now you may have figured out that the default subnet mask of class A is 255.0.0.0 or
/8, the default mask of class B is 255.255.0.0 or /16 and the default mask of class C is
255.255.255.0 or /24. Table 2-6 shows the default masks of each class. These default
masks cannot be changed. For example, you cannot use a mask of 255.255.0.0 for a
class C address. If you try to use an invalid mask such as this, every device will produce
an error. For each class, the minimum mask is the default mask and it cannot be
reduced. Class A has to have a minimum mask of 255.0.0.0, class B has to have a
minimum mask of 255.255.0.0 and class C has to have a minimum mask of
255.255.255.0.
Table 2-6 Default Subnet masks
Class Format
Default Subnet Mask
A
network.host.host.host
255.0.0.0
B
network.network.host.host
255.255.0.0
C
network.network.network.host 255.255.255.0
3
Remember that an IP address without mask or a mask without IP address does not
mean anything. A mask of /24 does not mean that the address is a class C address.
Even a class A or class B address can have a mask of /24 after subnetting. Table 2-7
provides a list of dotted decimal subnet mask value and the corresponding CIDR value.
Table 2-7 Subnet Mask values
Dotted Decimal Value CIDR notation
255.0.0.0
/8
255.128.0.0
/9
255.192.0.0
/10
255.224.0.0
/11
255.240.0.0
/12
255.248.0.0
/13
255.252.0.0
/14
255.254.0.0
/15
255.255.0.0
/16
255.255.128.0
/17
255.255.192.0
/18
255.255.224.0
/19
255.255.240.0
/20
255.255.248.0
/21
255.255.252.0
/22
255.255.254.0
/23
255.255.255.0
/24
255.255.255.128
/25
255.255.255.192
/26
255.255.255.224
/27
255.255.255.240
/28
255.255.255.248
/29
255.255.255.252
/30
4
Before moving to actual subnetting, you need to remember the powers of 2 i.e. the
value of 2 multiplied as many times as the given exponent. For example 2 4 = 2 x 2 x 2 x
2 = 16. Table 2-8 lists the first 14 values. It is not necessary to remember them all, but
do remember that each value is twice the previous one. The more you remember these
values, the easier it will be to subnet on your CCNA exam
Table 2-8 Powers of Two
Exponent Value
21
2
22
4
23
8
24
16
25
32
26
64
27
128
28
256
29
512
210
1024
211
2048
212
4096
213
8192
214
16384
Now that you know what subnetting is and how subnet masks are used, it is time to
create subnets. When planning to subnet, you need to know three things:
1. Total number of subnets that you need
2. Total number of hosts per subnet that you need
3. Available network and subnet mask (which will be subnetted)
Armed with answers to this, you need to find the following:
1. Subnet Mask to be used across the network
5
2. Valid subnets
3. Network address for each subnet
4. Broadcast address for each subnet
5. Valid host addresses in each subnet.
For this section I will take a sample requirement of 8 networks with 30 hosts each with
one class C network of 192.168.10.0 255.255.255.0 available. Now that you have the
requirement, first thing you need to find is the new subnet mask that can satisfy the
requirement. To find the subnet mask, follow the steps given below:
1. Find the exponent of 2 whose value is more than or equal to the number of subnets
required. Let’s call this 2sn. For our example, we need 8 subnets and 23 equals to 8. So
our 2sn is 23.
2. Find the exponent of 2 whose value minus 2 is more than or equal to the maximum
number of hosts required in a subnet. Let’s call this (2h-2). For our example, we need a
maximum of 30 hosts in a subnet and 25-2 gives us 30 hosts per subnet.
3. Make sure sn + h from the above two steps does not exceed the number of host bits
available in the network available. If the sum of sn and h exceed the available host bits
then you will require another network of the same class or a network of a higher class.
In our example we have 8 bits of host addresses available in 192.168.10.0
255.255.255.0 network. Our sn+h is 3+5 that gives us 8.
4. Convert the available mask to the CIDR notation and add sn to it to get the new subnet
mask. For our example the mask 255.255.255.0 can be converted to /24. On adding 3
we get a mask of /27. Converting from /27 to the dotted decimal format is easy. /24 is
255.255.255.0 or 11111111.1111111.1111111.00000000. /27 will be
11111111.1111111.1111111.11100000. You need not worry about the first 3 octets
since they are already known to be 255.255.255. For the last octet add the decimal
value for each network bit. In our case it will be 128+64+32 = 224. So the new subnet
mask is 255.255.255.224. Table 2-7 also provides a list of dotted decimal and
networking bits value.
The most difficult part is now over. To find the rest of the 4 answers, follow the steps
given below:
6
1. Valid subnets – To find the valid subnets deduct the interesting octet value from 256.
Interesting octets are those octets that have host bits. Available subnets will be in
multiples of the resultant value up to 256. In our case the fourth is the interesting octet.
Deducting 224 from 256 gives us 32. So the available subnets are 0,32, 64, 96, 128,
160, 192, 224.
2. Network Address of each subnet – The network address is the very first address of
each subnet. So for our valid subnets, the network address would be 192.168.10.0,
192.168.10.32, 192.168.10.64, 192.168.10.96, 192.168.10.128, 192.168.10.160,
192.168.10.192 and 192.168.10.224
Exam Alert:
Sometime back Cisco used to discard the first and the last subnet, also called subnet
zero. So the number of subnets used to be 2n-2. Starting IOS version 12.0 the ip
subnet-zero command is enabled by default and in Cisco exams the first and last
subnets are considered unless specified otherwise. Be on the lookout for questions on
your CCNA exam that ask you not to consider subnet zero. In such cases, leave out the
first and the last subnet. To fully understand how the command affects the calculation,
consider a Class C network with a mask of /26. It will give you subnets 0, 64, 128 and
192 if subnet-zero is allowed, else it will only give you subnets 64 and 128.
3. Broadcast Address of each subnet – The last address of a subnet is the broadcast
address. Simply deduct 1 from the next network address to find the broadcast address
of a subnet. For our example subnets the valid broadcast addresses are:
Network Address Broadcast Address
192.168.10.0
192.168.10.31
192.168.10.32
192.168.10.63
192.168.10.64
192.168.10.95
192.168.10.96
192.168.10.127
192.168.10.128
192.168.10.159
192.168.10.160
192.168.10.191
192.168.10.192
192.168.10.223
192.168.10.224
192.168.10.255
7
4. Valid host addresses in each subnet – For every subnet, the valid host addresses lie
between the network address and the broadcast address. For our example, the valid
host addresses for each subnet are:
Network Address Valid Host addresses Broadcast Address
192.168.10.0
192.168.10.1 – 30
192.168.10.31
192.168.10.32
192.168.10.33 – 62
192.168.10.63
192.168.10.64
192.168.10.65 – 94
192.168.10.95
192.168.10.96
192.168.10.97 – 126
192.168.10.127
192.168.10.128
192.168.10.129 – 158
192.168.10.159
192.168.10.160
192.168.10.161 – 190
192.168.10.191
192.168.10.192
192.168.10.193 – 222
192.168.10.223
192.168.10.224
192.168.10.225 – 254
192.168.10.255
Exam Alert:
Subnetting is one of the most important topics in the CCNA exam. Subnetting related
questions will not be straight forward like what you learned just now. Mostly you would
be given an IP address with a subnet mask and you will need to find out if it is a host,
subnet or broadcast address. In following examples review how to approach such
questions.
In the following sections, you will encounter variations of subnetting questions. For all of
them the process is similar to what you just learned. The steps you need to follow are
summarized below:
1. Find the interesting octet in the given subnet mask. Remember that the octet with a
value of less than 255 will be the interesting octet.
2. Deduct the value of interesting octet from 256 to find the increment by which the
network numbers are increasing. These are also your subnet addresses.
3. Write down the subnet address and broadcast address for each subnet
4. Write down the host addresses of each subnet
5. Once you have all the above information, you will find the answer to the given question.
8
Subnetting Class C Addresses
Subnetting technique remains the same irrespective of the class of address. The
difference that the class makes is the number of bits available for subnetting. Class C
starts with a mask of /24 and can have a maximum mask of /30. We cannot use /31 or
/32 because at least 2 hosts bits are required for the network and broadcast addresses
and /31 and /32 give us 1 and zero host bits respectively. In the examples below, you
get to practice subnetting class C addresses.
Subnetting Class C Address – Example #1
Problem: Is 192.168.1.193/26 a host address?
Solution:
1. Converting /26 to dotted decimal format gives 255.255.255.192. The fourth octet is the
interesting octet.
2. Deducting 192 from 256 gives us 64. So the subnet addresses are 0,64,128 and 192
3. The network address and broadcast address are:
Network Address Broadcast Address
192.168.1.0
192.168.1.63
192.168.1.64
192.168.1.127
192.168.1.128
192.168.1.191
192.168.1.192
192.168.1.255
4. The host addresses for each of the subnets are:
Network Address Host Addresses
Broadcast Address
192.168.1.0
192.168.1.1-62
192.168.1.63
192.168.1.64
192.168.1.65-126
192.168.1.127
192.168.1.128
192.168.1.129-190 192.168.1.191
192.168.1.192
192.168.1.193-254 192.168.1.255
5. The given address, 192.168.1.193 is a host address in the last subnet.
Subnetting Class C Address – Example #2
9
Problem: What is the network and broadcast address for the subnet to which the
address 192.168.1.228/28 belongs?
Solution:
1. Converting /28 to dotted decimal format gives 255.255.255.240. This shows that the
fourth octet is the interesting octet.
2. Deduction 240 from 256 gives us 16. So the subnet addresses are 0, 16, 32, 48, 64 …
208, 224, 240.
3. The network and broadcast address for the subnets are:
Network Address Broadcast Address
192.168.1.0
192.168.1.15
192.168.1.16
192.168.1.31
192.168.1.32
192.168.1.47
192.168.1.48
192.168.1.63
192.168.1.64
192.168.1.79
192.168.1.208
192.168.1.223
192.168.1.224
192.168.1.239
192.168.1.240
192.168.1.255
4. The host addresses of each subnet are:
Network
Address
Host Addresses
Broadcast Address
192.168.1.0
192.168.1.1-192.168.1.14
192.168.1.15
192.168.1.16
192.168.1.17-192.168.1.30
192.168.1.31
192.168.1.32
192.168.1.33-192.168.1.46
192.168.1.47
192.168.1.48
192.168.1.49-192.168.1.62
192.168.1.63
192.168.1.64
192.168.1.65-192.168.1.78
192.168.1.79
192.168.1.208 192.168.1.209-192.168.1.222
192.168.1.223
10
192.168.1.224 192.168.1.225-192.168.1.238
192.168.1.239
192.168.1.240 192.168.1.241-192.168.1.254
192.168.1.255
5. From the above table, you can see that the address 192.168.1.228 lies in the
192.168.1.224 subnet. The network address for this subnet is 192.168.1.224 and the
broadcast address is 192.168.1.239.
Subnetting Class C Address – Example #3
Problem: What type of address is 192.168.5.47/29? What is the network and broadcast
address of the subnet that this address belongs to and how many host addresses are
available in the subnet?
Solution:
1. Converting /29 gives 255.255.255.248. This shows that the fourth octet is the interesting
octet.
2. Deducting 248 from 256 gives us 8 so the subnets are 0, 8, 16, 24, 32, 40, 48…240,248
3. 192.168.5.47 lies in the 192.168.5.40 subnet and is the last address before the next
subnet 192.168.5.48. This means that 192.168.5.47/29 is a broadcast address for the
192.168.5.40/29 subnet.
4. The network address for this subnet is 192.168.5.40 and the valid host address range is
192.168.5.41-192.168.5.46
Subnetting Class B addresses
The process to subnet class B addresses is same as that used to subnet class C
address. The difference is that you have more bits available for subnetting. Class B
addresses start with a mask of /16 and can have a maximum mask of /30. One big
difference when subnetting class B addresses is that you deal with large number of
hosts per subnet and it becomes important to remember the Powers of Two table
shown in Table 2-8. In the examples given below, you will practice subnetting class B
addresses.
Subnetting Class B address – Example #1
Problem: Is 172.16.98.45/19 a host address?
Solution:
11
1. Converting /19 to dotted decimal format gives us 255.255.224.0. The third octet is the
interesting octet.
2. Deducting 224 from 256 gives 32. So the subnet addresses are 0, 32, 64, 96, 128, 160,
192, 224
3. The network address and broadcast address are:
Network Address Broadcast Address
172.16.0.0
172.16.31.255
172.16.32.0
172.16.63.255
172.16.64.0
172.16.95.255
172.16.96.0
172.16.127.255
172.16.128.0
172.16.191.255
172.16.192.0
172.16.223.255
172.16.224.0
172.16.255.255
4. The host address range for each subnet is:
Network
Address
Host Addresses
Broadcast Address
172.16.0.0
172.16.0.1-172.16.31.254
172.16.31.255
172.16.32.0
172.16.32.1-172.16.63.254
172.16.63.255
172.16.64.0
172.16.64.1-172.16.96.254
172.16.95.255
172.16.96.0
172.16.96.1-172.16.127.254
172.16.127.255
172.16.128.0
172.16.128.1-172.16.191.254
172.16.191.255
172.16.192.0
172.16.192.1-172.16.223.254
172.16.223.255
172.16.224.0
172.16.224.1-172.16.255.254
172.16.255.255
5. The address 172.16.98.45 is a host address in the 4th subnet.
Subnetting Class B address – Example #2
Problem: What are the network and broadcast addresses for the subnet to which the
address 172.19.251.100/23 belongs.
Solution:
12
1. Converting /23 to dotted decimal format gives us 255.255.254.0. This shows that the
third octet is the interesting octet.
2. Deducting 254 from 256 gives us 2. So the subnet addresses are 0, 2, 4, 6, 8, 10…248,
250, 252, 254
3. The network, broadcast and valid host ranges for these subnets are:
Network
Address
Host Addresses
Broadcast Address
172.19.0.0
172.19.0.1-172.19.1.254
172.19.1.255
172.19.2.0
172.19.2.1-172.19.3.254
172.19.3.255
172.19.4.0
172.19.4.1-172.19.5.254
172.19.4.255
172.19.6.0
172.19.6.1-172.19.7.254
172.19.7.255
172.19.8.0
172.19.8.1-172.19.9.254
172.19.9.255
172.19.250.0 172.19.250.1-172.19.251.254
172.19.251.255
172.19.252.0 172.19.252.1-172.19.253.254
172.19.253.255
172.19.254.0 172.19.254.1-172.19.255.254
172.19.255.255
5. As you can see, the address 172.19.251.100/23 is a valid host address in the
172.19.250.0/23 subnet. The network address for this subnet is 172.19.250.0 and the
broadcast address is 172.19.251.255.
Subnetting Class B address – Example #3
Problem: You see that your PC has an IP address and subnet mask of 172.30.40.5/21.
How many subnets can your network have? How many valid host addresses can each
subnet have?
Solution:
1. Converting a /21 mask to dotted decimal format gives us 255.255.248.0.
2. Converting it to dotted binary format gives us
11111111.11111111.11111000.00000000. This shows that 5 bits have been borrowed
for subnets and 11 bits are available for host addresses.
3. The borrowed 5 bits gives us 25=32 subnets.
13
4. The 11 host bits give us 211 = 2048 addresses. Out of 2048, 2 addresses are reserved
for host and broadcast addresses. So this leaves us with 2046 valid host addresses per
subnet.
Subnetting Class A addresses
The process to subnet class A addresses is the same as that you have used to subnet
class C and B addresses. The big difference is the large numbers you can deal with
while using masks such as /9. Class A addresses start with a mask of /8 and can have a
maximum of /30 mask. In the examples below, you will practice subnetting class A
addresses.
Subnetting Class A address – Example #1
Problem: Is 10.127.255.254/9 a host address?
Solution:
1. Converting /9 to dotted decimal format gives 255.128.0.0. The second octet is the
interesting octet.
2. Deducting 128 from 256 gives 128. So the subnet addresses are 0 and 128.
3. The network and broadcast address are:
Network Address Broadcast Address
10.0.0.0
10.127.255.255
10.128.0.0
10.255.255.255
4. The host address range for the subnets are:
Network
Address
Host
Addresses
Broadcast
Address
10.0.0.0
10.0.0.110.127.255.254
10.127.255.255
10.128.0.110.128.0.0 10.255.255.254
10.255.255.255
5. 10.127.255.254 is the last host address in the 1st subnet.
Exam Alert: A /30 or 255.255.255.252 is the highest mask which can be practically
used in a network. It gives 2 host addresses and is ideal for point-to-point links in a
network. Point-to-Point links are usually found in routers terminating WAN
links.[/stextbox
14
Subnetting Class A address – Example #2
Problem: This is a different kind of a problem. Your network number is 21.0.0.0. You
need to have as many subnets as possible without exceeding 1000 subnets while at the
same time having at least 500 hosts per subnet. What subnet mask would you use?
Solution:
Since 21.0.0.0 is a Class A network, the default mask is /8. So you have 24 bits of host
addresses that can be borrowed for the subnetting. Looking back at Table 2-8, you will
see that 210 gives us 1024 while 29 gives us 512. Since 1024 exceeds the given 1000
subnets, you will need to use 29. This means 9 bits will be borrowed for the network part
leaving the rest for the host part. The table below shows the default mask and the new
mask after borrowing 9 bits:
Octets
1st Octet
2nd Octet 3rd Octet
4th Octet
Default mask 11111111 00000000 00000000 00000000
New mask
11111111 11111111 10000000 00000000
The new mask of /17 will leave 15 bits for the host part which gives us much more than
the required 500 hosts per subnet.
Subnetting Class A address – Example #3
Problem: You have been given a network number of 10.0.0.0/8. You need to subnet it
such that you have at least 8000 hosts per subnet and at least 2000 subnets. What
subnet mask will you use?
Solution:
10.0.0.0/8 is a class A address with a default mask of /8. This leaves you with 24 bits for
host addresses. So you need to find which multiples of 2 give us the required numbers.
Looking back at Table 2-8, you will see that 211 gives us 2048 while 213 gives us 8192.
This means you can borrow 11 bits for the network part, leaving 13 bits for the host part.
The table below shows the default mash and the new mask in binary format:
Octets
1st Octet
2nd Octet 3rd Octet
4th Octet
Default mask 11111111 00000000 00000000 00000000
New mask
11111111 11111111 11100000 00000000
10.0.0.0/19 will give you 2048 subnets with 8192 host bits remaining. Each subnet will
have a maximum of 8109 hosts, leaving 2 addresses for network and broadcast
addresses.
15
Subnetting Class A address – Example #4
Problem:
What are the network and broadcast addresses for the subnet to which the address
10.212.10.50/12 belongs.
Solution:
1. Converting /12 to dotted decimal format gives us 255.240.0.0. This shows that the
second octet is the interesting octet.
2. Deducting 240 from 256 gives us 16. This means that the valid subnets are 0, 16, 32,
48, 64…208, 224, 240
3. The network, valid host and broadcast addresses for these subnets are:
Network
Address
Host Addresses
Broadcast Address
10.0.0.0
10.0.0.1-10.15.255.254
10.15.255.255
10.16.0.0
10.16.0.1-10.31.255.254
10.31.255.255
10.32.0.0
10.32.0.1-10.47.255.254
10.47.255.255
10.48.0.0
10.48.0.1-10.63.255.254
10.63.255.255
10.64.0.0
10.64.0.1-10.207.255.254
10.207.255.255
10.208.0.0 10.208.0.1-10.223.255.254
10.223.255.255
10.224.0.0 10.224.0.1-10.239.255.254
10.239.255.255
10.240.0.0 10.240.0.1-10.255.255.254
10.255.255.255
4. The address 10.212.10.50/12 is a host address in the 10.208.0.0/12 subnet.
5. The network address for the subnet is 10.208.0.0 and the broadcast address is
10.223.255.255
http://www.freeccnastudyguide.com/subnetting-practice-questions/
16
What valid host range is the IP address 172.24.113.100/26 a part of?
172.24.113.65 through to 172.24.113.126
How many subnets and hosts per subnet can you get from the network 192.168.74.0
255.255.255.192?
4 subnets and 62 hosts
What is the first valid host on the subnetwork that the node 10.228.67.103
255.255.240.0 belongs to?
10.228.64.1
17
Download