Professional Documents
Culture Documents
Chapter 2
Chapter 2
Table 2-2 shows the decimal value for the most common binary numbers you
will encounter in this chapter.
128 64 32 16 8 4 2 1
An IP address does not only represent the host address. In fact it represents the
network where the host resides and the host it self. In effect, the IP address
consists of two parts:
Each combination of the network component and the host component should
be unique in the entire Internetwork. To make it easy to identify which portion
of the address is network component and which one is the host component,
addresses are broken down into 5 classes discussed below:
Class A – The first byte (8 bits) is the network component and the
remaining three bytes (24 bits) are host component
(network.host.host.host). This class is for an internetwork with small
number of networks and large number of hosts per network.
Class B – The first two bytes (16 bits) are the network component and the
remaining three bytes are host components (network.network.host.host).
This class bridges the gap between Class A and Class C by providing for
medium number of networks with medium number of hosts.
Class C – The first three bytes (24 bits) are the network component and
the last byte (8 bits) is the host components
(network.network.network.host). This class provides for large number of
networks with fewer hosts per network.
In a binary address the first 5 bits of the address and the first octet in a dotted
decimal address shows the class of address. Table 2-3 shows the first 5 bits and
the first octet range of each class of address.
Before moving ahead, spend some time to figure out the class of some addresses
given below. Also try to figure out which portion is the network and which
portion is the host part:
Some IP address such as 127.0.0.1 have a special meaning. Table 2-4 lists such
addresses and what they represent.
The IANA also designated a range of addresses in class A, B and C for use in
private networks. These addresses can be used by anyone within their network
without any required permission but these addresses are not routable on the
Internet. You ISP or your organization usually assigns you one of these addresses
and later translates it to a public address when you want to get out to the Internet.
The designated ranges for private IP addresses are:
Class A – 10.0.0.0 to 10.255.255.255 (1 network)
Class B – 172.16.0.0 to 172.31.255.255 (16 networks)
Class C – 192.168.0.0 to 192.168.255.255 (256 networks)
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. 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.
While some of the benefits of subnetting are discussed above, the following list
discusses all the benefits associated with it:
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:
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.
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.
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 24 =
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.
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:
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. Lets 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. Lets 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:
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
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:
4. Valid hosts 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:
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.
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 atleast 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.
Solution:
Problem: What is the network and broadcast address for the subnet to which
the address 192.168.1.228/28 belongs?
Solution:
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.
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
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.
Solution:
Solution:
Solution:
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
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:
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.
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:
Problem: What are the network and broadcast addresses for the subnet to
which the address 10.212.10.50/12 belongs.
Solution:
Earlier, it was required to use the same subnet mask across the network. This was called classful
networking. With increase in complexity of networks and decrease in available IP addresses it
became obvious that classful networking causes waste valuable of IP addresses. To understand
how, consider Figure 2-1. The largest subnet requires 30 host addresses. So across the network a
mask of /27 is used, which gives 30 hosts per subnet. You will notice that in every subnet except
the subnet attached to RouterD, some host addresses will remain unused. In particular, 28 host
addresses are wasted for each link between the routers. In total this network wastes 118
addresses and uses 92 addresses.
In Figure 2-2, notice the different masks used for each subnet. The first network with 13 hosts is
using a mask of /28, which gives 16 hosts addresses. The point-to-point links between the routers
are using a /30 mask which gives 2 host addresses. In total the network is still using 92 addresses
but is wasting only 22 addresses. Now that you know the benefit of VLSM, take a look at how
you can use it in a network.
There are a few restrictions you need to consider when planning to use VLSM:
1. You need to use routing protocols that support classless routing such as Enhanced
Interior Gateway Routing Protocol (EIGRP), Open Shortest Path First (OSPF), Border
Gateway Protocol (BGP) or Routing Information Protocol (RIP) version 2. Classful
protocols such as RIPv1 cannot be used with VLSM. While routing protocols are covered
in detail in Chapter 4, you should understand that a routing protocol is classful because it
does not advertise the subnet mask along with the network address in its updates. Hence,
routers running these protocols, do not know the subnet mask and strictly follow the class
of the network. Classless protocols on the other hand advertise and understand subnet
masks.
2. You need to use fixed block sizes. You have come across these block sizes during
subnetting practice and these are listed in Table 2-9. You cannot use any block sizes apart
from these. For example in Figure 2-2, for the networks connected to RouterB and
RouterC, a block size of 32 was used even though the total addresses required were 21 in
each subnet.
When designing a network using VLSM, the following simple steps can help come up with an
appropriate addressing scheme:
1. Start by finding the largest subnet in your network. The number of host addresses needed
decides the size of the subnet.
2. Next assigning an appropriate mask to the largest subnet using the block sizes mentioned
in Table 2-9.
3. Note the subnet numbers remaining with the mask used in Step 2.
4. Take the next available subnet and subnet it further to accommodate your smaller
subnets.
5. Write down your new subnet numbers again.
6. Repeat step 4 and 5 for smaller segments.
Consider the example shown in Figure 2-2 and work through the above steps to see how the
network address and subnet mask was found for each segment:
1. The largest segment in Figure 2-2 is attached to RouterD. It requires 30 host addresses,
including the router interface (29 host addresses and 1 router interface). So we can use a
/27 mask which gives us exactly 30 host addresses. We assign 192.168.1.0/27 to that
subnet.
2. Our new subnets using /27 mask are 192.168.1.0/27, 192.168.1.32/27, 192.168.1.64/27,
192.168.1.96/27, 192.168.1.128/27 etc.
3. Next we look at the smaller subnets. The subnets attached to RouterB and RouterC
require 21 host addresses (20 host addresses and 1 router interface). The block size we
can use for them is 32. We already have subnets available with /27 mask, so we simply
assign them to these segments – 192.168.1.32/27 and 192.168.64/27.
4. Our next smaller segment is the one attached to RouterA. It requires 14 host address, so a
block size of 16 or a mask of /28 can be used. So we take the next available subnet,
192.168.1.96/27 and subnet it further using a /28 mask. This gives us 192.168.1.96/28
and 192.168.1.112/28. We assign the first of these to this segment – 192.168.1.96/28.
5. Finally we have the three point-to-point segments between the routers. Each requires 2
host addresses hence a block size of 4 and a mask of /30. We take our available subnet –
192.168.1.112/28 and subnet it further using a mask of /30. This gives us
192.168.1.112/30, 192.168.1.116/30, 192.168.1.120/30 and 192.168.1.124/30. We use
the first three for these segments – 192.168.1.112/30, 192.168.1.116/30 and
192.168.1.120/30.
Consider Figure 2-3 as another example. Using a class C network of 192.168.10.0/24 design a
VLSM solution to accommodate host requirements of all the segments.
1. The largest segment requires 125 host addresses. So a mask of /25 can be used. This
gives two subnets – 192.166.10.0/25 and 192.168.10.128/25. The first subnet can be
assigned to this segment.
2. The second largest segment requires 60 host addresses. You can take the second available
subnet – 192.168.10.128/25 – and divide it further using a /26 mask to give you subnets
192.168.10.128/26 and 192.168.10.192/26. Assign the first one to this segment.
3. The third largest segment requires 29 host addresses (28 host addresses and 1 for the
router interface). You will need to use a block of 32 and a mask of /27. Take the
remaining subnet from the previous step and divide it further using a /27 mask. This will
give you subnets 192.168.1.192/27 and 192.168.1.224/27. Assign the first one to this
segment.
4. The fourth largest block requires 13 host addresses (add one for the router interface). You
can use a block of 16 and a mask of /28. Take the remaining subnet from the previous
step and divide it further using a mask of /28. This will give you subnets
192.168.1.224/28 and 192.168.1.240/28. Assign the first one to this segment.
5. Now you are left with 3 point-to-point links between the routers. These links require two
host addresses and a mask of /30. Take the remaining subnet from the previous step and
divide it using a mask of /30. This will give you subnets 192.168.1.240/30,
192.168.1.244/30, 192.168.1.248/30 and 192.168.1.252/30. Use the first three of these for
the point-to-point links. The remaining one subnet can be left for future use.
Route Summarization
You already know from the previous chapter that routers function by creating a
table of all networks it knows about. This table is called the routing table and
routers use routing protocols to tell each other about the networks they know
of. As networks increase, so do the number of entries in a routing table. Large
routing tables cause increased processing and lower response time in a router.
To reduce the size of routing tables, networks can be grouped together or
summarized using a mask that incorporates them all. For example, in figure 2-
5, a 192.168.10.0/24 subnet has been divided into smaller subnets of /27 mask.
All of these networks connect to RouterA which it turn is advertising these
routes to RouterB. Without summarization, RouterB will come to know of 8
networks which are available via RouterA. Since these networks are contagious
subnets can have been subnetted from a /24 address, they can be summarized
back into 192.168.1.0/24 network by RouterA while advertising to RouterB.
This way, RouterB comes to know of one large /24 network only instead of 8
smaller /27 networks.
1. You can only summarize in the block sizes you learned about in VLSM –
128,64,32,16,8,4.
2. The network address used for the summarized address is the first network
address in the block.
Take another example, 172.16.0.0 through 172.16.35.0. This one is not as simple
as the first one. Notice that you have 36 networks to summarize which does not
conform to the block sizes. There are two things that you can do here:
The correct answer depends on the network. If you are planning to add
networks 36 to 63 then the second options works. Otherwise the first option is
the best one.
Take a third example where you know the summary address of 172.10.16.0
with a mask of 255.255.224.0 and need to find which networks are being
summarized. This is really easy. The third octet is the interesting octet and
gives a block size of 32. This means the networks 172.10.16.0 through
172.10.47.0 have been summarized.
192.168.1.0/25
192.168.1.128/25
192.168.2.0/24
192.168.3.0/24
192.168.4.0/26
192.168.4.64/26
192.168.4.128/26
192.168.4.192/26
Try to figure out the summary address that can be used for these networks. If
you look carefully the third octet forms a contiguous block of 4 and can be
summarized with the address 192.168.1.0 255.255.252.0 or 192.168.1.0/22.
Troubleshooting IP Addressing
IP Addressing is an integral part of networking and given the complexity of
addressing and subnetting, it is common to have IP addressing errors in the
network. So it is essential for you to be able to troubleshoot common problems
related to IP Addressing. Before troubleshooting a network, you have to
understand the below given common protocols and utilities that are used to
troubleshoot:
Packet InterNet Grouper (PING) – Ping is one of the most commonly used
utility that is used to troubleshoot addressing and connectivity problems.
This utility is available in almost all operating systems, including Cisco
devices and can be accessed by the command line interface using the ping
command. It uses the ICMP protocol to check if the destination host is
live or not.
Traceroute – Traceroute is another common utility that is available with
all operating systems. In some operating systems the utility can be access
using the tracert or traceroute command on the CLI. It is used to find
each hop between the source and destination hosts and is useful to see
the path taken by a packet.
ARP table – Sometimes it is useful to look at the ARP table of a system.
This table contains the MAC address to IP address bindings learned by
the system. On most operating systems the ARP table can be viewed
using the arp –a command. On a Cisco device the arp table can be viewed
using the show ip arp command.
IP config – Sometimes, you need to verify the IP address, subnet mask,
default gateway and DNS addresses the host is using. On a windows
machine all this information can be seen in the output of the ipconfig /all
command. On a unix based system, this information can be seen using
the ifconfig command.
For the following section consider the network shown in Figure 2-6. In this
network, HostA is trying to reach ServerA and ServerB but is not able to.
1. Ping 127.0.0.1, the loopback address from the Host. You will need to open a
terminal window of your operating system to use the ping utility. If you get an
output similar to the following, it shows that the IP stack in the host is working
well:
ping 127.0.0.1
2. Ping the IP address of the host itself. If its successful then it shows that the
host’s NIC is working well.
>ping 192.168.1.50
3. Ping the default gateway from the host. If the ping works it shows that your
host is able to communicate with the network and the default gateway.
>ping 192.168.1.1
4. Finally ping the remote host, ServerA or ServerB in our case. If the ping is
successful, this means there is a DNS or application layer protocol problem
between the host and ServerA. However, in our case the ping fails.
>ping 192.168.2.65
Now that you have used the Cisco recommended way to determine that the
problem lies in the network, it is time to look at the addressing. In this exercise,
you need to look at the IP address, subnet mask and default gateway configured
(as shown in Figure 2-6) to see if they are correctly configured. You can simply
look at the subnet mask and see which are valid host addresses in that subnet to
see if valid IP addresses have been configured. Take a step-by-step approach as
shown below to narrow down the problem area:
If you are careful about going step-by-step and finding out valid addresses in
each subnet, you can figure out any addressing problem in no time. Lets take a
look at another example two examples. For these examples, we will use the
network shown in Figure 2-7.
Problem: Host B is able to reach HostD but it is not able to reach HostA
Solution: The question tells us two things. First that HostB is able to reach
HostD, that means the network from HostB all the way to HostD is working
fine. Second, HostB is not able to reach HostA. It is simple to figure out that
there is a problem at HostA. To find the problem, take a look at the IP address
information given for HostA:
Example #3
Solution: Again this problem statement tells us that the network from HostD to
HostB is working well. So the problem requires a look at HostC’s addressing:
1. Again, a mask of /27 gives us subnets 0, 32, 64, 96, 128 and so on.
2. HostD and RouterB’s addresses lie in the 192.168.1.64/27 network. The
valid host addresses for this subnet are 192.168.1.65-94. The broadcast
address for the subnet is 192.168.1.95.
3. The next subnet is 192.168.1.94/27 that has a valid host range of
192.168.1.95-192.168.1.127.
4. You will notice that the IP address of HostC lies in the 192.168.1.94/27
subnet and not the 192.168.1.64/27 subnet. It lies it a different subnet
that the default gateway (RouterB) and HostD. Hence, HostD is not able
to reach HostC.
Broadcast Addresses:
Layer 2 broadcasts – These broadcasts are sent at layer 2 and are limited to
a LAN. These do not cross the boundary of a LAN, which is defined by a
router.
Layer 3 broadcasts – These broadcasts are sent at layer 3 and go to the
network.
You already know what unicast and multicast are but just to put them into
perspective of broadcasts, these terms are defined below again:
Unicast – Messages or data sent to a single host are called unicast.
Multicast – Messages or data sent to a group of devices is called multicast.
Like broadcasts, broadcast addresses also differ based on the layer. The different
types are discussed below:
A good example to understand how broadcast addresses are used, consider the
following example of how a host requests IP address from a DHCP server:
When a host boots up and needs to get an IP address from the DHCP
server, it does not know if the DHCP server in this same LAN segment or
across a router. So it sends a DHCP request with the destination IP
address set to 255.255.255.255 and the destination MAC address set to
FF.FF.FF.FF.FF.FF
The layer 2 broadcast goes out to the LAN and if a DHCP server is
connected to the segment, it will respond back.
If the DHCP server is not on the segment, the router will see the packet
and covert it into a unicast message and send it to the DHCP server. The
router needs to be configured for this though.
The DHCP will reply back with a unicast.