Ezzeldin Shereen
Ming Zeng
Peiyue Zhao
Introduction
2. Each lab session is four hours long. Students are welcome to take 10 minutes break during the session when
they consider convenient.
6. Please keep your lab position organized and clean, and ensure that the equipment is in the same state (or better)
as when you started.
3
1.5. Notation used in the manual
Before the laboratory session: The first thing that you should do is to read the manual completely and start studying
the concepts explained in the ‘Before the session’ sections. Your understanding of these concepts will be tested in the
homeworks.
During the laboratory session: While you are in the lab you must have a copy of the lab manual and your solved
homeworks, and perform the different tasks specified. Each of the tasks contains questions that you have to answer.
To pass the lab, students must successfully complete all tasks.
You must also read this part of the manual before you attend the lab, so that you are familiar with the tasks and
their questions. You will not have time to read the manual during the lab!
• Parameters inside square brackets are optional and if applied should be written without the square brackets.
Example of syntax in this manual:
ping [-LRUbdfnqrvVaA] destination
1.6 Credits
Parts of this lab manual have been transcribed literally or with small modifications from the white paper ’Understand-
ing IP addresses: everything you ever wanted to know’ by Chuck Semeria (
3Com c corporation), used with kind
permission of 3Com, and from different Linux HOW–TO’s and manuals. Previous versions of this manual were writ-
ten/edited by Ignacio Más Ivars, Evgueni Ossipov, Héctor Velayos, Mikael Rudholm, Ognjen Vuković and Ljubica
Pajević.
Laboratory Manual 4
Chapter 2
5
2.2. Equipment description Before the session
particular diagram. Thus, it can represent an unspecified network media or whole networks, which is its normal usage.
Additional information can be included in the diagram using alphanumeric strings, like IP addresses, host names or
device ports. The next section contains some network diagrams that will be used during the lab. At the same time,
these diagrams are good examples for the brief notes just introduced.
Laboratory Manual 6
2.2. Equipment description Before the session
Laboratory Manual 7
2.2. Equipment description Before the session
Laboratory Manual 8
2.2. Equipment description Before the session
following the 568B standard. A straight-through cable must be used to connect the Ethernet ports of a switch to PCs
or routers. It has both RJ45 plugs wired following the 568B standard. The only way to identify whether an Ethernet
cable is a crossover or straight-through cable is to check the color code at both ends.
More information about Ethernet cables and how to make them can be found at http://www.duxcw.com/
digest/Howto/network/cable/cable5.htm. General information about connectors, pin-outs, cables and
adapters can be consulted at http://www.hardwarebook.net/.
A different cable must be used to connect a PC to the console port of a Cisco device. The console port is a serial
port, and it must be connected to the PC USB port. The console port is a RJ45 jack while the PC has a USB port. To
connect both ports properly, we will use the USB to DB9 adapter, the DB9 to RJ45 adapter, (see Figure 2.9 and 2.7)
and a new type of cable known as roll-over cable. A roll-over cable also uses 8 wires with RJ45 plugs on both ends,
but it is different from the straight-through or crossover cables. In a roll-over cable, the pins on one end are reversed
on the other end. Thus pin 1 on one end connects to pin 8 on the other end. Pin 2 connects to pin 7, pin 3 connects to
pin 6 and so on. Figure 2.8 shows a roll-over cable.
In addition to these cables, there is permanent cabling in the lab room that you will need to use to connect the
router’s outer interface to the departmental backbones. The permanent cables run in the tables and floor, and link each
lab position with the lab’s cabling rack. The cabling rack is in front of the lab room (to your left). It contains the
departmental switches and a patch panels below them. Figure 2.10 shows the interior of the cabling rack.
Each switch has a label indicating to which departmental backbone it belongs. The patch panel has two rows
of sockets: the top and the bottom row. Each socket on the panel connects to a similar socket by the tables, which
are marked with a blue label and text LABBNÄT, Figure 2.11. The label indicates to which of the panel sockets a
particular socket is connected to. For example, 17B corresponds to the socket 17 on the bottom row (T stands for top,
B for bottom). The connection between the sockets in the patch panel and by the tables is equivalent to straight-through
cable.
The connection of the router’s outer interface to the departmental backbone requires two straight-through cables.
Use one to connect the router’s outer Ethernet interface to one of the blue-label sockets by the table. Use the other to
connect the socket in the patch panel with the same label to any port of the appropriate departmental switch.
2.2.2 Switches
The switch you will use in the lab is a Cisco Catalyst 3512 XL. In the front it has twelve 10/100 Ethernet switched
RJ45 ports plus two additional Gigabit Ethernet slots. The Ethernet ports will be used to connect the equipment of the
area network. The Gigabit slots will not be used in this lab. In the back it has the RJ45 console port for its configuration
and the three-pin power supply socket. It does not have a power switch, the equipment is turned on when connected
to the power supply. Each port is labeled on the box with a name, which it is also used to identify the port in the
configuration menus. Figure 2.13 shows the front and Figure 2.14 shows a closer view of the Ethernet ports in the
front. Note that each port is given a number, with number one in the top left corner. The number allows identification
of the ports in the configuration file, but there is no difference in the behavior of the ports. Any of them can be used to
connect equipment to the switch.
Laboratory Manual 9
2.2. Equipment description Before the session
Figure 2.10: Switches and patch panel in the lab cabling rack.
Laboratory Manual 10
2.3. Cisco software Before the session
There are additional switches inside the cabling rack. You will use them to connect your router to the departmental
backbone, but you do not have to change their configuration.
2.2.3 Routers
The router you will use in the lab is a Cisco 2621. All its ports are situated in the
back. It has two 10/100 Ethernet RJ45 ports, a RJ45 console port for its configuration,
a three-pin power socket and a power switch. Each port is labeled in the box with
a name, which it is also used to identify the port in the configuration file. Since the
router forwards packets between its ports, it is very important to connect each network
to the proper port. Figure 2.15 shows the front and Figure 2.16 shows the ports in the
back. Figure 2.12: A Raspberry Pi.
2.2.4 Terminals
A Raspberry Pi running Linux will be used as the terminal in the lab. The Raspberry Pi has functionalities as a regular
personal computer, therefore we refer to the Raspbery Pi as PC in this lab manual. The Raspberry Pi has various
ports, and its most important ports for this lab are the 10/100 Ethernet RJ45 port and the USB ports. Figure 2.12
shows the ports of the Raspberry Pi at the lab. To use the Raspberry Pi, each group needs to prepare a laptop to be
remotely connected to the Raspberry Pi. For more information, please refer to Section 2.8. The Raspberry Pi will fully
work as a PC in the lab. Each area network has a PC, which will be used as the network server for the area network.
Additional laptops can be connected to the area network. These laptops must have a RJ45 Ethernet port. This port will
be connected to any free port in the switch to join the area network.
Laboratory Manual 11
2.3. Cisco software Before the session
Figure 2.14: Ethernet ports in the front-left of the Cisco Catalyst 3512 XL.
Laboratory Manual 12
2.3. Cisco software Before the session
discover that the way the switch is configured is similar to that of the router, but some commands are different. You can
find these commands in a document called "Cisco IOS Desktop Switching Command Reference" available on Canvas.
If you need information on a particular command, you can look it up at http://www.cisco.com/c/en/us/
td/docs/ios/fundamentals/command/reference/cf_book.html. Before the lab, it is enough that
you read section "Using the command-line interface" of the switch manual. Note that it is similar to that section in the
router configuration. Since we will not configure complex functions in the switch during this lab, you do not have to
study deeply any of the switch commands. After reading this information about the switch, read below section 2.3.2
which describes how to start up the switch. You will start up and initially configure the switch during the lab.
Starting Up The switch will start booting as soon as the power supply is connected, since there is no power switch.
It is important to connect the management console before the switch is powered on, so it will display the messages
generated during the start up process. For the initial configuration, there is no need to connect any cable to the Ethernet
ports.
When the switch starts up, it begins POST, a series of eight tests that run automatically to ensure that the switch
works properly. When the switch begins POST, the port LEDs turn amber for 2 seconds, and then they turn green.
The System LED flashes green, and the RPS LED turns off. As each test runs, the port LEDs, starting with number 1,
turn off. The port LEDs for ports 2 to 8 each turn off in turn as the system completes a test. When POST completes
successfully, the port LEDs return to the status mode display, indicating that the switch is operational. If a test fails,
the port LED associated with the test turns amber, and the system LED turns amber as well.
To initiate the start-up configuration of the switch, send a break command from your terminal program. Then you
should see the initial configuration screen of the switch.
Using the Setup command of the Command Line Interface The command setup from the set of privileged com-
mands is used to assign IP information and to create a default configuration for continued operation. When you boot
the switch (or the router) for the first time, there is no configuration so you will be asked whether you want to enter
the "initial setup dialog". Answer yes and you will be configuring everything from scratch. If this question does not
appear, it means that some configuration was found. In this case, you will have to start the setup procedure from the
privileged mode using these commands:
Switch> enable
Password: passwd
Switch# setup
Continue with configuration dialog? [yes/no]: y
The password should be "qwerty". The setup procedure consists of a sequence of questions that you should answer.
This information is used to create the initial configuration. After the last question, this initial configuration is shown,
so it is possible to review it before saving. Here are the questions and the suggested answers:
Laboratory Manual 13
2.3. Cisco software Before the session
Question 4: Enter the IP address of your switch’s default gateway and press Return:
Question 5: Enter a host name for the switch and press Return:
Question 6: Enter a secret password (which ensures switch security) and press Return:
Question 9: You would enter Y to configure this switch as the cluster command switch. Enter N to configure it as a
member switch or as a stand-alone switch.
Question 10: Verify that the addresses are correct in the initial configuration displayed:
Question 11: If the information is correct, enter y at the prompt and press return to use it. When you see the message
"Press RETURN to get started", the setup program is complete. If the information is not correct, enter n at the
prompt, press Return, and begin again at Question 1.
Laboratory Manual 14
2.3. Cisco software Before the session
Starting Up In contrast to the switch, the router will not boot when the power supply is connected. It will boot
when the power switch in the back part is set to on. It is important to connect the management console before the
router is powered on, so the console will display the messages generated during the start up process. For the initial
configuration, there is no need to connect any cable to the Ethernet ports.
When the router starts up, it performs the POST without producing external signals. When POST completes
successfully, the bootstrap program is loaded from ROM into the RAM. This process produces the first messages in
the console. After bootstrap is loaded, it searches and loads the Cisco IOS. In our case, this software is retrieved from
the internal flash memory, decompressed and loaded into RAM. More messages appear in the console reporting the
evolution of these steps. When it is successfully loaded, the router’s configuration file is searched and loaded.
When you boot the router for the first time, there is no configuration file, so you will be asked whether you want
to enter the "initial configuration dialog". Answer "yes" and you will be configuring everything from scratch in the
set-up mode. If this question does not appear, it means that the router found some configuration. In this case, you
will have to start the initial configuration procedure from the privileged mode using the setup command as described
below:
Router> enable
Password: passwd
Router# setup
Continue with configuration dialog? [yes/no]: y
Initial configuration dialog The set up procedure consists of a sequence of questions that you should answer. This
information is used to create the initial configuration. After the last question, this initial configuration is shown, so it
is possible to review it before saving. Here are the questions and the suggested answers:
After these two questions, the configuration of the global parameters begins:
Laboratory Manual 15
2.3. Cisco software Before the session
Now the configuration of the interface parameters begins. The FastEthernet 0/0 port is first:
Question 13: Answer "yes" to configure FastEthernet 0/0 interface
Do you want to configure FastEthernet0/0 interface? [yes]: yes
Question 14: Answer "yes" to use the RJ45 connector in the back part of the router
Use the 100 Base-TX (RJ-45) connector? [yes]: yes
Question 17: Type the proper IP address for this interface in dotted-decimal format. The network diagram should
help finding out what this address should be. We have included an IP address as an example of the expected
answer.
IP address for this interface: 192.168.0.129
Question 18: Type the proper mask in dotted-decimal format corresponding to the previous IP address. We have
included a mask as an example of the expected answer.
Subnet mask for this interface: 255.255.255.0
After this question, similar questions will appear to configure the second FastEthernet interface of the router.
Answer them in the same way you did with the questions for the other FastEthernet interface. Mind that the IP address
and possibly the mask should be different for this second interface.
After this set of questions on the second FastEthernet interface, the initial configuration is generated and displayed
for you to verify it. The screen should look similar to this:
The following configuration command script was created:
hostname Router
enable secret 5 $1$EDYp$8IwOwl7TATzo8lYdAeuIV1
enable password lab
line vty 0 4
password qwerty
no snmp-server
!
ip routing
no bridge 1
!
interface FastEthernet0/0
media-type 100BaseX
full-duplex
ip address 192.168.0.129 255.255.255.0
!
interface FastEthernet0/1
media-type 100BaseX
full-duplex
ip address 192.168.0.26 255.255.255.0
dialer-list 1 protocol ip permit
dialer-list 1 protocol ipx permit
!
end
0 Go to the IOS command prompt without saving this config.
1 Return back to the setup without saving this config.
2 Save this configuration to nvram and exit.
Enter your selection [2]:
Check the configuration, especially the IP addresses and masks, and if everything is correct, answer "2" to save
the configuration and exit from the set up mode. If there is some incorrect information, you can answer "1" to repeat
the set up. After you save it, the router is working with your initial configuration. Note that you have not introduced
the static routing table yet, thus the router can only reach directly connected networks. If any static route is needed,
use the router’s command ip route to add static entries to the routing table.
Laboratory Manual 16
2.4. IP: General concepts Before the session
Figure 2.17: The five classes of IP addresses, where the prefix identifies the network and the suffix the
particular host inside that network.
Class A Networks Class A network addresses have an 8–bit network number, which starts with a 0, followed with
a 24–bit host number. Nowadays, class A addresses are referred to as ’/8’, because of their 8–bit network number.
There are 126 (27 – 2) class A networks. We have to subtract 2 because the 0.0.0.0 network is reserved for the default
route and 127.0.0.0 is used for the loopback interface. Each /8 network contains 224 – 2 (16,777,214) hosts. Again, we
subtract two addresses because the all–0s ("this network") and all–1s ("broadcast") host numbers cannot be assigned
to individual hosts. There are in total 231 (2,147,483,648) individual addresses available in class A, which are 50% of
the total IPv4 address space.
Class B Networks Class B network addresses have a 16–bit network number, with the two highest order bits set to
1–0, followed by a 16–bit host number. They are usually referred to as ’/16s’. There are 16,384 (214 ) /16 networks,
with 65,534 (216 – 2) hosts per network. The entire class B address space contains 230 (1,073,741,824) addresses.
Class C Networks Class C network addresses have the three highest order bits set to 1–1–0 and a 24–bit network
number, followed by a 8–bit host number. They are referred to as ’/24s’. There are 254 (28 – 2) hosts per network,
with 2,097,152 (221 ) possible /24 networks, giving a maximum of 229 (536,870,912) addresses.
Laboratory Manual 17
2.4. IP: General concepts Before the session
Table 2.1: Examples of 32–bit addresses and their equivalent in dotted-decimal notation.
Table 2.2: The range of decimal values in the first octet of each class.
Other Classes In addition to the three classes used to identify individual network interfaces, there are two additional
classes: Class D addresses have their four highest order bits set to 1–1–1–0 and are used to support IP Multicasting,
while Class E addresses have their leading four–bits set to 1–1–1–1 and are reserved for future use.
• When the Internet started, IP addresses were allocated to organizations based on simple requests, instead of the
actual needs. The decision to create 32–bit addresses gave only 232 (4,294,967,296) IPv4 addresses available,
which has led to an actual lack of addresses.
• The division of IP addresses based on octet boundaries was easy to implement and deploy, but it created a lack
of proper support for medium-size organizations. A /16, supporting 65,534 hosts, can be too large for this type
of organizations, while a /24, with only 254 possible hosts can be far too small. In the past, sites with several
hundred hosts were assigned a single /16 address, instead of two or three /24 addresses, thus quickly finishing
off the /16 address space. Also, the need to give several /24 addresses to the same organization has increased
the size of the routing tables.
2.4.5 IP sub–netting
In 1985, IETF RFC 950 defined a way to divide single class addresses into smaller pieces. Sub–netting was introduced
to overcome the problems the Internet was suffering with the two–level addressing hierarchy: first, local administrators
had to apply for a new network address before installing a new network at their site; and, second, the Internet routing
tables were beginning to grow to an unmanageable size.
The way to attack these problems was to add a new hierarchy to the addressing scheme. With sub–netting the host
number was divided into two parts, the subnet number and the host number on that subnet, thus creating a three–level
hierarchy.
With the new sub–netting scheme, the subnet structure of a network is not visible outside the organization’s do-
main. This helps reducing the routing tables of the outside routers, as the route to any subnet is the same as all subnets
share the same network number. It is only inside the organization’s private network were routers need to differentiate
Laboratory Manual 18
2.4. IP: General concepts Before the session
between the different subnets to route packets, reducing the complexity of the routing tables to the domain of the local
administrator.
With the new scheme, a site with several logical networks uses subnet addressing to cover them with a single /16
(Class B) network address. This concept is sometimes called super–netting. The router accepts all traffic from the
Internet to network 132.5.0.0, and forwards traffic to the interior subnetworks based on the third octet of the address.
• How many hosts can the largest subnet contain in the future?
The first step to perform is to take the maximum number of subnets required and round that value up to the closest
power of two. This computation should take into account the possible growth of the network. For example, if we need
11 subnets, then 23 will not provide enough subnets, so we will have to round up to 24 . This will give us three extra
subnets for our organization to grow.
The second step is checking the number of hosts that we will need in the largest subnet. Imagine that we will need
26 hosts. If this is the case, then we will need at least 25 (or 32) addresses.
Finally, we have to check the address space of our organization to see if we have enough bits to deploy the required
sub-netting plan. For example, with a single /16 address, we could have four bits for the subnet number and five bits
for the host number. If we instead have several /24s and we want to have 11 subnets, then we will have to subnet each
/24 into four subnets (with two bits of subnet number) and then combine three of them to get the required topology.
Laboratory Manual 19
2.4. IP: General concepts Before the session
Obtaining the Subnet Mask: To obtain the number of bits required for our six subnets, we need to create them in
blocks of powers of two. To define six subnets, we need, thus, 8 (23 ) subnets and we will have two free subnets for
future use. To enumerate our eight subnets, we will need to use three bits. In our example, we have a /24 address, so
we will have /27 as the extended network number length, which gives a network mask of 255.255.255.224
When we have /27 subnets, we are allocating five more bits for the host number, so we have 25 (32) individual IP
addresses in each subnet. However, there are only 30 (25 –2) possible host addresses on each subnet, as the all–0s and
all–1s host addresses cannot be used.
Obtaining the Subnet Numbers: We will number the eight subnets from 0 to 7, which in binary notation are: 0
(0002 ) to 7 (1112 ). To define subnet n, we place the binary representation of n into the bits of the subnet number. The
eight subnet numbers for this example are given in Table 2.4.
The eight subnet numbers for this example are given in Table 2.4. The bold portion of each address identifies the
network number, while the underlined digits identify the 3–bits representing the subnet-number field:
The Reserved Subnets: The initial definition of sub–netting prohibited the use of the all–0s and the all–1s subnets.
The reason was to avoid possible confusions in the original classful routers. Nowadays, routers can be running classful
and classless protocols at the same time.
The all–0s subnet, originally defines the entire network, so a router needs that each routing table update include the
route/<prefix-length> pair to differentiate between a route to the all-0s subnet and a route to the entire network. If we
are using a classful routing protocol, the routing advertisements for subnet 193.1.1.0/27 and for network 193.1.1.0/24
are identical – 193.1.1.0, so without knowing the network number length, or the netmask, a router will not be able to
differentiate between them.
The problem with the all–1s subnet is exactly the same. Routers need to have the network number length so that
they are able to determine if a broadcast (directed or all–subnets) should be sent only to the all–1s subnet or to the
entire network. For example, when the routing table does not contain a mask or prefix–length for each route, confusion
can occur because the same broadcast address (193.1.1.255) is used for both the entire network 193.1.1.0/24 and the
all–1s subnet 193.1.1.224/27.
The new classless routing protocols contain the mask or length with each route, so the all–0s and all–1s subnets
can be used again. Of course, the other routers in the organization’s network need to be able to correctly interpret,
learn, and forward traffic to other subnetworks with all-0s and all-1s in their subnet number field.
Defining Host Addresses for Each Subnet The host-number field of an IP address cannot contain all 0–bits or all
1–bits. The all–0s host number identifies the base network (or subnetwork) number, while the all–1s host number
represents the broadcast address for the network (or subnetwork).
In our current example, there are 5 bits in the host number field of each subnet address. This means that each
subnet represents a block of 30 host addresses (25 –2 = 30, note that the 2 is subtracted because the all–0s and the
all–1s host addresses cannot be used). The hosts on each subnet are numbered 1 through 30.
In general, to define the address assigned to Host n of a particular subnet, the network administrator places the
binary representation of n into the sub-net’s host number field. For example, to define the address assigned to Host
15 on Subnet 2, the network administrator simply places the binary representation of 15 (011112 ) into the 5–bits of
Subnet 2’s host number field.
The valid host addresses for Subnet 2 and 6 in our example are given in Table 2.5. The bold portion of each address
identifies the extended-network-prefix, while the underlined digits identify the 5-bit host-number field:
Defining the Broadcast Address for Each Subnet The broadcast address for Subnet 2 is the all 1’s host address or:
11000001.00000001.00000001.01011111 = 193.1.1.95
Laboratory Manual 20
2.4. IP: General concepts Before the session
A B
Network 192.168.0.X
192.168.0.R
192.168.0.A 192.168.0.B 192.168.0.C R
192.168.1.R
Network 192.168.1.X
C D
Network 192.168.0.X 192.168.1.C 192.168.1.D
Figure 2.18: An IP network on one Ethernet segment. Figure 2.19: Two IP networks on two different Eth-
ernet segments.
Note that the broadcast address for Subnet 2 is exactly one less than the base address for Subnet 3 (193.1.1.96).
This is always the case – the broadcast address for Subnet n is one less than the base address for Subnet (n+1).
The broadcast address for Subnet 6 is simply the all 1’s host address or:
11000001.00000001.00000001.11011111 = 193.1.1.223
Again, the broadcast address for Subnet 6 is exactly one less than the base address for Subnet 7 (193.1.1.224).
Laboratory Manual 21
2.5. Debugging Before the session
The difference with the previous case is that now A cannot obtain D’s Ethernet address with an ARP request,
because D would never see A’s request, they are in different physical wires! A knows that D is in a different IP
network, so it knows that it must send the packet to R to get it forwarded to the proper destination.
2.4.10 IP routing
Direct or indirect routing
When two machines are on the same network, there is no need to forward a packet between them on the IP layer. In
this case direct routing is used. In the first example, A and C are in the same network, so they know that they can reach
each other just by using the proper Ethernet address.
On the other hand, if the network addresses of source and destination are not the same, then the packet must be
forwarded by a router who knows how to reach the destination. In the second example, if A wants to reach D, it needs
to have some routing information to know where to send the packet to reach D. The way to add routes to the routing
table in a Unix machine is to use the route command.
R needs to have two IP addresses, one for each network interface. A can then know that R is on its network just
looking at the IP address of the interface of R connected to the first Ethernet segment. The same way, D sees the
second network interface of R and is able to obtain the Ethernet address of this interface. Most of the times it is not
necessary to manually add the routing entry for the other Ethernet segment. It is sufficient to have R as the default
gateway, which is the machine to send the packets addressed to machines out of my network segment. Of course, the
default gateway needs to have a routing table properly configured to forward the packets to the correct destinations.
2.5 Debugging
2.5.1 General model: top down or bottom up approaches
The main tasks of a network administrator are to keep a network running and to fix it in case of failure. Basically these
tasks can be decomposed in the following set of subtasks.
Laboratory Manual 22
2.5. Debugging Before the session
In general one can discover that a failure occurs by simple facts like: you cannot open a web page, you cannot
print on the network printer, you cannot make a remote connection to a distant computer. . . . In this case you, as the
network administrator, should perform certain steps to discover why these strange things are happening. You can use
two general approaches to find out the reason of the failure and to locate the place of the problem in the network.
These two approaches are called Top-Down and Bottom-Up. From the name of the approaches you can understand
that you should check the work of the network on the different levels starting from application level to physical in the
top-down approach, or from physical to application layer in the bottom-up approach. Recall the main layers in the
TCP/IP stack.
Physical layer - On this layer you can check whether the cabling is made correctly. Check that all cables are properly
connected to the network cards. And in the far end check that a network device (your PC, router etc) is powered
ON!
Link layer - On this layer you can check the link layer configuration, status, and statistical information of the network
interfaces. In the PC’s for this purpose you can use the command ifconfig. This command will provide you with
necessary statistics of the interface usage and its current status. You will find in the next subsection a description
on how to use this command. One of the possible problems at the link layer can be an automatic disabling of
the network interface due to incorrect cabling. In this case when executing ifconfig in the PC you either will
not see the record about the problematic interface at all, or in the status field (see the output of ifconfig in the
next subsection) will be written “DOWN”. In the switches and routers the command to see the status of the
interfaces is show interfaces, but the meaning of these commands is exactly the same as of ifconfig. To fix
the problem on this level first check that the cabling is correct. Then, bring the interface up manually with the
proper commands.
Network layer (IP) - The typical problem on this layer is an incorrect IP configuration of the network interface. The
sequence of your actions to fix the problem should be:
1. Check if the network interface is configured with the proper IP address and network mask.
2. Test the configuration by checking if you can communicate with other network devices.
3. If the problem remains repeat from the configuration.
There are different commands to check the IP configuration of the interfaces in PC’s, switches, and routers. For
example in the PC’s use for this purpose ifconfig. Another item which is included in the term “IP configuration”
is proper configuration of the routing table. In the PC’s, for example, you can use the command route for this
purpose. Check the next subsection for details of usage of these commands.
In order to test the correctness of the step one, the easiest way is to use the ping command which exists in all
network devices (so in the simplest case the syntax of the command is common for PC’s and Cisco devices).
Check if you can ping a machine (a PC or a router) which you know for sure that it is up and running. If you
can not ping this machine repeat the configuration step.
If you checked the configuration and you are 100% sure that it is correct but ping still does not work, maybe the
problem is not in your PC, but in an intermediate device (e.g. router). The way to locate the erroneous device is
to use the traceroute command (which again exists both in the PC’s and the Cisco devices). If you find out that
one of the routers which you have an access to configure is not responding, apply the same approach to locate
and fix the failure in this router.
Transport layer - On this level you can try to establish a TCP connection to a particular port and check whether
it works or not. For this purpose you can use the telnet program on your PC in the form: telnet destina-
tion_IP:port_number. The possible reason of the failure on this level could be a special set of rules in your PC
which forbids an access to certain IP addresses and/or TCP/UDP ports. This kind of filtering has the name "IP
firewalling". Check the firewalling rules for correctness.
Application layer - On this layer you can discover that something is going wrong by observing whether your ap-
plications work as they should. Most probably, applications will generate meaningful errors when they cannot
work. The error message is the best hint to find the problem. Read it carefully and make sure you understand it.
Read the application manual if needed.
Laboratory Manual 23
2.6. Tools and commands in the PC Before the session
ifconfig The first action you should performs when you are trying to connect your computer to the Internet is to
configure your network interface (network card). Basically you should be able to:
The syntax of the command when you would like to assign IP parameters is
In the case you run ifconfig without arguments, you will get a summary of the configuration of the interfaces
which are up, like the one you can see below:
As you can notice from the output, the first line gives you information about the link layer; the second and the
third show IP configuration; the fourth line gives you a status of the interface; and finally, the next three strings
show the interface usage statistic. In the lab you will use this command with or without arguments. You can
find information about other arguments and options of this command typing in the terminal window:
man ifconfig
Ping Sometimes the connection to a remote machine cannot be established. This could be due to several reasons.
One of these reasons could be network failure at any part of the network. If you cannot connect to a specific
computer how do you know whether it is due to network failure, the computer being down or perhaps some error
in a program running on the computer? As a first step you could try to figure out if the computer is reachable
through the network. For this purpose you could use the ping program available on most networked systems.
Ping simply sends a number of special packets, called ECHO REQUEST packets, to the destination computer.
When the destination computer receives these packets it is supposed to send back ECHO REPLY packets. Your
ping program will display the received ECHO REPLY packets. These types of packets are part of the ICMP
protocol which ping uses. The syntax of this command is
ping Name_of_the_machine
One option that might be useful to use in this command is “- n”. With this option the ping will produce only
numeric output, without trying to resolve symbolic names for host addresses. This option is useful in the case
when DNS is not working. If this option is not specified the ping trying to resolve a name will block the terminal
window for some tens of seconds. The syntax of the ping in this case is:
ping -n Name_of_the_machine
Laboratory Manual 24
2.6. Tools and commands in the PC Before the session
Traceroute The Internet is a large and complex aggregation of network hardware, connected together by gate-
ways/ routers. Tracking the route your packets follow to their destination (or finding the miss-configured
router that throws away your packets) can be difficult. The command traceroute utilizes the IP protocol TTL
(time to live) field which is decremented by every router a packet passes through. When this counter is zero
the packet is thrown away and an ICMP TIME_EXCEEDED packet is sent back to the sender. This ICMP
TIME_EXCEEDED packet contains among other things the identity of the router that dropped the packet. The
traceroute attempts to force such response from each gateway/router along the path to the destination by first
sending a packet with the TTL set to one, then a packet with the TTL set to two and so on until it reaches the
destination. The syntax of this command is:
traceroute Name_of_the_machine
As with ping you can use the option “- n”, which will disable name resolution. The syntax of the traceroute in
this case is:
traceroute -n Name_of_the_machine
Route After you have checked that your interface is configured properly, but you still do not have any response from
ping or traceroute, it is a good time to check that the routing information in your PC is correct. You can check
the content of the routing table by typing
route
in the terminal window. You will see the output of this command like the one below.
[lab@localhost lab]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.213.0 * 255.255.255.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default itguest-gw.gues 0.0.0.0 UG 0 0 0 eth0
If your PC has one network card the routing table will consist of three records: the route to your network, the
route to the 127.0.0.0 network, and the default route. When sending packets to an IP address that is inside of
your own network, your PC will use the first record; for the packets which destination is outside of your network
the PC will use the third record, and send them to the default gateway. Check the entry corresponding to the
default route (the network address for default route is 0.0.0.0), it should point to the first router in your network.
If you do not have this record or it does not point to the first router, configure the routing table as described in
“During the Laboratory Session” section.
ARP In our lab you will use this command to check the content of the arp table in your PC. The syntax of Arp is:
Arp -a
In this form the command will output the content of the Arp table. You can find more information about usage
of this command executing:
man Arp
Telnet Telnet is a program which allows you to login to a distant device (e.g. computer, router). Use the following
syntax of telnet:
telnet Destination_IP Port_number
Laboratory Manual 25
2.6. Tools and commands in the PC Before the session
telnet Destination_IP
With this syntax telnet will connect you to the default telnet port (TCP port 23).
Network sniffers A network sniffer is a tool that picks up a copy of each and every packet that traverses the commu-
nication link on which your network interface is attached. We will use a sniffer so that you can see for yourself
exactly what is going on when two computers start talking to each other. This will give you a chance to see
how all the protocols and mechanisms you have read about so far interact and work together. There exists many
network sniffer; in our lab we will use a program called “Wireshark”, which is probably one of the most popular
sniffers used for academic purposes. In the next subsection you will find the description of Wireshark.
GUI description
You can start Wireshark from a window manager, or from the command line; in the second case, you can specify
optional settings, such as the interface to capture from, or more advanced settings. This is not necessary to begin with,
so you can just launch the application, select the interfaces and you will see the main window of the graphical interface
(see Figure 2.20), which consists of three panes that you can re-size. Below the panes there is a strip that shows the
current filter and some informational text. The top pane contains the list of network packets that you can scroll
through and select. By default, the packet number, packet time stamp, source and destination addresses, protocol, and
description are displayed for each packet. The ’Columns’ page in the dialog box popped up by ’Edit:Preferences’ lets
you change this (although, unfortunately, you currently have to save the preferences, and exit and restart Wireshark
for those changes to take effect). If you click on the heading of a column, the display will be sorted by that column;
clicking on the heading again will reverse the sort order for that column. An effort is made to display information as
high up in the protocol stack as possible, e.g. IP addresses are displayed for IP packets, but the MAC layer address
is displayed for unknown packet types. The right mouse button can be used to pop up a menu of operations. The left
mouse button can be used to mark a packet. The middle pane contains a protocol tree for the currently selected packet.
The tree displays each field and its value in each protocol header in the stack. You can expand each item and see the
content of the different protocols by clicking the ’+’ sign left to the name of the protocol. The lowest pane contains a
dump of the actual packet data. Selecting a field in the protocol tree highlights the corresponding bytes in this section.
Display filters syntax and how to make the traces more ’attractive’
Display filters help you to remove the noise from a packet trace and let you see only the packets that interest you. If
a packet meets the requirements expressed in your display filter, then it is displayed in the list of packets. Display
filters let you compare the fields within a protocol against a specific value, compare fields against fields, and check
the existence of specified fields or protocols. The simplest display filter allows you to check for the existence of a
protocol or field. If you want to see all packets which contain the TCP protocol, the filter would be ’tcp’ (without
the quotation marks!). Fields can also be compared against values. The comparison operators can be expressed either
through C-like symbols, or through English-like abbreviations as in Table 2.6.
Laboratory Manual 26
2.6. Tools and commands in the PC Before the session
eq == Equal
ne != Not Equal
gt > Greater that
lt < Less than
ge >= Greater than or equal to
le <= Less than or equal to
To create a filter, click on the ’Filter’ button in the left down corner of the main window. In the appearing window,
type the name of your filter (for example ’TCP traffic’) in the ’Filter name’ field. Then, in the ’Filter string’ field,
print the string of your filter, like ’ip.addr eq 130.237.50.78’. Click on ’New’; your filter will be added to the window
of available filters, then click on save to save your filter. To apply your new filter click on the ’Apply’ button. After
you applied your filter you can start capturing. Choose ’Start’ from the ’Capture’ menu and the Capture window will
appear, as shown in Figure 2.21.
In this window you will have to configure your session, and for that you have to activate the live update of packets
in real time and the automatic scrolling, so you are able to see the packets passing by. In addition, you have to select
the monitored interface in the upper most part of the window. Select the interface called "eth0".
Do NOT put anything in the ’Filter’ string! In this string, you are supposed to set ’tcpdump like’ filters. This
type of filters uses different syntax (see the ’tcpdump’ manual page for more information). In fact, you can use either
’display’ or ’tcpdump filters’, or even both of them, but it is enough to use only display filters. Moreover, the syntax
of ’display’ filters is richer and can allow you to do much more than ’tcpdump’ filters. After you configured the
Capture options click ’OK’ to start capturing. After some time, you can stop capturing and analyze the trace. You can
simplify understanding the trace by coloring certain packets. This is good if you want to see for example packets from
a particular host and port number out of all captured packets. For this you need to choose Colorize Display from the
Display menu (note that this item is inactive before you start capturing). Click on New and set the Display filter in
appeared window, with the syntax described above. Choose the foreground and background by clicking on appropriate
button. Then click on ’Apply’, to apply your settings. In Table 2.7 you have some important protocol fields, while
Table 2.8 gives some useful port numbers and Table 2.9 contains some examples.
Laboratory Manual 27
2.6. Tools and commands in the PC Before the session
Laboratory Manual 28
2.7. Linux hints Before the session
2.7.1 Logging in
Unix is a multi-user operating system. This basically means that many people may work on the same computer at
the same time; therefore to work with Linux you have to identify yourself by a process called logging in. When you
switch on your PC the Linux will prompt your user name and password. Depending on the configuration this prompt
can appear either in textual console or in graphical user interface (XWindows). After entering both correct name and
password you are authorized to use the system.
If you work in graphical mode you will see an environment like the one in Figure 2.22 which looks similar to
Microsoft Windows. If you are working in textual mode you will see something like this:
user@live: $
This is a command prompt and you are supposed to write Unix commands after the symbol “$”.
In graphical user interface mode, so go on “Accessories/Terminal” to start a terminal window.
Laboratory Manual 29
2.7. Linux hints Before the session
Another important thing for you to know is the concept of paths. In Linux there is a special system file for each
user which contains the paths to the most used directories. Since the access to some parts of the file system is restricted
for the normal user, there is no path to the programs which are in the /bin and /usr/sbin. If, for example, you have
logged in as a normal user you will not be able to execute traceroute command. In this case you have to specify the
full path to this command (e.g. /usr/sbin/traceroute) to execute it. To summarize the discussion:
• All directories are branching out from the root (“/”)
• The record “/usr/sbin/traceroute” means: The program “traceroute” is in the “sbin” directory, which is in the
“usr” directory. The “usr” directory branches directly from the “root” (“/”)
• The most used programs in our lab have the following paths (try to specify the whole path when you see an error
like bash: name_of_command: command not found):
1. /sbin/ifconfig
2. /bin/ping
3. /usr/sbin/traceroute
4. /sbin/route
You can open as many terminal windows as you want - they will work in parallel. There is however another way
to execute commands. Linux allows switching between graphical mode (XWindows) and textual mode by means of
virtual consoles. Linux by default offers 6 consoles to the user and you can switch between them by pressing the
following sequence of keys: CTRL-ALT-F1 ... CTRL-ALT-F6. When you switch to a console you will see the login
prompt:
localhost login:
After you log in, you will see the command prompt. You can always return to the graphical mode by pressing
CTRL-ALT-F7.
Laboratory Manual 30
2.8. Connecting to Raspberry Pi Before the session
Command Meaning
ls List the content of your working directory
cd [name of a directory] Change the directory
less [name of a file] Display the content of a file (you can use both)
more [name of a file]
cp [file1] [file2] Copy files
mv [file1] [file2] Move files
rm [file1] Remove file (i.e, delete)
Note, that this may be the most useful command in Unix. Use it always when you are unsure about the syntax of
a command. The commands which you will use in the lab are listed in Table 2.10.
You can edit text files using many available text editors like: vi, pico, emacs, or any graphical editor you can find
in XWindows such as gedit.
4. Connect your computer to the wireless network "PiNetX", where "X" stands for the ID of the Raspberry Pi and
can be found on the case of the Raspberry Pi. The password is also available on the case of the Raspberry Pi.
5. Run the VNC Viewer and connect to host 192.168.50.1. The user name and password for login is "pi" and
"raspberry".
Laboratory Manual 31
Tasks During the laboratory session
3. How many link-layer hops do the packets perform from the PC in your LAN to the gateway to the Internet?
(Hint: How many ’cables’ are your packets crossing in Figure 2.3?)
4. How many hops do the packets perform considering ONLY the network layer in the same path? (Hint: How
many IP-level devices are your packets crossing?)
5. Each position in the lab corresponds to an area network of a particular department. Write below the name of the
network you are in and the range of the assigned IP addresses.
• Network address:
• Broadcast address:
• The range of addresses available for the devices in your network:
• Network mask:
6. Figure 2.23 represents the equipment in your area network and part of the departmental backbone. Using figure
2.2 and figure 2.3 as a guide, fill in the IP addresses, names and interface names corresponding to your position.
Assign the IP addresses following the rules given in section 2.1.1.
1. Following the indications of section 2.2, find the router, the switch and the PC server (the Raspberry Pi). Note
that the model name of the Cisco equipment appears in the front top-right corner of the box.
• Search in the Cisco boxes and write down the model series:
2. Start working with the router. Find all its Ethernet ports, its console port, its power switch and its power supply
socket.
3. In the switch, find its Ethernet ports and its power supply socket.
5. Classify the cables in your lab position into crossover, straight-through and roll-over cables. Find also the DB9
to RJ45 adapter and USB to DB9 adapter.
Laboratory Manual 32
Tasks During the laboratory session
Laboratory Manual 33
Tasks During the laboratory session
• The different types of cables in the lab can also be identified by the color of their external covers. Please
write here the color corresponding to each type of cable:
Crossover cable:
Straight-through cable:
Roll-over cable:
Note: The color of the external cover is not standardized at all. Different brands can use different colors for the
same type of cables. Check the color code in the RJ45 plugs to properly identify the type of cable.
• Check the values of your interface by typing ifconfig without options. You should see the configuration
information in the form shown below. Fill in below the missing fields of the ifconfig output:
eth1 Link encap:Ethernet HWaddr
inet addr: Bcast: Mask:
UP BROADCAST RUNNING MULTICAST MTU: Metric:1
RX packets:1217 errors:0 dropped:0 overruns:1 frame:0
TX packets:303 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
Interrupt:11 Base address:0x200
4. Add a route to the default gateway with the route command. The default gateway should be the inner interface
of your LAN router.
route add default gw Address_of_your_router
• Looking at the routing table above, answer the following question (you should not run any command to
answer this question, just look at the table, which you have filled in above).
Suppose you ping a computer inside your network and a computer which is outside of your network. Look
at the routing table of your computer and mark which routing entry is the one that is used to send these
ping packets, both to the switch and a computer outside your network.
Laboratory Manual 34
Tasks During the laboratory session
1. Before starting the initial configuration of the switch, you need to find out the answers to the question that will
appear during the setup process. Most of these answers already appeared in 2.3.2. The IP configuration data
must be obtained from the network diagram for your session (See Figure 2.2 considering the position of the
switch in the network and your IP addressing scheme)
• Fill in the gaps below with the information to be used for the configuration of the switch:
– Switch IP address:
– Switch net mask address:
– Switch default gateway address:
– Switch secret password:
– Switch Telnet password:
• If the switch is a link-layer device and thus independent of the IP layer, why does it require an IP address?
4. Power on the switch. Some messages should be displayed in the console while the switch boots. If there are no
messages displayed, check the connection and configuration of the emulated console.
6. Once you have finished and saved the initial configuration, reboot the switch using the switch’s command
reload.
7. After the switch completes the reboot process, connect the PC Ethernet port to any port of the switch. In the
PC open a terminal window. Execute telnet IP_of_the_Switch to login from the PC to the switch. Display the
configuration of the switch using the proper CLI command. With the information shown, fill in the gaps below.
interface VLAN1
ip address
ip default-gateway
1. Before starting the initial configuration of the router, you need to find out the answers to the question that will
appear during the setup process. Most of these answers already appeared in 2.3.3, but the IP configuration data
must be obtained from the network diagram for your session (See Figure 2.2 considering the position of the
router in the network and your IP addressing scheme).
• Fill in the gaps below with the information to be used for the configuration of the router:
– FastEthernet 0/0 IP address:
– FastEthernet 0/0 subnetwork mask address:
– FastEthernet 0/1 IP address:
– FastEthernet 0/1 subnetwork mask address:
Laboratory Manual 35
Tasks During the laboratory session
4. Connect the router Fast Ethernet ports to the corresponding switch ports. Remember to use the proper type of
Ethernet cable. Refer to Figure 2.3 to find out which ports of the router should be connected to each network.
5. Power the router on. Some messages should be displayed in the console while the router boots. If there are no
messages displayed, check the connection and the configuration of the emulated console.
7. Once you have finished and saved the initial configuration, add the static routes of the table above using the "ip
route" command. The parameters to this command can be discovered using the question mark character in the
CLI while in configuration mode.
8. Once you have added the routing table save the configuration with the copy command. Use the proper parame-
ters to this command.
9. Once you have completed and saved the configuration, reboot the router using the command reload.
10. After the router completes the reboot process, open a terminal window in the PC. Execute
telnet IP_of_the_Router to login from the PC to the router. Display the configuration of the router using the
proper CLI command. With the information shown, fill in the gaps below.
interface FastEthernet0/0
ip address
no ip directed-broadcast
speed
full-duplex
!
interface FastEthernet0/1
ip address
no ip directed-broadcast
speed
full-duplex
!
11. Ping from the router to its default gateway (the interface of the PC-router in your departmental backbone).
Which is the symbol used to display a successfully received ping reply?
Laboratory Manual 36
Tasks During the laboratory session
• In a terminal window of the PC try the ping command to check that the following hosts are alive (reachable
from your machine). Pinging the PC-Router use the IP address of the interface which belong to your
department (Check Figure 2.2 for the proper address).
ping -n router_IP
ping -n IP_of_PC-router
ping -n www.imit.kth.se
• Ping the machine www.kth.se and stop it after a few replies typing Ctrl+C; fill in the missing parts of the
ping output given below and answer to the following questions.
PING www.kth.se ( ) (84) bytes of data.
bytes from ( ): icmp_seq=1 ttl=
time=
bytes from ( ): icmp_seq=2 ttl=
time=
bytes from ( ): icmp_seq=3 ttl=
time=
• How many IP hops away is the machine www.kth.se from your current position? (Remember ping re-
quests/replays are sent with maximum value of TTL = 255)
• Which is the sequence number of the first router which does not respond?
• Execute : arp -a . How many entries has the ARP table of your PC?
• What is the Ethernet address of your PC(you can also find this information using the ifconfig command)?
Remember the facts about construction of the filters and do the following:
• The following filter will display all Ethernet frames from and to your machine which contain the ARP pro-
tocol (we will refer to this filter later as ARP_FILTER). Execute ifconfig to discover Your_MAC_Address.
Laboratory Manual 37
Tasks During the laboratory session
• The following filter will display only IP traffic (we will refer to this filter later as IP_FILTER).
ip
• The following filter will display traceroute traffic from and to your PC (we will refer to this filter later as
TRACEROUTE_FILTER).
(ip.src==IP_of_Your_PC and ip.proto==0x11) or
(ip.dst==IP_of_Your_PC and ip.proto==0x01)
If you see an error message after executing this command this means that your ARP table does not have an entry
for this IP address. This is fine, just proceed with the task.
Now go back to your Wireshark window. While capturing, make a ping to the switch in your network. Type
the ARP_FILTER in the Filter field of the main window of Wireshark and answer the following questions:
• What is the meaning of the first message of ARP (look at “info” column)?
• What is the meaning of the second message of ARP (look at “info” column)?
3. While capturing, make a ping to the ROUTER in your network. Type the IP_FILTER in the Filter field of the
main window of Wireshark and answer the following questions:
• In the main window of Wireshark choose one of the ICMP request packets. Look at Figure 2.24, find
appropriate information in Wireshark and fill in the gaps (Hint: you need to calculate how many bytes the
ICMP header of the PING packet is).
4. While capturing the traffic in Wireshark, make a traceroute to 194.71.11.40 without the “-n” option. Type
the TRACEROUTE_FILTER in the Filter field of the main window of Wireshark and answer the following
questions:
• How many times does the PC send traceroute probes to each hop? Hint: Choose consequently at least 7
UDP packets starting from the first one. Look at Time To Live value of the IP header in each packet.
• Choose one of the last three ICMP messages of the traceroute (these message came from the destination
machine). What is the code (number and meaning) of this ICMP message?
• Choose any other ICMP message of the traceroute (this message came from one of the routers on the path
to the destination). What is the code (number and meaning) of this ICMP message?
Laboratory Manual 38
Tasks During the laboratory session
• What is the UDP port number(s) to which the traceroute sends its probes?
• List the names of all protocols which are involved in the traceroute communications (look at the ’Protocols’
column in Wireshark’s main window).
Laboratory Manual 39
Tasks During the laboratory session
Laboratory Manual 40
Chapter 3
These lines should be included in the configuration file of the router as the rest of the configuration. The first
line declares that the definition of an ACL is starting. The keywords ip access-list are mandatory, while
extended specifies the type of ACL. There are several types of ACL, but we will always use extended ACL because
they provide the richest syntax. The first line ends with the name we gave to this ACL, noHTTPtraffic, that can be
used for reference to this ACL later. The second and third lines are the statements, which establish our policy. The first
keyword deny or permit indicates whether the statement will deny or accept respectively the traffic if the condition
is satisfied. The rest of the line contains the condition against which each packet will be tested.
The condition starts with a keyword and then it has two mandatory addresses source address and
destination address and optionally port. The first keyword in the condition indicates the type of traffic to
match. Possible values for this field are TCP,udp,ip or icmp. After the traffic type, each address is specified with
two words, the first is the expected IP address and the second is called a wildcard mask.
The wildcard mask indicates which bits of the packet’s IP address must match the expected address for the state-
ment to be applied. The wildcard mask looks like a network mask, but it operates in a completely different way. Each
0 bit in the wildcard means to check the corresponding packet’s address bit, while a 1 bit means to ignore. So the
destination address 192.168.10.0 0.0.0.255 of the first statement means that the first 3 octets of the packet’s
41
Tasks Before the session
destination address must match the first 3 octets of the given address for this rule to be applied. The last octet of the
packet’s address is not checked since the wildcard mask contains ones there. As a special case, the address 0.0.0.0
means any IP address and the wildcard mask 255.255.255.255 means do not check any bit of the packet’s address.
In our example, the couple 0.0.0.0 255.255.255.255 in the source address of the first statement means accept any
address as the source address of the tested packet. The router will display the word any instead of this couple. The
condition finishes with the port to be matched, being this information optional. In our example, the first statement
contains a port limitation in the condition but not the second. In the first condition, eq 80 means that the packet must
contain the port 80 (HTTP port) to match the condition.
To summarize, our ACL has two statements. The first one denies TCP traffic from any source with destination
any host in our network (192.168.10.0/24) if the packet contains HTTP traffic (port 80). The second one permits any
other packet. It is important to highlight that the packets are tested against the statements in the order in which the
statements were created and that when a packet matches a statement, the permit or deny decision is made and the rest
of the statements are not checked. For example, if the second statement were in the first position, all packets would be
accepted since all would match the permit condition and the deny condition would never be tested.
To finish with the syntax of the ACLs, mind that by default they contain a final statement deny 0.0.0.0
255.255.255.255 0.0.0.0 255.255.255.255, which will deny all packets not matching any of the pre-
vious statements. It is always there, even though it is never displayed. This means that the second statement of our
example is important, otherwise the default statement would have dropped all the packets not containing port 80.
Remember that you always need to permit the allowed traffic explicitly.
Once the desired ACL’s are included in the configuration of the router, they must be linked to a particular interface.
This linking mechanism provides great flexibility because different interfaces in the router can apply different policies
(ACLs). The syntax to link our ACL to the incoming traffic to the FastEthernet0/1 port of the router would be:
interface FastEthernet0/1
...
ip access-group noHTTPtraffic in
...
It is a straightforward command in the interface’s configuration where the name of the ACL is used to identify
it. The final keyword in means that the ACL is to be checked against incoming traffic, thus outgoing traffic will not
be filtered. The other value of this final keyword can be out to filter outgoing traffic. Remember that there is an
additional restriction; at most two ACL can be linked to one interface (one per direction).
To close this section, we will give you some useful hints when working with ACLs. The ACL must be created in
global configuration mode, but they are linked to interfaces from the particular interface’s configuration mode. The
statements are tested in the order in which they were created, thus if you need to change the order of the statements,
you have to delete them first using the “no” form and retype them again in the desired order. The command show ip
interface executed in privileged mode lists the ACLs, which are set for each interface. And the command show
access-list [name] displays the contents of the ACL given by name. When the optional name is omitted all
ACLs are displayed.
Laboratory Manual 42
Tasks During the laboratory session
1. Figure 3.1 represents the equipment in your area network and part of the departmental backbone. Using figure
2.2 and figure 2.3 as a guide, fill in the IP addresses, names and interface names corresponding to your position.
Assign the IP addresses following the rules given in section 2.1.1.
2. Following this diagram, connect the interfaces of the router, the switch and the PC.
3. First you need to configure the router in your network. Connect the management console to the router. Use the
PC running Linux as management console. Remember to link the console port of the router to the USB of the
PC using the rollover cable, the RJ-45 to DB9 converter, and the USB to DB9 converter.
Laboratory Manual 43
Tasks During the laboratory session
4. Open a terminal window in the PC and start the program minicom with the superuser privileges (sudo).
5. Connect the power cable to the router and switch it on. Check that some messages appear in the management
console as the router boots.
6. Wait until the router boots. Then if the router asks you whether you would like to enter the initial configuration
dialog, answer no. When the router’s prompt appears, enter in global configuration mode using the enable
command.
7. This time we will not configure the router typing all commands in the command line interface, but we will
download the configuration from a TFTP server in the network. So the first step is to configure the router to
reach the TFTP server. In our network, the TFTP server is running in the PC-router, which is also the default
gateway to the Internet. This PC can be reached through the router’s port named FastEthernet0/1. Using the
information in figure 3.1, configure the router’s interface FastEthernet0/1 with the proper IP address and network
mask. Remember to use the proper commands to enter in interface configuration mode (i.e. configure
terminal and interface FastEthernet0/1).
8. Once you have configured the interface, check that it is not shutdown. In order to check this display the running
configuration of the router (show running-config). Find the description of the interfaces. If the word
“shutdown” is part of the configuration of any of the two interfaces (i.e FastEthernet0/0 or FastEthernet0/1) the
interface does not work. If this is the case you have to switch it on manually by performing the following steps;
otherwise omit them.
(a) Enter in the interface configuration mode (i.e. configure terminal and interface
FastEthernet0/x, where ’x’ is the number of the shutdown interface).
(b) Type no shutdown.
(c) Exit from the interface configuration mode.
9. At this point you must be able to reach the TFTP server. Check it using ping from the router to the PC-router’s
closest interface. If you cannot reach the IP address of the TFTP server, review all previous steps until you find
the problem. Do not proceed to the next step, before you can reach the TFTP server.
10. The TFTP server stores a different configuration file for every router. So you have to download the file corre-
sponding to your router using the right filename. The filename of your router’s configuration is composed by
your network name and the suffix ’-r-config’. For example, if your position is area 2 of the production depart-
ment, the filename is ’pro2-r-config’. If your position is area 4 of the research and development department,
the filename is ’rad4-r-config’ and so on. Download that file to your router’s running configuration, using the
following Cisco command in global configuration mode:
Firstly, you will be asked for the IP address of the remote host. This should be the IP address of the closest
interface of the PC-router to your router. After this you need to indicate the filename and the destination filename
(use the default value running-config). After you answer the third and last question, the configuration file
will be downloaded to your router. The configuration will become the running configuration in the router
immediately after the download process is completed.
11. The router is now configured as figure 3.1 indicates, including passwords and routing table. Looking at the
running-configuration, check that none of the FastEthernet interfaces is shutdown as explained in Step 8 above.
(a) Check that the IP addresses assigned to the interfaces correspond to those in figure 3.1.
(b) Check the routing table. You should be able to ping and traceroute any hostname in the Internet from the
router. For instance, try to traceroute www.imit.kth.se.
13. Save the configuration of the router using copy running-config startup-config.
14. Now that the router is ready, configure the switch. Connect the management console to the switch and power it
on. Some messages should appear in the console while the switch boots.
Laboratory Manual 44
Tasks During the laboratory session
15. Wait until the switch boots. Then if the switch asks you whether you would like to enter the initial configuration
dialog, answer no. When the switch prompt appears, enter in global configuration mode using the enable
command. Note that the switch can ask you to log in.
16. Using the information in Figure 3.1, configure the switch’s interface VLAN1 with the proper IP address and net-
work mask. Remember to use the proper commands to enter in interface configuration mode (i.e. configure
terminal and interface vlan1).
17. Set the default gateway for the switch with the command ip default-gateway IP_of_Gateway
in privileged mode.
18. Once you have configured the interface and the default gateway, you must be able to reach the TFTP server. It
is the same server for both the switch and router. Check it using ping from the switch. If you cannot reach the
IP address of the TFTP server, review all the previous steps until you find the problem. Do not proceed to the
next step, before you can reach the TFTP server.
19. The TFTP server stores a different configuration file for every switch. So you have to download the file corre-
sponding to your switch using the right filename. The filename of your switch’s configuration is composed by
your network name and the suffix ’-sw-config’. For example, if your position is area 2 of the production depart-
ment, the filename is ’pro2-sw-config’. If your position is area 4 of the research and development department,
the filename is ’rad4-sw-config’ and so on. Download that file to your switch’s running configuration, using the
following Cisco command in global configuration mode:
copy tftp running-config
Firstly, you will be asked for the IP address of the remote host. This should be the IP address of the closest
interface of the PC-router to your router. After this you need to indicate the filename and the destination filename
(use the default value running-config). After you answer the third and last question, the configuration file
will be downloaded to your switch. The configuration will become the running configuration in the switch
immediately after the download process is complete. The switch is now configured as figure 3.1 indicates,
including passwords and the IP address.
20. Check that the received configuration is correct. Check that the IP addresses assigned to the vlan interface is
right and check the default gateway. You should be able to ping and traceroute any host in the Internet from the
switch. For instance, try to traceroute www.imit.kth.se.
21. Now, save the configuration of the switch using copy running-config startup-config.
22. Finally, configure the PC Ethernet interface using the commands described in the section 2.6. You will need to
configure the network interface with proper IP address and network mask, and then the PC routing table. Open
a terminal window in your PC. You will type all commands there.
23. Configure your Ethernet interface (Remember that in your PC the ID of the Ethernet interface in the PC is eth1)
with the command ifconfig. Recall the IP information of your network and configure your interface using
the following command:
ifconfig Interface_ID IP_of_your_PC netmask Your_Netmask broadcast Broadcast_address
24. Add a route to the default gateway with the ’route’ command. The default gateway should be the inner
interface of your LAN router.
route add default gw Address_of_your_router
25. Now the configuration of the PC is finished. You should be able to ping and traceroute any hostname in the
Internet from the PC. For instance, traceroute to www.imit.kth.se.
Laboratory Manual 45
Tasks During the laboratory session
1. From the PC telnet to the PC router in the lab, the one that offers Internet access to all the routers. It can be
reached at any IP address shown in Figure 2.3. As the user name use: lab and the password labo. The Linux
command should look like this:
telnet IP_of_PC-Router -l lab
2. From the PC-router telnet to your own router and enter in privileged mode (command enable) so you can
change the configuration of the router. Note that this is exactly the type of connection that policy 1 tries to
forbid.
3. Write below the ACL corresponding to the above policy 1 using the proper Cisco syntax. Remember that telnet
uses tcp port 23.
4. Add the ACL above to the router configuration using the telnet connection established through the PC-router.
Do not link the ACL to the interface yet. Close the telnet connection from the PC-router to your router with the
command exit after adding the ACL.
5. Connect the management console to the router, enter in the configuration mode and link the previous ACL to
the proper interface. Note that the proper interface depends on how you wrote the ACL. Mind that the telnet
connection to PC-router from your PC should keep working after the ACL is set.
6. Now that the ACL is set, check that you cannot establish a telnet connection from the PC-router to your router
any longer. What is the error message displayed when the telnet connection fails?
7. Before starting with the second policy, check that you can open with a web browser in the PC both ’ftp://ftp.sunet.se’
and ’http://ftp.sunet.se’. Both URLs will reach the FTP archive of the Swedish University Network, but the for-
mer will use the FTP protocol while the second will use the HTTP protocol. The second policy will only permit
the HTTP connection to this site.
8. Close the web browser.
9. Write below the ACL corresponding to the policy 2 using the proper Cisco syntax. Note that this ACL should
permit some additional traffic not mentioned in the text of the policy before blocking the rest of the traffic: Web
browsing (tcp port 80) will work if Domain Name Resolution (DNS) is working, thus DNS (udp port 53) should
be permitted as well. In addition, you should allow the traffic useful for network maintenance, so permit also
ICMP traffic.
Laboratory Manual 46
Tasks During the laboratory session
10. Add this second ACL to the router configuration using a telnet connection from your PC to the router.
11. Link this new ACL to the proper interface. Note that the proper interface depends on how you wrote the ACL.
Mind also that the outgoing telnet connection to the router from your PC allowed by policy 1 should keep
working after this ACL is set.
12. Now that the ACL is set, check that you can still open this URL ’http://ftp.sunet.se’ with a web browser in the
PC.
13. Now check that you cannot open this URL ’ftp://ftp.sunet.se’ with a web browser in the PC. What is the error
message displayed when the connection fails?
14. Now check that ’ftp.sunet.se’ is still alive using ping from the PC. Why does ping work when the site cannot be
browsed?
15. Now trace the route from the PC to ’ftp.sunet.se’ using the Linux command traceroute. Why cannot tracer-
oute reach the destination even when ICMP traffic is allowed? (Hint: read traceroute manual page with man
traceroute if you are not sure how it works).
Laboratory Manual 47
Tasks During the laboratory session
Laboratory Manual 48
Chapter 4
• A Fully Qualified Domain Name (FQDN), which is the specific domain you are looking for
49
Tasks Before the session
DNS queries are resolved in different ways. Sometimes your machine contains a local cache that contains infor-
mation previously looked for, or the DNS server can use its own cache to answer a query. However, most of the time,
the DNS server needs to contact other DNS servers to resolve the name and then send back the answer to the client.
This is called a recursive query. The client machine can also contact additional DNS servers using separate queries.
This process is called iteration.
• A hosts file configured locally, which contains hosts name to address mappings. These manually inserted map-
pings are stored in the local cache when the DNS client is started.
• Some Resource Records (RR) that came in previous responses from DNS servers, and that are kept in the local
cache for some time.
If the local resolver is not able to solve a query, then the process continues with the client querying a DNS server.
Laboratory Manual 50
Tasks Before the session
Laboratory Manual 51
Tasks Before the session
This recursion process can be time consuming and resource intensive, but it has some advantages for the DNS
server, as it obtains information about the DNS name space and caches it in its local cache to speed up subsequent
queries. The local DNS cache is cleared when the DNS server is restarted.
• An authoritative answer. It has the authoritative bit set and means that the answer was obtained from a server
with direct authority over the queried name.
• A positive answer, which contains the demanded resource records (RR) or a set of RR’s that comply with the
questioned DNS name and record type.
• A referral answer, which contains additional resource records not included in the query. This answers is given
back to the client when recursion is not supported by the server, so that the client can continue the query using
iteration. If the client is unable to use iteration, it can make further queries using the referral information.
• A negative answer, which can indicate that either an authoritative server answered that the queried name does
not exist, or that it exists but there are no records of the specified type for that name.
Laboratory Manual 52
Tasks During the laboratory session
1. Edit the file /etc/resolv.conf. If it does not exists, create one. It contains the IP address of the DNS server to
contact when resolving names. Change the name-server’s IP address to the IP of the PC-router in the network:
192.168.0.1. After editing, the first line of the file should contain the following:
nameserver 192.168.0.1
2. First, perform a recursive query to get the IP address corresponding to a hostname. In this step use dig without
options to resolve hostnames. This is an example of the syntax:
dig Name_of_a_machine
• Look in Table 4.1 and pick up the name of the web server which corresponds to your position. Resolve its
IP address using dig. Look at the statistic’s part (the last part of ‘dig’s’ output). What is the query time?
• Repeat the previous exercise with the same name. What is the query time now? Why do you observe this
phenomenon?
Laboratory Manual 53
Tasks During the laboratory session
3. Second, perform a non-recursive query. In the last step, your DNS client contacted several servers to complete
the recursive query. Now you will use dig to contact the different servers one by one until you get the IP address
corresponding to the given hostname. The goal of this step is to discover how the DNS client in your PC resolves
IP addresses given symbolic names. Execute these commands and answer the questions:
• Execute the following command to obtain the list of available root servers.
dig +nostats +nocmd
• Choose a ‘ROOT’ server from the list and write its name here:
• Now perform non-recursive queries to resolve the IP address of the machine www.ee.kth.se. Write below
the list of DNS servers (name and IP address) contacted. Start querying from the root server that you
chose above and use the following syntax of dig to do non-recursive queries:
dig +norec +nostats +nocmd www.ee.kth.se @IP_of_the_DNS_server
Note: read the description of DNS in Section 4.1 if you do not remember how the recursion works.
Remember the following! All zone files in the directory contain a serial number inside. A typical example is:
Laboratory Manual 54
Tasks During the laboratory session
;
; Zone file for your_area.your_department.acme
;
; The full zone file
;
$TTL 3D
@ IN SOA ns.your_area.your_department.acme.
hostmaster.your_area.your_department.acme. (
201502271300 ; serial, todays date + todays serial #
Each time you edit this file, increment this field by 1. This will tell your DNS server to flush the cache and load the
edited zone information. Also, notice that in all templates that we provide to you, you need to change certain values.
The values that you should change are written in italics in the manual. In general you should change the places where
it says IP_of_Your_Router or your_area.your_department.
One last comment: whenever you start BIND, you can always check the output messages of the initialization. All
the output is saved in file ‘/var/log/daemon.log’, so just open the file for reading using ‘sudo less /var/log/daemon.log’
to see BIND startup messages.
First, get the parameters for the configuration of your DNS server:
1. Considering the diagram in Figure 4.1 as an example identify the following information for your network.
• What is the IP address of the machine which is able to resolve all domains of ACME’s network?
• What is the IP address of the machine which run the DNS server for YOUR network?
• Use Figure 4.1 as an example and assign the names to the devices in your network and fill them into the
diagram in Figure 4.2 :
Laboratory Manual 55
Tasks During the laboratory session
However, C-style /* */, C++-style // and Unix-style # comments are used in files ‘/etc/bind/named.conf.options’,
‘/etc/bind/named.conf.default-zones’, and ‘/etc/bind/named.conf.local’. Don’t use a semicolon to mark a comment in
these files.
Finally, after each step that you perform, you should always save your configuration file before continuing.
Laboratory Manual 56
Tasks During the laboratory session
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
The record starts with the keyword zone followed by the domain name and the class (in stands for the Internet).
The word master indicates that this server is a primary master server for the zone, and the last line shows the
file to be read. On a primary master server, files ’named.conf.default-zones’ and ’named.conf.local’ contain one
record for each file to be read. The special zone ‘.’ is used when your server can not resolve the names by its
own. Basically, you should read this zone description as ‘For every name which is not under my responsibility
forward the query to 192.168.0.1, which is the IP address of the PC-router; it will handle it’.
These zones are the default zones, their zone files come predefined so you do not have to worry about them.
However, for your better understanding you will have to edit the file for your localhost (your own PC).
• Open the file‘/etc/bind/db.127’. This file contains the database for your localhost (your own PC). You can check
that it corresponds to the third zone in your ‘named.conf.default-zone’ file. It should contain the following:
$TTL 3D
@ IN SOA ns.your_area.your_department.acme.
hostmaster.your_area.your_department.acme. (
201502271300; Year+Month+Date+Serial
8H ; Refresh
2H ; Retry
4W ; Expire
1D) ; Minimum TTL
NS ns.your_area.your_department.acme.
1.0.0 PTR localhost.
Change all appearances of your_area and your_department to the names corresponding to your area and depart-
ment (refer to Figure 4.2 for information). Save the file and proceed further.
In this file you can see the structure of the database files (db). Remember that every line that starts with a
semicolon is a comment. This file maps addresses to host names. Each file is named as the network number
it represents, so 127 means that this particular file contains the mappings from IP addresses to names for any
address of the form 127.x.x.x. As you can see, only the parts (the ‘x.x.x’) of the IP address needs to be written
in the file, as all the other parts are already matched when this file is used. This is the reason why the localhost
entry is 1.0.0, because the localhost address is ‘127.0.0.1’. Note that the entry address is written in the opposite
order. Notice also the ‘.’ at the end of localhost. If a machine name does not end in a period in a zone file the
origin is added to its end, so the entry would be ‘localhost.127.0.0’ which, of course, is wrong!
Most entries in the db files are called DNS resource records, and they must start in column one. The ordering of
resource records in the db files is as follows (not all of them need to be present):
• Start BIND running ‘/etc/init.d/bind9 start’. Check that BIND loads correctly by looking at the file ‘/var/log/daemon.log’.
Run dig -x 127.0.0.1 and fill the missing parts of its output below. Of course, some of the values will
not be the same for you, as your localhost zone file could differ from this example, however the ANSWER
SECTION should be there!
Laboratory Manual 57
Tasks During the laboratory session
;; QUESTION SECTION:
;1.0.0.127. . . IN PTR
;; ANSWER SECTION:
.in-addr.arpa. IN .
;; AUTHORITY SECTION:
0.0.127.in-addr.arpa. IN NS .
• Edit ‘/etc/bind/named.conf.local’ file. Append the following text to the end of this file:
zone "your_area.your_department.acme" {
type master;
notify no;
file "/etc/bind/db.your_area.your_department.acme";
};
This entry tells BIND where to find the database about your own area. You should already know what each field
means. The ‘notify no’ means that we do not want to notify all the rest of the DNS servers about the content of
our file. . . after all we are only testing! Save the file and proceed further.
;
; Zone file for your_area.your_department.acme
;
; The full zone file
;
$TTL 3D
@ IN SOA ns.your_area.your_department.acme.
hostmaster.your_area.your_department.acme. (
201502271300 ; serial, todays date + todays serial #
8H ; refresh, seconds
2H ; retry, seconds
4W ; expire, seconds
1D ) ; minimum, seconds
;
;--- -DESCRIPTION of THIS DNS server-------------;
;----------LABEL--VALUE--------COMMENT------;
TXT "Area.Dept.acme DNS server"
NS ns ; Inet Address of name server
;
;----ASSIGNMENT of IP ADDRESSES TO THE NETWORK DEVICES-;
;NAME-------------------------LABEL--IP ADDRESS---------;
;
localhost A 127.0.0.1
ns A IP_of_your_DNS_Server
www CNAME ns
Name_of_the_inner_interface_of_your_router A IP_of_your_router
sw A IP_of_your_switch
other A IP_of_other_device
In this zone file you should be able to recognize most of the Resource Records (RR). Most of them are ‘A’
resource records, that map names to IP addresses. There is also a CNAME record, which is an alias for the web
server, which in your case would run on the same PC. That is why it points to the ‘A’ record of your name server
(your PC). Save the file and proceed further.
Laboratory Manual 58
Tasks During the laboratory session
• Restart BIND running ‘/etc/init.d/bind9 restart’ and check log messages in ‘/var/log/daemon.log’. In the case
of error messages you need to search for an error in your configuration files. Otherwise, run
dig www.your_area.your_department.acme
;; QUESTION SECTION:
;www. . .acme. IN A
;; ANSWER SECTION:
. . .acme. IN .
ns. . .acme. IN A
;; AUTHORITY SECTION:
. .acme. IN NS .
• Edit ‘/etc/bind/named.conf.local’ file and append the following text to the end of this file:
zone "0.168.192.in-addr.arpa" {
type master;
notify no;
file "/etc/bind/db.192.168.0";
};
;
; Zone file for 0.168.192.in-addr.arpa
;
; The reverse zone file
;
$TTL 3D
@ IN SOA ns.your_area.your_department.acme.
hostmaster.your_area.your_department.acme. (
201502271300 ; serial, todays date + todays serial #
8H ; refresh, seconds
2H ; retry, seconds
4W ; expire, seconds
1D ) ; minimum, seconds
;
NS ns.your_area.your_department.acme.
;
;-REVERSE ASSIGNMENT of IP ADDRESSES TO THE NETWORK DEVICES----------;
;Host Part of IP ADD--------LABEL---------------NAME----------------;
Laboratory Manual 59
Tasks During the laboratory session
You can easily understand the content of this file. All resource records are of type PTR, so they translate IP
addresses to names. Edit the file and substitute the given strings by names and IP numbers of your network.
Remember! You only have to write the host part of your IP addresses. For example if the IP address of
the inner interface of your router is 192.168.0.129, then instead of the entry First_valid_host_address you
should write only "129". Notice also the dots at the end of the names. If you do not add those dots, then the
name of the zone file would be added at the end. Save the file and proceed further.
• Restart BIND running ‘/etc/init.d/bind9 restart’ and check if any errors appear. If all is correct, run
dig -x IP_Address_of_Your_Router
;; QUESTION SECTION:
; . . . . . . IN PTR
;; ANSWER SECTION:
.in-addr.arpa. IN .
;; AUTHORITY SECTION:
.in-addr.arpa. IN NS .
;; ADDITIONAL SECTION:
ns. . .acme. IN A
Laboratory Manual 60