Ccna Class Notes
Ccna Class Notes
In the example above, the two computers are directly connected using a cable. This
small network can be used to exchange data between just these two computers.
What if we want to expand our network? Then we can use a network device, either a
switch or a hub, to connect more than two computers together:
Now all of the devices on the network can communicate with each other.
We’ll talk more about hubs and switches in just a moment. For now, just remember
that these devices serve as a central point to which all of the computers connect to.
OSI & TCP/IP models
OSI model
OSI (Open Systems Interconnection) model was created by the International
Organization for Standardization (ISO), an international standard-setting body. It
was designed to be a reference model for describing the functions of a
communication system. The OSI model provides a framework for creating and
implementing networking standards and devices and describes how network
applications on different computers can communicate through the network media.
The OSI model has seven layers, with each layer describing a different function of
data traveling through a network. Here is the graphical representation of these
layers:
The layers are usually numbered from the last one, meaning that the Physical layer
is considered to be the first layer. It is useful to remember these layers, since there
will certainly be a couple of questions on the CCNA exam regarding them. Most
people learn the mnemonic „Please Do Not Throw Sausage Pizza Away“:
Physical – defines how to move bits from one device to another. It details
how cables, connectors and network interface cards are supposed to work and how
to send and receive bits.
Data Link – encapsulates a packet in a frame. A frame contains a header and
a trailer that enable devices to communicate. A header (most commonly) contains a
source and destination MAC address. A trailer contains the Frame Check Sequence
field, which is used to detect transmission errors. The data link layer has two
sublayers:
1. Logical Link Control – used for flow control and error detection.
2. Media Access Control – used for hardware addressing and for controlling the
access method.
The following table shows which protocols reside on which layer of the OSI model:
TCP/IP model
The TCP/IP model was created in the 1970s by the Defense Advance Research
Project Agency (DARPA) as an open, vendor-neutral, public networking model.
Just like the OSI model, it describes general guidelines for designing and
implementing computer protocols. It consists of four layers: Network Access,
Internet, Transport, and Application:
The following picture show the comparison between the TCP/IP model and OSI
model:
As you can see from the picture above, the TCP/IP model has fewer layers than the
OSI model. The Application, Presentation, and Session layers of the OSI model are
merged into a single layer in the TCP/IP model. Also, Physical and Data Link layers
are called Network Access layer in the TCP/IP model. Here is a brief description of
each layer:
Link – defines the protocols and hardware required to deliver data across a
physical network.
Internet – defines the protocols for the logical transmission of packets over
the network.
Transport – defines protocols for setting up the level of transmission service
for applications. This layer is responsible for reliable transmission of data and the the
error-free delivery of packets.
Application – defines protocols for node-to-node application communication
and provide services to the application software running on a computer.
There are some other differences between these two models, besides the obvious
difference in the number of layers. OSI model prescribes the steps needed to
transfer data over a network and it is very specific in it, defining which protocol is
used at each layer and how. The TCP/IP model is not that specific. It can be said
that the OSI model prescribes and TCP/IP model describes.
A typical SOHO (small office/home office) LAN consist of PCs, printers, switches,
routers, and cabling that connects all these devices together. The following figure
shows a typical LAN:
In the picture above we have two computers that are connected to a switch. The
switch is then connected to a router that provides the LAN with access to the
Internet.
Some of the most popular LAN technologies are Ethernet, Token Ring and FDDI.
Most LAN networks use TCP/IP to communicate. Twisted-pair cabling is usually
used in a LAN.
Ethernet is by far the most popular wired LAN technology. It defines wiring, signaling,
connectors, frame formats, protocol rules, etc. Most modern LANs also support the
wireless LAN (WLAN) technology, defined by the IEEE 802.11 standards. WLANs
use radio waves instead of wires or cables for links between devices.
The key difference between LANs and WANs is that the company usually doesn’t
own WAN infrastructure. A company usually leases WAN services from a service
provider. A WAN spanning multiple cities could look something like this:
Frame Relay, ATM and X.25 are different types of WAN technologies. The Internet
can also be considered a WAN.
Encapsulation
The term encapsulation is used to describe a process of adding headers and
trailers around some data. This process can be explained with the four-layer TCP/IP
model, with each step describing the role of the layer. For example, here is what
happens when you send an email using your favourite email program (such as
Outlook or Thunderbird):
1. the email is sent from the Application layer to the Transport layer.
2. the Transport layer encapsulates the data and adds its own header with its
own information, such as which port will be used and passes the data to the Internet
layer
3. the Internet layer encapsulates the received data and adds its own header,
usually with information about the source and destination IP addresses. The Internet
layer than passes the data to the Network Access layer
4. the Network Access layer is the only layer that adds both a header and a
trailer. The data is then sent through a physical network link.
Here is a graphical representation of how each layer add its own information:
NOTE
The term decapsulation refers to the process of removing headers and trailers as data passes
from lower to upper layers. This process happens on the computer that is receiving data.
While the TCP/IP model uses terms like segment, packet and frame to refer to a
data packet defined by a particular layer, the OSI model uses a different
term: protocol data unit (PDU). A PDU represent a unit of data with headers and
trailers for the particular layer, as well as the encapsulated data. Since the OSI
model has 7 layers, PDUs are numbered from 1 to 7, with the Physical layer being
the first one. For example, the term Layer 3 PDU refers to the data encapsulated at
the Network layer of the OSI model.
Ethernet explained
Ethernet is the most used networking technology for LANs today. It defines wiring
and signaling for the Physical layer of the OSI model. For the Data Link layer, it
defines frame formats and protocols.
The Ethernet frame structure is defined in the IEEE 802.3 standard. Here is a
graphical representation of an Ethernet frame and a description of each field in the
frame:
Preamble – informs the receiving system that a frame is starting and enables
synchronisation.
SFD (Start Frame Delimiter) – signifies that the Destination MAC Address
field begins with the next byte.
Destination MAC – identifies the receiving system.
Source MAC – identifies the sending system.
Type – defines the type of protocol inside the frame, for example IPv4 or
IPv6.
Data and Pad – contains the payload data. Padding data is added to meet
the minimum length requirement for this field (46 bytes).
FCS (Frame Check Sequence) – contains a 32-bit Cyclic Redundancy
Check (CRC) which allows detection of corrupted data.
The FCS field is the only field present in the Ethernet trailer. It allows the receiver to
discover whether errors occurred in the frame. Note that Ethernet only detects in-
transit corruption of data – it does not attempt to recover a lost frame. Other higher
level protocols (e.g. TCP) perform error recovery.
Every network card manufacturer gets a universally unique 3-byte code called
the Organizationally Unique Identifier (OUI). Manufacturers agree to give all NICs
a MAC address that begins with the assigned OUI. The manufacturer then assigns a
unique value for the last 3 bytes, which ensures that every MAC address is globaly
unique.
MAC addresses are usually written in the form of 12 hexadecimal digits. For
example, consider the following MAC address:
D8-D3-85-EB-12-E3
Every hexadecimal character represents 4 bits, so the first six hexadecimal
characters represent the vendor (Hewlett Packard in this case).
If you are using Windows, start the Command Prompt (Start – Programs –
Accessories – Command Prompt). Type the ipconfig/all command and you should
see a field called Physical Address under the Ethernet adapter settings:
If you are using Linux, type the ifconfig command. You should see your MAC
address referred to as HWaddress.
IP address
An IP address is a 32-bit number that identifies a host on a network. Each device
that wants to communicate with other devices on a TCP/IP network needs to have
an IP address configured. For example, in order to access the Internet, your
computer will need to have an IP address assigned (usually obtained by your router
from the ISP).
Private IP addresses
There are three ranges of addresses that can be used in a private network (e.g. your
home LAN). These addresses are not routable through the Internet.
10.0.0.0 – 10.255.255.255
172.16.0.0 – 172.31.255.255
192.168.0.0 – 192.168.255.255
If you are using Windows, start the Command Prompt (Start – Programs –
Accessories – Command Prompt). Enter the ipconfig command. You should see a
field called IP Address:
Linux users:
1. unicast addresses
Unicast addresses represent a single LAN interface. A unicast frame will be sent to a
specific device, not to a group of devices on the LAN:
The unicast address will have the value of the MAC address of the destination
device.
2. multicast addresses
Multicast addresses represent a group of devices in a LAN. A frame sent to a
multicast address will be forwarded to a group of devices on the LAN:
Multicast frames have a value of 1 in the least-significant bit of the first octet of the
destination address. This helps a network switch to distinguish between unicast and
multicast addresses. One example of an Ethernet multicast address would
be 01:00:0C:CC:CC:CC, which is the address used by CDP (Cisco Discovery
Protocol).
3. broadcast addresses
Broadcast addresses represent all device on the LAN. Frames sent to a broadcast
address will be delivered to all devices on the LAN:
The broadcast address has the value of FFFF.FFFF.FFFF (all binary ones). The
switch will flood broadcast frames out all ports except the port that it was received
on.
Network devices
Let’s take a look at the network devices commonly found in today’s LANs..
Hubs
A hub serves as a central point to which all of the hosts in a network connect to. A
Hub is an OSI Layer 1 device and has no concept of Ethernet frames or addressing.
It simply receives a signal from one port and sends it out to all other ports. Here is an
example 4-port Ethernet hub (source: Wikipedia):
Today, hubs are considered obsolete and switches are commonly used instead.
Switches
Like hubs, a switch is used to connect multiple hosts together, but it has many
advantages over a hub. Switch is an OSI Layer 2 device, which means that it can
inspect received traffic and make forwarding decisions. Each port on a switch is a
separate collision domain and can run in a full duplex mode (photo credit:
Wikipedia).
Routers
A router is a device that routes packets from one network to another. A router is
most commonly an OSI Layer 3 device. Routers divide broadcast domains and have
traffic filtering capabilities.
As mentioned above, hubs have no way of distinguishing out which port a signal
should be sent to; instead, an electrical signal is sent out each port. All nodes on the
network will receive data, and the data will eventually reach the correct destination,
but with a lot of unnecessary network traffic:
In the example above you can see that the hub has sent out the receiving signal out
all other ports, except the incoming port. Hubs are therefore considered obsolete and
switches are commonly used instead in modern LANs. Hubs have numerous
disadvantages over switches, such as:
they are not aware of the traffic that passes through them
they create only one large collision domain
a hub typically operates in half duplex
there is also a security issue with hubs since the traffic is forwarded to all
ports (except the source port), which makes it possible to capture all traffic on a
network with a network sniffer!
NOTE
Hubs are also known as multiport repeaters because that is basically what they do – repeat the
electrical signal that comes in one port out all other ports (except the incoming port).
In the example above we have a network of four computers. The network is divided
into segments by a bridge. Each segment is a separate collision domain with its own
bandwidth. Let’s say that Host A wants to communicate with Host C. Host A will send
the frame with the Host C’s destination MAC address to the bridge. The bridge will
inspect the frame and forward it to the segment of the network Host C is on.
Network bridges offered substantial improvements over network hubs, but are not
widely used anymore in modern LANs – switches are commonly used instead. Here
is why:
most bridges have only 2 or 4 ports. A switch can have tens or even hundreds
of ports
bridges are software based, while switches are hardware-based and use
chips (ASICs) when making forwarding decisions, which makes them much faster
than bridges
switches can have multiple spanning-tree instances, bridges can have only
one
switches can have multiple broadcast domains (one per VLAN)
Network switch explained
Just like hubs and bridges, a switch is used to connect multiple hosts
together, but it has many advantages over them. Switch is an OSI Layer 2
device, which means that it can inspect received traffic and make forwarding
decisions. Each port on a switch is a separate collision domain and can run in
a full duplex mode (photo credit: Wikipedia).
As you can see from the example above, Host A is trying to communicate with
Host C and sends a packet with the Host C’s destination MAC address. The
packet arrives at the switch, which looks at the destination MAC address. The
switch then searches that MAC address in its MAC address table. If the MAC
address is found, the switch then forwards the packet only out the port
connected to the frame’s destination. Hosts connected to other ports will not
receive the frame.
Network router explained
A router is a network device that routes packets from one network to another.
It is usually connected to two or more different networks. When a packet
comes to a router port, the router reads the address information in the packet
to determine out which port the packet will be sent. For example, a router
provides you with the internet access by connecting your LAN with the
Internet.
NOTE
A router is most commonly an OSI Layer 3 device, since its forwarding decision is based
on the information of the OSI Layer 3 – the destination IP address. Routers divide
broadcast domains, provide full duplex communication, and have traffic filtering
capabilities.
The picture below shows a typical home router:
If two hosts from different networks want to communicate, they will need a
router in order to exchange data. Consider the following example:
We have a network of three hosts and a router. Note that each computer is on
a different network. Host A wants to communicate with Host B and sends the
packet with the Host B’s IP address (10.0.0.20) to the router. The router
receives the packet, compares the packet’s destination IP address to the
entries in its routing table and finds a match. It then sends the packet out the
interface associated with the network 10.0.0.0/24. Only Host B will receive
and process the packet. In fact, Host C will not even be aware that the
communication took place.
half-duplex – a port can send data only when it is not receiving data. In other words,
it cannot send and receive data at the same time. Network hubs run in half-duplex mode in
order to prevent collisions. Since hubs are rare in modern LANs, the half-duplex system is
not widely used in Ethernet networks anymore.
full-duplex – all nodes can send and receive on their port at the same time. There
are no collisions in full-duplex mode, but the host NIC and the switch port must support the
full-duplex mode. Full-duplex Ethernet uses two pairs of wires at the same time instead of a
single wire pair like half-duplex.
Each NIC and switch port has a duplex setting. For all links between hosts and
switches, or between switches, the full-duplex mode should be used. However, for all
links connected to a LAN hub, the half-duplex mode should be used in order to
prevent a duplex mismatch that could decrease network performance.
Notice how the first number in the name of the standard represents the speed of the
network in megabits per second. The word base refers to baseband, meaning that
the signals are transmitted without modulation. The last part of the standard name
refers to the cabling used to carry signals. For example, 1000Base-T means that the
speed of the network is up to 1000 Mbps, baseband signaling is used, and the
twisted-pair cabling will be used (T stands for twisted-pair).
Coaxial cabling
A coaxial cable has an inner conductor that runs down the middle of the cable. The
conductor is surrounded by a layer of insulation which is then surrounded by another
conducting shield, which makes this type of cabling resistant to outside interference.
This type of cabling comes in two types – thinnet and thicknet. Both types have
maximum transmission speed of 10 Mbps. Coaxial cabling was previously used in
computer networks, but today are largely replaced by twisted-pair cabling (Photo
credit: Wikipedia)
Twisted-pair cabling
A twisted-pair cable has four pair of wires. These wires are twisted around each
other to reduce crosstalk and outside interference. This type of cabling is common in
current LANs.
Twisted-pair cabling can be used for telephone and network cabling. It comes in two
versions, UTP (Unshielded Twisted-Pair) and STP (Shielded Twisted-Pair). The
difference between these two is that an STP cable has an additional layer of
insulation that protects data from outside interferences.
Here you can see how a twisted pair cable looks like (Photo credit: Wikipedia):
Fiber-optic cabling
This type of cabling uses optical fibers to transmit data in the form of light signals.
The cables have strands of glass surrounded by a cladding material (Photo credit:
Wikipedia):
This type of cabling can support greater cable lengths than any other cabling type
(up to a couple of miles). The cables are also immune to electromagnetic
interference. As you can see, this cabling method has many advantages over other
methods but its main drawback is that it is more expensive.
Single-mode fiber (SMF) – uses only a single ray of light to carry data. Used
for larger distances.
Multi-mode fiber (MMF) – uses multiple rays of light to carry data. Less
expensive than SMF.
ST (Straight-tip connector)
SC (Subscriber connector)
FC (Fiber Channel)
LC (Lucent Connector)
1. Straight-through cable
This cable type has identical wiring on both ends (pin 1 on one end of the cable is
connected to pin 1 at the other end of the cable, pin 2 is connected to pin 2 etc.):
This type of cable is used to connect the following devices:
computer to hub
computer to switch
router to hub
router to switch
Computers and routers use wires 1 and 2 to transmit data and wires 3 and 6 to
receive data. Hubs and switches use wires 1 and 2 to receive data and wires 3 and 6
to send data. That is why, if you want to connect two computers together, you will
need a crossover cable.
2. Crossover cable
With the crossover cable, the wire pairs are swapped, which means that different
pins are connected together – pin 1 on one end of the cable is connected to pin 3 on
the other end, pin 2 on one end is connected to pin 6 on the other end (Photo credit:
Wikipedia):
This type of cable is used when you need to connect two devices that use same
wires to send and receive data. For example, consider connecting two computers
together. If you use straight-through cable, with identical wiring in both ends, both
computers will use wires 1 and 2 to send data. If computer A sends some packets to
computer B, computer A will send that data using wires 1 and 2. That will cause a
problem because computers expect packets to be received on wires 3 and 6, and
your network will not work properly. This is why you need to use a crossover cable
for such connections.
NOTE
Newer devices support the Auto MDI-X capability to automatically detect and configure the
required cable connection type. This removes the need for a specific cable type between certain
devices. Also, note that the Gigabit Ethernet and faster standards use all four wire pairs to
transfer data in both direction simultaneously.
Types of IP addresses
The IP addresses are divided into three different types, based on their operational
characteristics:
In the picture above you can see that the host wants to communicate with the server.
It uses the (unicast) IP address of the server (192.168.0.150) to do so.
*This is because the subnet mask of 255.255.255.0 means that the last octet in the
IP address represents the host bits. And 8 one’s written in decimal is 255.
Classes of IP addresses
TCP/IP defines five classes of IP addresses: class A, B, C, D, and E. Each class has
a range of valid IP addresses. The value of the first octet determines the class. IP
addresses from the first three classes (A, B and C) can be used for host addresses.
The other two classes are used for other purposes – class D for multicast and class
E for experimental purposes.
The system of IP address classes was developed for the purpose of Internet IP
addresses assignment. The classes created were based on the network size. For
example, for the small number of networks with a very large number of hosts, the
Class A was created. The Class C was created for numerous networks with small
number of hosts.
For the IP addresses from Class A, the first 8 bits (the first decimal number)
represent the network part, while the remaining 24 bits represent the host part. For
Class B, the first 16 bits (the first two numbers) represent the network part, while the
remaining 16 bits represent the host part. For Class C, the first 24 bits represent the
network part, while the remaining 8 bits represent the host part.
NOTE
The system of network address ranges described here is generally bypassed today by use of
the Classless Inter-Domain Routing (CIDR) addressing.
Special IP address ranges that are used for special purposes are:
In the example above you can see that two unrelated organizations use the same
private IP network (10.0.0.0/24) inside their respective internal networks. Because
private IP addresses are not globally unique, both organizations can use private IP
addresses from the same range. To access the Internet, the organizations can use a
technology called Network Address Translation (NAT), which we will describe in the
later lessons.
There are three ranges of addresses that can be used in a private network (e.g. your
home LAN or office)
10.0.0.0 – 10.255.255.255
172.16.0.0 – 172.31.255.255
192.168.0.0 – 192.168.255.255
Internet routers are configured to discard any packets coming from the private IP
address ranges, so these addresses are not routable on the Internet.
Subnetting explained
Subnetting is the practice of dividing a network into two or more smaller networks. It
increases routing efficiency, enhances the security of the network and reduces the
size of the broadcast domain.
In the picture above we have one huge network: 10.0.0.0/24. All hosts on the
network are in the same subnet, which has the following disadvantages:
a single broadcast domain – all hosts are in the same broadcast domain. A
broadcast sent by any device on the network will be processed by all hosts, creating
lots of unnecessary traffic.
network security – each device can reach any other device on the network,
which can present security problems. For example, a server containing sensitive
information shouldn’t be in the same network as user’s workstations.
organizational problems – in a large networks, different departments are
usually grouped into different subnets. For example, you can group all devices from
the Accounting department in the same subnet and then give access to sensitive
financial data only to hosts from that subnet.
Subnet mask
An IP address is divided into two parts: network and host parts. For example, an IP
class A address consists of 8 bits identifying the network and 24 bits identifying the
host. This is because the default subnet mask for a class A IP address is 8 bits long.
(or, written in dotted decimal notation, 255.0.0.0). What does it mean? Well, like an
IP address, a subnet mask also consists of 32 bits. Computers use it to determine
the network part and the host part of an address. The 1s in the subnet mask
represent a network part, the 0s a host part.
Computers works only with bits. The math used to determine a network range is
binary AND.
Let’s say that we have the IP address of 10.0.0.1 with the default subnet mask of 8
bits (255.0.0.0).
First, we need to convert the IP address to binary:
Computers then use the AND operation to determine the network number:
The computer can then determine the size of the network. Only IP addresses that
begins with 10 will be in the same network. So, in this case, the range of addresses
in this network is 10.0.0.0 – 10.255.255.255.
NOTE
A subnet mask must always be a series of 1s followed by a series of 0s.
Create subnets
There are a couple of ways to create subnets. In this article we will subnet a class C
address 192.168.0.0 that, by default, has 24 subnet bits and 8 host bits.
2x = number of subnets. x is the number of 1s in the subnet mask. With 1 subnet bit,
we can have 21 or 2 subnets. With 2 bits, 22 or 4 subnets, with 3 bits, 23 or 8 subnets,
etc.
2y – 2 = number of hosts per subnet. y is the number of 0s in the subnet mask.
Subnetting example
An example will help you understand the subnetting concept. Let’s say that we need
to subnet a class C address 192.168.0.0/24. We need two subnets with 50 hosts per
subnet. Here is our calculation:
1. Since we need only two subnets, we need 2 1 subnet bits. In our case, this means
that we will take one bit from the host part. Here is the calculation:
First, we have a class C address 192.168.0.0 with the subnet mask of 24. Let’s
convert them to binary:
192.168.0.0 = 11000000.10101000.00000000.00000000
255.255.255.0 = 11111111.11111111.11111111.00000000
We need to take a single zero from the host part of the subnet mask. Here is our
new subnet mask:
255.255.255.128 = 11111111.11111111.11111111.10000000
2. We need 50 hosts per subnet. Since we took one bit from the host part, we are left
with seven bits for the hosts. Is it enough for 50 hosts? The formula to calculate the
number of hosts is 2y – 2, with y representing the number of host bits. Since 2 7 – 2 is
126, we have more than enough bits for our hosts.
192.168.0.0/25 – the first subnet has the subnet number of 192.168.0.0. The range
of IP addresses in this subnet is 192.168.0.0 – 192.168.0.127.
Before CIDR, public IP addresses were assigned based on the class boundaries:
Class A – the classful subnet mask is /8. The number of possible IP
addresses is 16,777,216 (2 to the power of 24).
Class B – the classful subnet mask is /16. The number of addresses is
65,536
Class C – the classful subnet mask is /24. Only 256 addresses available.
Some organizations were known to have gotten an entire Class A public IP address
(for example, IBM got all the addresses in the 9.0.0.0/8 range). Since these
addresses can’t be assigned to other companies, there was a shortage of available
IPv4 addresses. Also, since IBM probably didn’t need more than 16 million IP
addresses, a lot of addresses were unused.
To combat this, the classful network scheme of allocating the IP address was
abandoned. The new system was classsless – a classful network was split into
multiple smaller networks. For example, if a company needs 12 public IP addresses,
it would get something like this: 190.5.4.16/28.
The number of usable IP addresses can be calculated with the following formula:
In the example above, the company got 14 usable IP addresses from the 190.5.4.16
– 190.5.4.32 range because there are 4 host bits and 2 to the power of 4 minus 2 is
14 The first and the last address are the network address and the broadcast
address,,respectively. All other addresses inside the range could be assigned to
Internet hosts.
Ping explained
ping is perhaps the most commonly used tool to troubleshoot a network. Ping
(Packet Internet Groper) is included with most operating systems. It is invoked
using a ping command and uses ICMP (Internet Control Message Protocol) to
reports errors and provides information related to IP packet processing. Ping works
by sending an ICMP echo request message to the specified IP address. If the
computer with the destination IP address is reachable, it responds with an ICMP
echo reply message.
Protocol [ip] – specify the protocol, such as appletalk, clns, ip, novell, apollo,
vines, decnet, or xns. The default is ip.
Target IP address – specify the IP address or the hostname of the host to
ping.
Repeat count – specify the number of ping packets that will be sent to the
destination address. 5 by default.
Datagram size – specify the size of the ping packet (in bytes). The default is
100 bytes.
Timeout in seconds – specify the timeout interval. The default is 2 seconds.
The echo reply needs to be received before the timeout expires in order for ping to
be successful.
Extended commands – specify whether or not a series of additional
commands will appear. The default is no. If you type yes additional arguments will be
shown.
Source address or interface – specify the interface or the IP address of the
router to use as the source address for the ping packets.
Type of service – specifies the Type of Service (ToS). This is the Internet
service’s quality selection. The default is 0.
Set DF bit in IP header? – specify whether or not the Don’t Fragment (DF) bit
will be set on the ping packet. If yes is entered, the Don’t Fragment option does not
allow the packet to be fragmented. The default is no.
Validate reply data? – specify whether or not to validate the reply data. The
default is no.
Data pattern – specify the data pattern. Data patterns are used to
troubleshoot framing errors and clocking problems on serial lines. The default
is [0xABCD].
Loose, Strict, Record, Timestamp, Verbose – specify the IP header
options.
Sweep range of sizes – specify the sizes of the ping echo packets that are
sent. This parameter is used to determine the minimum sizes of the MTUs
configured on the nodes along the path to the destination address. The default is no.
The extended ping command is most often used to change the source IP address of
the ping echo packets. Consider the following example:
By default, routers choose the IP address of the outgoing interface as the source IP
address for ping echo packets. This means that R2 will use the IP address of the
Fa0/1 interface (10.0.0.1) as the source IP address for the ping packets sent to
10.0.0.2 (R1). Let’s try to ping R1 using the standard ping command:
R2#ping 10.0.0.2
!!!!!
As you can see from the output, the ICMP replies were received. However, I can run
the extended ping command to change the source IP address to the IP address of
the R2 Fa0/0 interface (192.168.5.1). This is done to ensure that R1 knows about the
192.168.5.1 network (in other words, that it knows where to send packets destined
for the 192.168.5.0/24 network, which could indicate routing problems).
R2#ping
Protocol [ip]:
.....
In the output above you can see that no echo replies were received after I’ve
changed the source IP of the ping packets. This means that R1 doesn’t know how to
reach the 192.168.5.0/24 network.
Traceroute explained
Traceroute is a command-line interface based tool used to identify the path used by
a packet to reach its target. This tool also uses ICMP messages, but unlike ping, it
identifies every router in a path taken by the packets. Traceroute is useful when
troubleshooting network problems because it can help identify where exactly the
problem is. You can figure out which router in the path to an unreachable target
should be examined more closely as the probable cause of the network’s failure.
Traceroute command on Unix works slighty different than the Windows version. It
uses UDP packets with a large destination port number (33434 to 33534) that is
unlikely to be used by any application at the destination host. Like the Windows
version of the command, traceroute on Unix uses TTL to get the IP addresses of the
intermediary routers. When a destination host is reached, it replies with an ICMP port
unreachable message.
traceroute command
The traceroute command on a Cisco device can be used to identify the path used by
a packet to reach its target. It identifies all the routers in the path from the source
host to destination host and it can be useful when troubleshooting network problems.
Using this command you can figure out which router in the path to an unreachable
target should be examined more closely as the probable cause of the network’s
failure.
R1#traceroute 172.16.0.2
You can see that the traceroute command has listed the IP addresses of all of the
routers in the path to the destination. Now let’s assume that the router R3 goes
down. Consider the command output now:
R1#traceroute 172.16.0.2
2 10.0.0.1 !H * !H
3**
Wildcard masks
Wildcard masks are used to specify a range of network addresses. They are
commonly used with routing protocols (like OSPF) and access lists.
Just like a subnet mask, a wildcard mask is 32 bits long. It acts as an inverted subnet
masks, but with wildcard mask, the zero bits indicate that the corresponding bit
position must match the same bit position in the IP address. The one bits indicate
that the corresponding bit position doesn’t have to match the bit position in the IP
address.
Here is an example of using a wildcard mask to include only the desired interfaces in
the OSPF routing process:
Router R1 has three networks directly connected. To include only the 10.0.1.0
subnet in the OSPF routing process, the following network command can be used:
R1(config)#router ospf 1
10.0.1.0 = 00001010.00000000.00000001.00000000
0.0.0.255 = 00000000.0000000.00000000.11111111
The theory says that the zero bits of the wildcard mask have to match the same
position in the IP address. So, let’s write the wildacard mask below the IP address:
00001010.00000000.00000001.00000000
00000000.00000000.00000000.11111111
As you can see from the output above, the last octet doesen’t have to match,
because the wildcard mask bits are all ones. The first 24 bits have to match,
because of the wildcard mask bits of all zeros. So, in this case, wildcard mask will
match all addresses that begins with 10.0.1.X. In our case, only one network will be
matched, 10.0.1.0/24.
What is we want to match both 10.0.0.0/24 and 10.0.1.0/24? Than we will have to
use different wildcard mask. We need to use the wildcard mask of 0.0.1.255. Why is
that? Well, we again need to write down the addresses in binary:
00001010.00000000.00000000.00000000 = 10.0.0.0
00001010.00000000.00000001.00000000 = 10.0.1.0
00000000.00000000.00000001.11111111 = 0.0.1.255
From the output above, we can see that only the first 23 bits have to match (notice
that the third octet of the wildcard mask has a 1 at the end). That means that all
addresses in the range of 10.0.0.0 – 10.0.1.255 will be matched. So, in our case, we
have successfully matched both addresses, 10.0.0.0 and 10.0.1.0.
NOTE
Wildcard mask of all zeros (0.0.0.0) means that the entire IP address have to match in order for a
statement to execute. For example, if we want to match only the IP address of 192.168.0.1, the
command used would be 192.168.0.1 0.0.0.0.
A wildcard mask of all ones (255.255.255.255) means that no bits have to match. This basically
means that all addresses will be matched.
The cable is of light blue color with a DB-9 connector at one end and a RJ-45
connector at the other:
You connect the rollover cable to the serial port on your computer. On the Cisco
device, there is a blue console port (usually marked in blue) to which you connect
the other end of the cable:After the cable is connected, you can access the device
using the terminal emulation software (e.g. Putty or HyperTerminal). You need to
configure the PC’s serial port to match the console port settings. Here are the
defaults:
9600 baud
no hardware flow control
8 data bits
no parity bits
1 stop bit
NOTE
Newer Cisco devices usually include a USB console port, since serial ports are rare on modern
PCs.
The TCP/IP suite is named after its most important protocols, the Transmission
Control Protocol (TCP) and the Internet Protocol (IP). Some of the protocols included
in the TCP/IP suite are:
The following table shows which protocols reside on which layer of the TCP/IP
model:
TCP explained
One of the main protocols in the TCP/IP suite is Transmission Control Protocol
(TCP). TCP provides reliable and ordered delivery of data between applications
running on hosts on a TCP/IP network. Because of its reliable nature, TCP is used
by applications that require high reliability, such as FTP, SSH, SMTP, HTTP, etc.
One other notable characteristic of TCP is its reliable delivery. TCP uses sequence
numbers to identify the order of the bytes sent from each computer so that the data
can be reconstructed in order. If any data is lost during the transmission, the sender
can retransmit the data.
source port – the port number of the application on the host sending the
data.
destination port – the port number of the application on the host receiving
the data.
sequence number – used to identify each byte of data.
acknowledgment number – the next sequence number that the receiver is
expecting.
header length – the size of the TCP header.
reserved – always set to 0.
flags – used to set up and terminate a session.
window – the window size the sender is willing to accept.
checksum – used for error-checking of the header and data.
urgent – indicates the offset from the current sequence number, where the
segment of non-urgent data begins.
options – various TCP options, such as Maximum Segment Size (MSS) or
Window Scaling.
NOTE
TCP is a Transport layer protocol (Layer 4 of the OSI model).
As the name implies, the three way handshake process consists of three steps:
1.
1. Host A initiates the connection by sending the TCP SYN packet to the
destination host. The packet contains the random sequence number (e.g. 5432)
which marks the beginning of the sequence numbers for data that the Host A will
transmit.
2. The Server receives the packet and responds with its own sequence
number. The response also includes the acknowledgment number, which is Host A’s
sequence number incremented by 1 (in our case, that would be 5433).
3. Host A acknowledges the response of the Server by sending the
acknowledgment number, which is the Server’s sequence number incremented by 1.
1. The client application that wants to close the connection sends a TCP
segment with the FIN (Finished) flag set to 1.
2. The server receives the TCP segment and acknowledges it with the ACK
segment.
3. Server sends its own TCP segment with the FIN flag set to 1 to the client in
order to terminate the connection.
4. The client acknowledges the server’s FIN segment and closes the connection.
UDP explained
One other important protocol in the TCP/IP site is User Datagram Protocol (UDP).
This protocol is basically a scaled-down version of TCP. Just like TCP, this protocol
provides delivery of data between applications running on hosts on a TCP/IP
network, but, unlike TCP, it does not sequence the data and does not care about the
order in which the segments arrive at the destination. Because of this it is considered
to be an unreliable protocol. UDP is also considered to be a connectionless protocol,
since no virtual circuit is established between two endpoints before the data transfer
takes place.
Because it does not provide many features that TCP does, UDP uses much less
network resources than TCP. UDP is commonly used with two types of applications:
applications that are tolerant of the lost data – VoIP (Voice over IP) uses
UDP because if a voice packet is lost, by the time the packet would be retransmitted,
too much delay would have occurred, and the voice would be unintelligible.
applications that have some application mechanism to recover lost
data – Network File System (NFS) performs recovery with application layer code, so
UDP is used as a transport-layer protocol.
The UDP header is 8 bytes long and consists of the following fields:
source port – the port number of the application on the host sending the
data.
destination port – the port number of the application on the host receiving
the data.
length – the length of the UDP header and data.
checksum – checksum of both the UDP header and UDP data fields.
NOTE
UDP is a Transport layer protocol (Layer 4 of the OSI model).
Ports explained
A port is a 16-bit number used to identify specific applications and services. TCP
and UDP specify the source and destination port numbers in their packet headers
and that information, along with the source and destination IP addresses and the
transport protocol (TCP or UDP), enables applications running on hosts on a TCP/IP
network to communicate.
Applications that provide a service (such as FTP and HTTP servers) open a port on
the local computer and listen for connection requests. A client can request the
service by pointing the request to the application’s IP address and port. A client can
use any locally unused port number for communication. Consider the following
example:
In the picture above you can see that a host with an IP address of 192.168.0.50
wants to communicate with the FTP server. Because FTP servers use, by default,
the well-known port 21, the host generates the request and sends it to the FTP
server’s IP address and port. The host use the locally unused port of 1200 for
communication. The FTP server receives the request, generates the response,and
sends it to the host’s IP address and port.
Port numbers are from 0 to 65535. The first 1024 ports are reserved for use by
certain privileged services:
NOTE
The combination of an IP address and a port number is called a socket. In our example the
socket would be 192.168.0.50:1200.
ARP request packets are sent to the broadcast addresses (FF:FF:FF:FF:FF:FF for
the Ethernet broadcasts and 255.255.255.255 for the IP broadcast).
All operating systems maintain ARP caches that are checked before sending an
ARP request message. Each time a host needs to send a packet to another host on
the LAN, it first checks its ARP cache for the correct IP address and matching MAC
address. The addresses will stay in the cache for a couple of minutes. You can
display ARP entries in Windows by using the arp -a command:
DHCP & DNS
DHCP (Dynamic Host Configuration Protocol)
DHCP is a network protocol that is used to assign various network parameters to a
device. This greatly simplifies administration of a network, since there is no need to
assign static network parameters for each device.
subnet mask
default gateway
domain name
DNS server
Cisco routers can be configured as both DHCP client and DHCP server.
2: The DHCP servers receive the DHCP Discover packet and respond with DHCP
Offer packets, offering IP addressing information.
3: If the client receives the DHCP Offer packets from multiple DHCP servers, the first
DHCP Offer packet is accepted. The client responds by broadcasting a DHCP
Request packet, requesting the network parameters from the server that responded
first.
To use DNS, you must have a DNS server configured to handle the resolution
process. A DNS server has a special-purpose application installed. The application
maintains a table of dynamic or static hostname-to-IP address mappings. When a
user request some network resource using a hostname, (e.g. by
typing www.google.com in a browser), a DNS request is sent to the DNS server
asking for the IP address of the hostname. The DNS server then replies with the IP
address. The user’s browser can now use that IP address to access
www.google.com.
The picture below shows a sample DNS record, taken from a DNS server:
Here you can see that the host with the hostname APP1 is using the IP address
of 10.0.0.3.
NOTE
DNS uses a well-known UDP port 53.
To use telnet, you must have a software (Telnet client) installed. On a remote device,
a Telnet server must be installed and running. Telnet uses the TCP port 23 by
default.
One of the greatest disadvantages of this protocol is that all data, including
usernames and passwords, is sent in clear text, which is a potential security risk.
This is the main reason why Telnet is rarely used today and is being replaced by a
much secure protocol called SSH. Here you can find information about setting up
Telnet access on your Cisco device.
NOTE
The word telnet can also refer to the software that implements the telnet protocol.
Setting up Telnet
To access a Cisco device using telnet, you first need to enable remote login. Cisco
devices usually supports 16 concurrent virtual terminal sessions, so the first
command usually looks like this:
HOSTNAME(config)line vty 0 15
To enable remote login, the login command is used from the virtual terminal session
mode:
HOSTNAME(config-vty)login
HOSTNAME(config-vty)password PASSWORD
Let’s try this on a real router. First, we will try to access the router without enabling
telnet on a device:
As you can see in the picture above, we can not access a Cisco device using telnet
before setting up the password. Let’s do that:
Like Telnet, a user accessing a remote device must have an SSH client installed. On
a remote device, an SSH server must be installed and running. SSH uses the TCP
port 22 by default.
Here is an example of creating an SSH session using Putty, a free SSH client:
NOTE
SSH is the most common way to remotely access and manage a Cisco device. Here you can find
information about setting up SSH access on your Cisco device.
Setting up SSH
To enable secure access to your Cisco device, you can use SSH instead of Telnet.
SSH uses encryption to secure data from eavesdropping.
To enable SSH, the following steps are required:
The following example shows the configuration of the first three steps:
A user wants to transfer files from Host A to the FTP server. The user will start an
FTP client program (in this example, Filezilla), and initiate the connection:
In the example above, the anonymous authentication was used, so the user was not
asked to provide the password. The client can now transfer files from and to the FTP
server using the graphical interface.
NOTE
FTP uses two TCP ports: port 20 for sending data and port 21 for sending control
commands. The protocol supports the use of authentication, but like Telnet, all data is sent in
clear text, including usernames and passwords.
TFTP (Trivial File Protocol)
TFTP is a network protocol used to transfer files between remote machines. It is a
simple version of FTP, lacking some of the more advanced features FTP offers, but
requiring less resources than FTP.
Because of it’s simplicity TFTP can be used only to send and receive files. This
protocol is not widely used today, but it still can be used to save and restore a router
configuration or to backup an IOS image.
Clients and web servers use request-response method to communicate with each
other, with clients sending the HTTP Requests and servers responding with the
HTTP Responses. Clients usually send their requests using GET or POST methods,
for example GET /homepage.html. Web servers responds with a status message
(200 if the request was successful) and sends the requested resource.
Web servers usually use a well-known TCP port 80. If the port is not specified in a
URL, browsers will use this port when sending HTTP request. For example, you will
get the same result when requesting http://google.com and http://google.com:80.
NOTE
The version of HTTP most commonly used today is HTTP/1.1. A newer version, HTTP/2, is
available and supported by most browser.
HTTPS is commonly used to create a secure channel over some insecure network,
e.g. Internet. A lot of traffic on the Internet is unencryped and susceptible to sniffing
attacks. HTTPS encrypts sensitive information, which makes a connection secure.
NOTE
HTTPS uses a well-known TCP port 443. If the port is not specified in a URL, browsers will use
this port when sending HTTPS request. For example, you will get the same result when
requesting https://gmail.com and https://gmail.com:443.
NTP (Network Time Protocol)
Network Time Protocol (NTP) is an application layer protocol used for clock
synchronization between hosts on a TCP/IP network. The goal of NTP is to ensure
that all computers on a network agree on the time, since even a small difference can
create problems. For example, if there is more than 5 minutes difference on your
host and the Active Directory domain controller, you will not be able to login into your
AD domain.
NTP uses a hierarchical system of time sources. At the top of the structure are highly
accurate time sources – typically atomic or GPS clocks. These clocks are known as
stratum 0 servers. Stratum 1 servers are directly linked to stratum 0 servers and
computers run NTP servers that deliver the time to stratum 2 servers, and so on
(image source: Wikipedia):
NTP uses a client-server architecture; one host is configured as the NTP server and
all other hosts on the network are configured as NTP clients. Consider the following
example:
Host A is configured to use a public NTP server uk.pool.ntp.org. Host A will
periodically send an NTP request to the NTP server. The NTP server will provide the
accurate data and time, so Host A can synchronize its clock.
NOTE
NTP uses a well-known UDP port 123. The current version is NTPv4, and it is backward
compatible with NTPv3.
When a DHCP client boots up, it looks for a DHCP server in order to obtain network
parameters. If the client can’t communicate with the DHCP server, it uses APIPA to
configure itself with an IP address from the APIPA range. This way, the host will still
be able to communicate with other hosts on the local network segment that are also
configured for APIPA.
The host on the left is configured as DHCP client. The host boots up and looks for
DHCP servers on the network. However, the DHCP server is down and can’t
respond to the host. After some time (from a couple of seconds to a couple of
minutes, depending on the operating system) the client auto-configures itself with an
address from the APIPA range (e.g. 169.254.154.22).
NOTE
If your host is using an IP address from the APIPA range, there is usually a problem on the
network. Check the network connectivity of your host and the status of the DHCP server.
The APIPA service also checks regularly for the presence of a DHCP server (every
three minutes). If it detects a DHCP server on the network, the DHCP server
replaces the APIPA networking addresses with dynamically assigned addresses.
Host A wants to test whether it can reach Server over the network. Host A will start
the ping utility that will send ICMP Echo Request packets to Server. If Server is
reachable, it will respond with ICMP Echo Reply packets. If Host A receives no
response from Server, there might be a problem on the network.
NOTE
ICMP messages are encapsulated in IP datagrams, which means that they don’t use higher level
protocols (such as TCP or UDP) for transmission.
C:\>ping 192.168.8.11
IP header
An IP header is a prefix to an IP packet that contains information about the IP
version, length of the packet, source and destination IP addresses, etc. It consists of
the following fields:
Here is a description of each field:
Version – the version of the IP protocol. For IPv4, this field has a value of 4.
Header length – the length of the header in 32-bit words. The minumum
value is 20 bytes, and the maximum value is 60 bytes.
Priority and Type of Service – specifies how the datagram should be
handled. The first 3 bits are the priority bits.
Total length – the length of the entire packet (header + data). The minimum
length is 20 bytes, and the maximum is 65,535 bytes.
Identification – used to differentiate fragmented packets from different
datagrams.
Flags – used to control or identify fragments.
Fragmented offset – used for fragmentation and reassembly if the packet is
too large to put in a frame.
Time to live – limits a datagram’s lifetime. If the packet doesn’t get to its
destination before the TTL expires, it is discarded.
Protocol – defines the protocol used in the data portion of the IP datagram.
For example, TCP is represented by the number 6 and UDP by 17.
Header checksum – used for error-checking of the header. If a packet arrives
at a router and the router calculates a different checksum than the one specified in
this field, the packet will be discarded.
Source IP address – the IP address of the host that sent the packet.
Destination IP address – the IP address of the host that should receive the
packet.
Options – used for network testing, debugging, security, and more. This field
is usually empty.
Below you can see how IOS looks like when a Cisco device is started for the first
time, using a 3745 router as an example:
Cisco 3745 (R7000) processor (revision 2.0) with 249856K/12288K bytes of memory.
R7000 CPU at 350MHz, Implementation 39, Rev 2.1, 256KB L2, 512KB L3 Cache
5 FastEthernet interfaces
1. Console access – this type of access is usually used to configure newly acquired
devices. These devices usually don’t have an IP address configured, and therefore
can not be accessed through the network. Most of the Cisco devices have a physical
console port. This port can be connected to a computer using a rollover cable, a
special type of cable with pins on one end reversed on the other end of the cable.
The rollover cable is a serial cable, which means that you can’t just plug it in an
Ethernet port on your computer. You will need an adapter that converts an interface
on your computer (usually a 9-pin serial interface) into RJ-45.
NOTE
Newer Cisco devices usually include a USB console port, since serial ports are rare on modern
PCs.
2. Telnet access – this type of access used to be a common way to access network
devices. Telnet is an terminal emulation program that enables you to access IOS
through the network and configure the device remotely. The device that is being
configured needs to have an Telnet server installed and an IP address configured.
Telnet uses a well known TCP port 23. One of the biggest disadvantages of this
protocol is that is sends all data as clear-text, which includes the passwords! This is
the reason why this type of access is usually not used anymore. Instead, SSH is
usually used.
3. SSH access – like Telnet, this access type enables you to configure devices
remotely, but it adds an extra layer of security by encrypting all communications
using public-key cryptography. SSH uses well known TCP port 22.
IOS modes
IOS has many different modes. There are three main modes any many submodes.
We will describe the three main modes and one submode.
user EXEC mode – the default mode for the IOS CLI. This is the mode that a
user is placed in after accessing the IOS. Only basic commands (like ping or telnet)
are available in this mode.
privileged EXEC Mode – this mode is accessed by typing
the enable command from the user EXEC mode. This mode can be password
protected. In this mode a user can view and change a device’s configuration.
global configuration mode – this mode can be accessed by typing
the configure terminal command from the privileged EXEC mode. It is used to
change the device’s configuration.
A global configuration mode can have many submodes. For example, when a user
wants to configure an interface, he will have to enter the interface submode by
entering the interface INTERFACE_TYPE INTERFACE_NUMBER command
(e.g. interface FastEthernet 0/1 ) from the global configuration mode. This submode
can have many commands that are specific for the interface.
We’ll describe each of the modes mentioned above in more detail in the following
lectures.
Would you like to enter the initial configuration dialog? [yes/no]: yes
At any point you may enter a question mark '?' for help.
hostname R1
line vty 0 4
password cisco
interface Vlan1
shutdown
no ip address
interface GigabitEthernet0/0
shutdown
no ip address
interface GigabitEthernet0/1
shutdown
no ip address
!
interface GigabitEthernet0/2
no shutdown
end
Building configuration...
[OK]
The wizard guides you through the initial configuration of your device and will create
an initial configuration file. The setup mode is useful when you are unfamiliar with the
IOS CLI, but once you learn the basics of CLI, you probably won’t use this mode
ever again.
NOTE
You can enter the setup mode at any time from the command line by typing the setup command
from the privileged mode. To exit the setup mode without saving any changes, press CRTL+C.
As you can see, most of the commands available are used to show statistics and
perform some basic troubleshooting. The prompt on the left side of the screen
always displays the device hostname (R1 in this case), followed by the character >.
All commands can be abbreviated to their first letters of the command name. For
example, you can abbreviate ping by typing pin, because no other command in the
User EXEC mode IOS mode begins with these letters.
The prompt for this mode shows # after the device hostname.
Global configuration mode commands
To change a device configuration, you need to enter the global configuration mode.
This mode can be accessed by typing configure terminal (or conf t, the abbreviated
version of the command) from the enable mode. The prompt for this mode
is hostname(config).
Global configuration mode commands are used to configure a device. You can set a
hostname, configure authentication, set an IP address for an interface, etc. From this
mode you can also access submodes, for example the interface mode, from where
you can configure interface options.
You can get back to a privileged EXEC mode by typing the end command. You can
also type CTRL + C to exit the configuration mode.
Submode commands
A global configuration mode contains many submodes. For example, if you want to
configure an interface you have to enter that interface configuration mode. Each
submode contains only commands that pertain to the resource that is being
configured.
To enter the interface configuration mode you need to specify which interface you
would like to configure. This is done by using the interface
INTERFACE_TYPE/INTERFACE_NUMBER global configuration command,
where INTERFACE_TYPE represents the type of an interface (Ethernet,
FastEthernet, Serial…) and INTERFACE_NUMBER represents the interface
number, since CIsco devices usually have more than one physical interface. Once
inside the interface configuration mode, you can get a list of available commands by
typing the “?” character. Each submode has its own prompt. Notice how the
command prompt was changed to Router(config-if) after I’ve entered the interface
submode:
Router#?
Exec commands:
--More--
If the output spans more than one page, press the spacebar to display the following
page of commands, or press Enter to go one command at a time. To quit the output,
press q.
Router#de?
debug delete
In the picture above you can see that we’ve displayed all commands that start
with de.
If the command is more than one word long, you can use the question mark to
display the next command in a string:
Router#debug ?
Router#debug eigrp ?
In the picture above you can see that we’ve displayed all commands that can follow
the command debug. We then displayed all commands that can follow the
commands debug eigrp.
You can also autocomplete a command. Just type the first few characters and
press Tab. If there is only a single match, IOS will complete the command.
You don’t have to type an entire word to finish a command. Just can type just the
first letter or a couple of letters, and if there is only a single match, IOS will
understand what are you trying to accomplish. For example, you can type sh ip int
b instead of the longer version, show ip interface brief:
Router#sh ip int b
Note that we were able to execute the command above because each set of
characters had only one match in the list of commands. If we’ve typed sh ip in
b instead, IOS would not have understood our intention:
Router#sh ip in b
startup configuration
running configuration
Immediately after you type a command in the global configuration mode, it will be
stored in the running configuration. A running configuration resides in a device’s
RAM, so if a device loses power, all configured commands will be lost.
To avoid this scenario, you need to copy your current configuration into the startup
configuration. A startup configuration is stored in the nonvolatile memory of a device,
which means that all configuration changes are saved even if the device loses
power.
To copy your running configuration into the startup configuration you need to type
the command copy running-configuration startup-configuration.
Hostname command
The hostname command is used to configure the device hostname. Because this
command changes a device configuration, it must be entered in the global
configuration mode. After typing the command, the prompt will change and display
the new hostname.
You may notice that the promt has changed to reflect the mode you are currently in.
For the interface mode the HOSTNAME#(config-if) prompt is shown.
Once inside the interface mode, you can enable an interface by typing the no
shutdown command.
IP address command
The ip address interface mode command is used to assign an IP address to an
interface. The syntax of this command is ip address IP_ADDRESS SUBNET_MASK.
For example, if we want to assign an IP address of 10.0.0.1 with the subnet
mask 255.0.0.0 to a interface, we would use the following command:
What if you had made a mistake and written the ip address 10.0.0.2
255.0.0.0 command instead of the command above? Well, you can remove the
wrong IP address by typing the same command, but this time with the no keyword in
front of it, in our case no ip address. You can remove any command from your IOS
configuration by using the no keyword in front of the command.
Setting up passwords
Each Cisco IOS device has the built-in authentication features. There are three basic
ways to configure authentication on a device:
HOSTNAME(config) line console 0
HOSTNAME(config-line) login
This will force a user to type the password when trying to access the device through
the console port.
Configure a password for the telnet access – by default, the telnet access
is disabled. You need to enable it. This is done using the following sequence of
commands:
HOSTNAME(config-line) login
The first command defines a range of virtual terminal sessions that you would like to
configure. A virtual session can be a telnet or SSH session. Cisco devices usually
supports 16 concurrent VTY sessions. So, this command usually looks like this: line
vty 0 15.
The login command allows a remote access to a device. It is required in order for
telnet to work.
Configure a password for the privileged EXEC mode – from the privileged
EXEC mode you can enter the global configuration mode and change the
configuration of a device. Therefore it is important to prevent an unauthorized user
from entering the global configuration mode. You can do that by setting up a
password to enter the privileged EXEC mode. This can be done in two ways:
It is important to note that this type of password encryption is not consider especially
secure, since the algorithm used can be easily cracked. Cisco recommends using
this command only with additional security measures.
Configuring banners
You can display a banner on a Cisco device. A banner is usually shown before the
login prompt. It is usually some text that appears on the screen when a user connect
to the device (e.g. some legal information).
The most commonly used banner is the Message Of The Day (MOTD) banner. This
banner, if configured, is shown before the login prompt to every user that is trying to
establish a session with the device. The following global configuration command is
used to configure a MOTD banner:
A delimiting character is a character of your choice. Its purpose is to signify the start
and end of a text that will appear in the banner. For example, the command banner
motd # Unauthorized access forbidden! # will show the following text: Unauthorized
access forbidden!.
Show version command
The show version command is used to display information about a Cisco device. The
command can be entered in both the user EXEC and privileged EXEC mode. By
using this command you can find out many useful information about your Cisco
device, such as:
You can set a number of command saved in the buffer for the current terminal
session by using the terminal history size NUMBER command from the user EXEC
or privileged EXEC mode.
NOTE
Another way to recall your command from the history buffer is by using the up arrow key on your
keyboard. Most recent command is recalled first.
Show running-configuration & show startup-configuration commands
After you have changed the configuration of your device you can verify its
configuration. To dispay the current configuration, type show running-
configuration from the privileged EXEC mode. This show the configuration that is
stored in a device’s RAM.
After you have stored your running configuration into the startup configuration, you
can view the saved configuration using the show startup-config command from the
privileged EXEC mode.
This command shows the configuration that is currenty stored in the device’s
NVRAM. This configuration will be loaded next time the device is restarted.
show command
We’ve already mentioned a couple of show commands in the previous sections, so
you should already we somewhat aware of this command. This command is used to
display the device’s configuration, statistics, command history, interface status…
The show command is invoked from the enable mode and can accept a lot of
parameters:
Floor1#show ?
...
interface GigabitEthernet0/0
description WAN to London
no ip address
duplex auto
speed auto
shutdown
!
interface GigabitEthernet0/1
no ip address
duplex auto
speed auto
shutdown
!
Router(config-if)#no desc
Router(config)#int g0/0
Router(config-if)#
In the example above you can see that we’re currently in the interface submode. We
want to get more information about the interface with the show interface
Fa0/1 command, but we got an error because the command is not available in this
mode. However, if we use the do keyword in front of the command, the command
will succeed:
--More--
The command was now executed because of the do keyword. Notice that we’re still
in the interface submode and we can continue with the interface configuration.
Ports on an IOS device
Cisco uses the term interface to refer to physical ports on an IOS device. Interfaces
can be configured with different settings, depending on the type of the interface and
whether you are configuring an interface on a router or a switch. Let’s look at the
Cisco 1841 router as an example:
1. Slot 1 Network Card expansion slot – you can buy and install an additional
interface card of various types to fit in here.
2. Kensington Security Slot – you can physical secure the router with a cable
here to help prevent theft.
3. Fast Ethernet port 0/1 and status indicator LED.
4. Console port – you can connect directly to the router’s management
command line interface here via your laptop and a console cable.
5. Slot 0 Network Card expansion slot – another slot for additional interface
cards. Note the the numbering is from right to left.
6. CompactFlash memory card slot – the IOS operating system image lives
here.
7. USB port – You can plug in a USB drive here to move files to and from the
router.
8. Fast Ethernet port 0/0 and status indicator LED.
9. Aux port – You can connect a legacy modem here for out of band (outside the
normal network path) management. Not commonly used in modern networks.
10. On/Off switch.
11. Input power socket.
To display basic information about the device interfaces in IOS, use the show ip
interface brief command from the privileged exec mode. This is one of the most
commonly used commands on Cisco devices:
In the output above we can see that this router has 2 physical interfaces –
FastEthernet0/0 and FastEthernet0/1.
Interface – displays the type of the interface, in this case Fast Ethernet 0/0.
The first zero specifies the physical slot on the router, while the second zero
specifies the port number.
IP-Address – displays the interface’s IP address.
OK? – YES in this column signifies that the IP address is currently valid.
Method – manual in this column means that the interface has been manually
configured. DHCP means that the interface has been configured using DHCP.
Status – up indicates that the interface is administratively up.
Protocol – up indicates that the interface is operational.
Router(config)#interface f0/0
Router(config-if)#speed 100
In the example above you can see that we’ve configured the speed option for the
interface Fast Ethernet 0/0.
Router(config)#int f0/0
Router(config-if)#no shutdown
Router(config-if)#
Use the show ip interface brief command to check the device’s IP addresses and
status of its interfaces:
The following figure shows how to connect a modem to an aux port on a router
(image source: Cisco):
Router(config)#line aux 0
Router(config-line)#password cisco
Router(config-line)#login
The code above enables password checking for users dialing into the router.
interface FastEthernet0/0
duplex auto
speed auto
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
interface FastEthernet1/0
no ip address
shutdown
duplex auto
speed auto
interface FastEthernet2/0
no ip address
shutdown
duplex auto
speed auto
--More--
In the picture above you can see that we’ve entered the show running-config | begin
interface command (we could have abbreviated it to show run | b int). This command
starts the output from the first occurence of the word interface.
no service password-encryption
password cisco
password cisco
As you can see from the example above, the include function displays only lines that
include the word password. The include function is helpful in some situations but can
also be confusing because it only includes exact matching commands with no
context around them, as in this example with password cisco shown twice in the
output.
To display only the section of the output about a certain feature, use
the section function:
line vty 0 4
password cisco
login
line vty 5 15
password cisco
login
You can see in the example above that the command displayed only the vty
section of the running configuration. The section function is not supported for all
parts of the configuration, but can be very helpful for example to view all the
configuration for a particular routing protocol:
router ospf 1
log-adjacency-changes
passive-interface FastEthernet0/0
NOTE
Cisco Packet Tracer doesn’t support the pipe function. The examples above were created in
GNS3.
1. The device performs the power-on self-test (POST) process to discover and verify
its hardware components.
2. If the POST test is successful, the bootstrap program is copied from ROM into
RAM.
3. The bootstrap program decides which IOS image to load from the flash memory
into RAM, and then loads the chosen IOS.
4. IOS finds the startup configuration file, usually located in NVRAM, and loads it into
RAM as the running configuration.
TFTP is a client-server network protocol used to send and receive files. To backup
files to a TFTP server, you will have to set it up first. You can use Packet Tracer to
do so; just add a Server to your topology, assign it an IP address and enable the
TFTP service:
To backup the running configuration to a TFTP server, you can use the copy
running-config tftp: command:
Writing running-config...!!
To restore the configuration, just switch the order of the parameters – copy tftp
startup-config:
Accessing tftp://192.168.0.10/R1-confg...
Notice that we had to specify the filename, along with the IP address of the TFTP
server.
debug command
The debug command displays information about the Cisco device operations,
generated or received traffic, and any error messages. The information are provided
in real-time until the user disables debugging or the device is restarted.
The debug operation takes a lot of CPU resources and should not be used often in
production environments. It is meant to be used as a troubleshooting tool for only a
short period of time. You can choose to debug only specific events – for example,
EIGRP information, received ICMP messages, etc.
R1#debug ip icmp
R1#
R1#
To disable debugging of the ICMP events, simply re-enter the command with the no
keyword in front of it:
R1#debug ip rip
R1#
R1#debug all
To disable this command, type the undebug all command (or the u all shortcut). You
will quite possibly be getting so much output that it is nearly impossible to enter a
command, and the shortest u all is your best chance. If you cannot enter the
command then you can try connecting from a different PC and entering the
command there.
R1#u all
R1#
As you can probably guess from the output, the message indicates that the link
connected to the GigabitEthernet0/0 interface went down. This message was shown
to you because the logging console command is enabled by default for the console
line. However, SSH and Telnet users will not be shown this message by default. The
enable mode command that needs to be executed in order to see these messages is
terminal monitor:
R1#terminal monitor
After executing this command the logging messages will also appear on the terminal
lines.
NOTE
The command terminal no monitor disables the showing of the log messages.
Notice that this is not the standard Cisco syntax – usually the keyword ‘no’ goes in
front of the command. We would usually expect the command to be no terminal
monitor, but the correct command is actually terminal no monitor.
Syslog explained
Syslog is a standard for message logging. Syslog messages are generated on
Cisco devices whenever an event takes place – for example, when an interface goes
down or a port security violation occurs.
You’ve probably already encountered syslog messages when you were connected to
a Cisco device through the console – Cisco devices show syslog messages by
default to the console users:
R1#
R1#terminal monitor
R1#
In the example above you can see that the logged in user executed the terminal
monitor command. Because of that, the telnet user was notified via a syslog
message when the Gi0/1 interface went up a couple of moments later.
R1(config)#logging 10.0.0.10
Now, logs generated on R1 will be sent to the syslog server with the IP address of
10.0.0.10. Of course, you need to have a Syslog server (e.g. Kiwi syslog) installed
and configured.
NOTE
It is also possible (and recommended) to use specify hostname instead of the IP address in
the logging command. The command is logging host HOSTNAME.
Notice how the command was interrupted and the syslog message was shown. To
prevent this, the logging synchronous console line mode command is used:
Now, the syslog message was shown, but the command was copied to the next line
below the message.
exec-timeout command
By default, an IOS device will disconnect a console or VTY user after 10 minutes of
inactivity. You can specify a different inactivity timer using the exec-timeout
MINUTES SECONDS line mode command.
For example, to disconnect a console user after 90 seconds of inactivity, we can use
the following command:
R1(config)#line con 0
R1(config-line)#exec-timeout 1 30
After 90 seconds of inactivity, the session will be disconnected and the user will need
to supply the console password to log back in:
R1(config-line)#
Password:
NOTE
To disable the timeout, use the value of 0 (not recommended in production environments!)
Syslog message format
Syslog messages that appear on a Cisco device consists of several parts. Consider
the following message:
In our example the message has the severity level of 5, which is a notification event.
The first five levels (0-4) are used by messages that indicate that the functionality of
the device is affected. Levels 5 and 6 are used by notification messages, while the
level 7 is reserved for debug messages.
The severity levels can be used to specify the type of messages that will be logged.
For example, if you think that you are getting too many non-important messages
when logged in through a console, the global configuration command logging
console 2 will instruct the device to only log messages of the severity level 0, 1 and 2
to the console.
IOS files
Cisco devices usually use integrated flash memory to store IOS software images and
other files (e.g. backup configuration files). The startup configuration is stored in
NVRAM. For each memory device available on the device, a file system called IOS
file system (IFS) is created. To list file systems available on your device, the show
file systems EXEC mode command is used:
File Systems:
In the command above you can see that I have two file systems available on my
device. Here is a description of each field:
The IOS image is a single file that is loaded into RAM when the device boots. This
file is usually stored in the flash memory, since this type of memory will retain the
stored files even after the router is powered off or rebooted. To show the contents of
the flash memory, the show flash: command is used:
R2#show flash:
3 33591768 c1900-universalk9-mz.SPA.151-4.M4.bin
2 28282 sigdef-category.xml
1 227537 sigdef-default.xml
write erase
erase nvram:
erase startup-config
Once you execute one of the commands above, you will need to reload the device.
Here is an example:
R1#write erase
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
R1#reload
1. We need to place the image file to a TFTP server that is reachable by the switch:
2. Next, we need to transfer the file from the TFTP server to the flash memory of the
switch. This can be done by issuing the copy command on the switch:
SW1#
Notice how we need to enter the IP address and the exact filename of the image we
wanted to copy. We’ve also specified that the destination filename will be the same
as the source filename.
By issuing the show flash: command, we can see that the file was copied to the
switch:
SW1#show flash:
Directory of flash:/
3. The last step is to configure the switch to load the new IOS version. If we reboot
the system now, the old IOS file will be loaded:
SW1#reload
Cisco WS-C2960-24TT (RC32300) processor (revision C0) with 21039K bytes of memory.
2960-24TT starting...
4. The last step is to save the configuration and reload the device. We can verify that
the newer version of IOS is being used by issuing the show version command:
SW1#show version
Here is an example. Let’s say that we want to transfer the image file from the FTP
server to a Cisco switch. We can do this using the following set of commands:
SW1(config)#end
SW1#
Accessing ftp://10.0.0.100/c2960-lanbasek9-mz.150-2.SE4.bin...
To verify that the file has indeed been transfered, we can use the show
flash: command:
SW1#show flash:
Directory of flash:/
We can also transfer files from the IOS device to the FTP server, for example to
backup the startup configuration. Here is an example of copying the startup
configuration of a switch to the FTP server:
Writing startup-config...
Here’s an example:
version 16.6.4
no service password-encryption
hostname R1
....
In the example above we’ve listed the startup configuration (that is stored in NVRAM
by default) using the more command.
You can filter the more command’s output just as you would do with a show
command, e.g.:
interface GigabitEthernet0/0/0
interface GigabitEthernet0/0/1
interface GigabitEthernet0/0/2
interface Vlan1
In the example above we’ve filtered only the lines that include the word ‘interface’.
A Cisco router can be configured as a DHCP server. Here are the steps:
1. Exclude IP addresses from being assigned by DHCP by using the ip dhcp
excluded-address FIRST_IP LAST_IP
2. Create a new DHCP pool with the ip dhcp pool NAME command.
3. Define a subnet that will be used to assign IP addresses to hosts with
the network SUBNET SUBNET_MASK command.
4. Define the default gateway with the default-router IP command.
5. Define the DNS server with the dns-server IP address command.
6. (Optional) Define the DNS domain name by using the ip domain-name
NAME command.
7. (Optional) Define the lease duration by using the lease DAYS HOURS
MINUTES command. If you don’t specify this argument, the default lease time of 24
hours will be used.
Floor1(dhcp-config)#default-router 192.168.0.1
Floor1(dhcp-config)#dns-server 192.168.0.1
In the example above you can see that I’ve configured the DHCP server with the
following parameters:
To view information about the currently leased addresses, you can use the show ip
dhcp binding command:
Hardware address
In the output above you can see that there is a single DHCP client that was assigned
the IP address of 192.168.0.51. Since we’ve excluded the IP addresses from
the 192.168.0.1 – 192.168.0.50 range, the device got the first address available
– 192.168.0.51.
To display information about the configured DHCP pools, you can use the show ip
dhcp pool command:
Pool Floor1DHCP :
Leased addresses : 1
Excluded addresses : 1
This command displays some important information about the DHCP pool(s)
configured on the device – the pool name, total number of IP addresses, the number
of leased and excluded addresses, subnet’s IP range, etc.
To make sure that the workstation indeed got its IP parameters, we can issue
the ipconfig command:
C:\>ipconfig
IP Address......................: 10.0.0.104
R1(config)#int Gi0/0
We can verify that the Gi0/0 interface has indeed got its IP address from the DHCP
server by running the show ip int brief command:
(config)clock summer-time NAME recurring [week day month hh:mm week day month hh:mm
[offset]]
R1(config)clock summer-time DST recurring last Sunday March 2:00 last Sunday October 2:00
Cisco routers can be configured as both NTP clients and NTP servers. To configure
a Cisco router as an NTP client, we can use the ntp server IP_ADDRESS command:
NOTE
To define a version of NTP, add the version NUMBER keywords at the end of the command
(e.g. ntp server 192.168.0.100 version 3).
nominal freq is 250.0000 Hz, actual freq is 249.9990 Hz, precision is 2**19
DEVICE(config)#ntp master
After entering this command you will need to point all the devices in your LAN
to use the router
To discover information, Cisco devices send CDP messages out each of their
interfaces. These messages contain information about them, such as their
hostname, network and data link addresses, the device model, IOS version, etc.
As you can see from the example above, there is one directly connected device.
Here is a description of each field:
Device ID – the hostname of the directly connected device. In this case the
hostname is Switch.
Local Interface – the local interface on which the CDP messages were
received (Gi0/0 in this case).
Holdtime – the amount of time the local device will hold the information
before discarding it if no more CDP packets are received.
Capability – the capability of the directly connected device. The
letter S indicates that the directly connected device is a switch. The letter R would
indicate a router.
Platform – the model and OS level running on the neighbor, 2960 series
switch in this case.
Port ID – the neighbor device’s interface on which the CDP packets were
sent, in this case Fa0/1.
To get even more information about the neighbors, use the show cdp neighbors
detail command:
Entry address(es):
Holdtime: 126
Version :
advertisement version: 2
Duplex: full
NOTE
IEEE has released a vendor-neutral link layer protocol called Link Layer Discovery Protocol
(LLDP) as an alternative to CDP.
as NTP server.
R1(config)#lldp run
Capability codes:
(R) Router, (B) Bridge, (T) Telephone, (C) DOCSIS Cable Device
(W) WLAN Access Point, (P) Repeater, (S) Station, (O) Other
As you can see from the output above, R1 has a single neighbor. Here is the
description of the fields in the output:
To get more detail information about LLDP neighbors, run the show lldp neighbors
detail command:
------------------------------------------------
System Name: R2
System Description:
System Capabilities: R
Enabled Capabilities: R
1000baseT(FD)
100baseT(FD)
Vlan ID: 1
NOTE
To get information about a specific neighbor, run the show lldp entry DEVICE_ID command.
R2#show lldp
Status: ACTIVE
This command displays information about whether LLDP is active on the device, the
frequency of LLDP transmissions, the holdtime for packets being sent, and the delay
time for LLDP to initialize on an interface.
You can also configure whether you would like your device to send or receive LLDP
packets on a particular interface using the no lldp transmit and no lldp
receive interface mode commands. For example, to only receive LLDP packets on
the Gi0/0 interface, I would use the following command to disable the sending of
LLDP packets:
URLs can also be used to reference documents other than the web sites. Here are
some examples of using URLs to reference an FTP resource, mail address and local
files:
Host Port Flags Age Type Address(es)
We can ping the server using its hostname to verify that the hostnames are
being resolved:
Floor1#ping HQ_SERVER
!!!!!
NOTE
The drawback of this method of name resolution is that we need to create static
hostname-to-address mappings on each device in order to be able to resolve hostnames.
If possible, use DNS instead.
In the output above you can see that I’ve specified the IP address of my DNS server
(192.168.0.100). Let’s say that the DNS server contains a record for a server
called fileshare. I can try to ping that host using its hostname to verify that the name
resolution process is indeed working:
Floor1#ping fileshare
.!!!!
As you can see from the output above, the hostname fileshare was translated to the
IP address of 192.168.0.110.
no ip domain-lookup command
By default, any single word entered on an IOS device that is not recognized as a
valid command is treated as a hostname to which you want to telnet. The device will
try to translate that word to an IP address in a process that can last about a minute.
R1#writte
In the output above you can see that I’ve mistyped the command write. The router
entered the DNS resolution process which lasted about a minute. This can be
annoying and this is why this feature is often turned off, especially in the lab
environments.
If you don’t need to have a DNS server configured for your router, you can use
the no ip domain-lookup command to disable the DNS translation process:
R1(config)#no ip domain-lookup
Now, if I mistype a command, the router will not perform a DNS resolution process:
R1#writte
Translating "writte"
R1#
R1#show processes
CPU utilization for five seconds: 0%/0%; one minute: 0%; five minutes: 0%
The first line of the output shows the CPU utilization for the last 5 seconds, 1 minute,
and 5 minutes. Here is a description of other fields in the output:
However, there is one problem with this command – the password is stored in
clear text in the configuration:
R1#show running-config
Building configuration...
!
version 15.1
....
!
!
...
R1(config)#
ERROR: Can not have both a user password and a user secret.
Please choose one or the other.
R1#show ip arp
The ARP table contains two entries for R1’s own two interfaces with the IP address
of 10.0.0.1 and 172.16.0.1. The – in the age column indicates that the entry will
never be timed out.
The ARP table also lists the MAC addresses of the two connected hosts. Consider
the entry for Host A:
Here are the steps R1 needs to take before forwarding frames to Host A:
Layer 2 switching
Layer 2 switching (or Data Link layer switching) is the process of using devices’
MAC addresses to decide where to forward frames. Switches and bridges are used
for Layer 2 switching. They break up one large collision domain into multiple smaller
ones.
In a typical LAN, all hosts are connected to one central device. In the past, the
device was usually a hub. But hubs had many disadvantages, such as not being
aware of traffic that passes through them, creating one large collision domain, etc.
To overcome some of the problems with hubs, bridges were created. They were
better than hubs because they created multiple collision domains, but they had
limited number of ports. Finally, switches were created and are still widely used
today. Switches have more ports than bridges, can inspect incoming traffic and make
forwarding decisions accordingly. Also. each port on a switch is a separate collision
domain, so no packet collisions should occur.
Layer 2 switches are faster than routers because they don’t take up time looking at
the Network layer header information. Instead, they look at the frame’s hardware
addresses to decide what to do with the frame – to forward, flood, or drop it. Here
are other major advantages of Layer 2 switching:
Here is an example of the typical LAN network – the switch serves as a central
device that connects all devices together:
Now consider the way the switches work. We have the same topology as above,
only this time we are using a switch instead of a hub:
Switches increase the number of collision domains. Each port is one collision
domain, which means that the chances for collisions to occur are minimal. A switch
learns which device is connected to which port and forwards a frame based on the
destination MAC address included in the frame. This reduces traffic on the LAN and
enhances security.
Switches also use MAC addresses to make accurate forwarding or filtering decision.
When a switch receives a frame, it associates the media access control (MAC)
address of the sending device with the port on which it was received. The table that
stores such associations is called a MAC address table. This table is stored in the
volatile memory, so associations are erased after the switch is rebooted.
To better how a network switch works, take a look at the following example:
Let’s say that host A wants to communicate with host B for the first time. Host A
knows the IP address of host B, but since this is the first time the two hosts
communicate, the hardware (MAC) addresses are not known. Host A uses the ARP
process to find out the MAC address of host B. The switch forwards the ARP request
out all ports except the port the host A is connected to. Host B receives the ARP
request and responds with its MAC address. Host B also learns the MAC address of
host A (because host A sent its MAC address in the ARP request). Host C receives
the ARP request, but doesn’t respond since the IP address listed in the request is
not its own.
As mentioned above, a switch learns which MAC addresses are associated with
which port by examining the source MAC address of each received frame. Because
host B responded with the ARP reply that included its MAC address, the switch
knows the MAC address of host B and stores that address in its MAC address table.
For host A, the switch knows its MAC address because of the ARP request that
included it.
Now, when host A sends a packet to host B, the switch looks up in its MAC address
table and forwards the frame only out the Fa0/2 port – the port on which host B is
connected to. Other hosts on the network will not be involved in the communication:
NOTE
By default, MAC addresses stay in the switch’s MAC address table for 5 minutes. So if host A
and host B decide to communicate inside the next 5 minutes, a new ARP process will not be
necessary.
You can display the MAC address table of the switch by using the show mac-
address-table command:
Switch#show mac-address-table
-------------------------------------------
The output is pretty much self-explanatory: all ports belong to VLAN 1 and MAC
addresses associated with specific ports are listed. DYNAMIC means that the
address were learned dynamically by using the source MAC address of the received
frames.
In the picture above we have three broadcast domains, since all ports on a hub or a
switch are in the same broadcast domain, and all ports on a router are in a different
broadcast domain.
CSMA/CD
CSMA/CD (Carrier Sense Multiple Access with Collision Detection) helps hosts
to decide when to send packets on a shared network segment and how to detect
collisions if they occur. For example, in a hub network, two devices can send packets
at the same time. This can cause a collision. CSMA/CD enables devices to “sense”
the wire to ensure that no other device is currently transmitting packets. But, if two
devices “sense” that the wire is clear and send packets at the same time, a collision
can occur. If the collision occur, packets have to be resend after a random period of
time.
In the topology above we have a hub network. Host A is trying to communicate with
host B. Host A “senses” the wire and decides to send packets. But, in the same time,
host C sends its packets to host D and the collision occurs. The sending devices
(host A and host C) detect the collision and resend the packet after a random period
of time.
NOTE
Since switches are now commonly used in networks instead of hubs, CSMA/CD is not really
used anymore. Each port on a swich usually operate in a full duplex mode and there are no
packet collisions in a full duplex mode.
What is a VLAN?
VLANs (Virtual LANs) are logical grouping of devices in the same broadcast
domain. VLANs are usually configured on switches by placing some interfaces into
one broadcast domain and some interfaces into another. Each VLAN acts as a
subgroup of the switch ports in an Ethernet LAN.
VLANs can spread across multiple switches, with each VLAN being treated as its
own subnet or broadcast domain. This means that frames broadcasted onto the
network will be switched only between the ports within the same VLAN.
A VLAN acts like a physical LAN, but it allows hosts to be grouped together in the
same broadcast domain even if they are not connected to the same switch. Here are
the main reasons why VLANs are used:
The following topology shows a network with all hosts inside the same VLAN:
Without VLANs, a broadcast sent from host A would reach all devices on the
network. Each device will receive and process broadcast frames, increasing the CPU
overhead on each device and reducing the overall security of the network.
By placing interfaces on both switches into a separate VLAN, a broadcast from host
A would reach only devices inside the same VLAN, since each VLAN is a separate
broadcast domain. Hosts in other VLANs will not even be aware that the
communication took place. This is shown in the picture below:
NOTE
To reach hosts in a different VLAN, a router is needed.
access port – a port that can be assigned to a single VLAN. This type of
interface is configured on switch ports that are connected to end devices such as
workstations, printers, or access points.
trunk port – a port that is connected to another switch. This type of interface
can carry traffic of multiple VLANs, thus enabling you to extend VLANs across your
entire network. Frames are tagged by assigning a VLAN ID to each frame as they
traverse between switches.
Configuring VLANs
By default, all ports on a switch are in the VLAN 1. We can verify that by typing
the show vlan command from the IOS enable mode of a switch:
In the picture above, you can see that all of the 24 ports of the switch are in the
same VLAN, namely VLAN 1.
Two steps are required to create a VLAN and assign a switch port to the VLAN:
The first command (vlan 2) created the VLAN 2. We’ve then entered the Fa0/1
subinterface mode and configured the interface as an access interface that belongs
to VLAN 2. To verify this, we can again use the show vlan command:
Configuring access & trunk ports
To configure an interface to be an access interface, the switchport mode
acess interface command is used. This type of interface can be assigned only to a
single VLAN.
Host A and host B are in different VLANs, VLAN 1 and VLAN 2. These ports need to
be configured as access ports and assigned to their respective VLANs by using the
following sequence of commands:
Because the link between SW1 and SW2 needs to carry traffic of multiple VLANs, it
needs to be configured as a trunk interface. This is done by using the following
commands on both SW1 and SW2:
On SW1:
On SW2:
Now the link between SW1 and SW2 can carry traffic from both the VLAN1 and
VLAN2. You can verify that an interface is indeed a trunk interface by using
the show interface Fa0/3 switchport command on SW1:
NOTE
VLAN 1 doesn’t have to be created, it exists by default. Also, by default, all ports are in the VLAN
1, so Fa0/1 doesn’t need the switchport access vlan 1 command.
Frame tagging
To identify the VLAN a packet is belonging to, switches use tagging to assign a
numerical value to each frame in a network with multiple VLANs. This is done to
ensure that switches know out which ports to forward frames.
There are two VLANs in the toplogy pictured above, namely VLAN 3 and VLAN 4.
Host A sends a broadcast packet to switch SW1. Switch SW1 receives the packet,
tags the packet with the VLAN ID of 3 and sends it to SW2. SW2 receives the
packet, looks up at the VLAN ID, and forwards the packet only out the port Fa0/1,
since only that port is in VLAN 3. Host B and host C will not receive the packet
because they are in different VLAN than host A.
NOTE
When forwarding a tagged frame to a host device a switch will remove the VLAN tag, since host
devices don’t understand tagging and would drop the packet.
EEE 802.1Q
IEEE 802.1Q is one of the VLAN tagging protocols supported by Cisco switches.
This standard was created by the Institute of Electrical and Electronics Engineers
(IEEE), so it an open standard and can be used on non-Cisco switches.
To identify to which VLAN a frame belongs to, a field is inserted into the frame’s
header.
Original frame:
802.1Q frame:
An example will attempt to clarify the concept. Let’s say that we have a network of 2
switches and 4 hosts. Hosts A and host D are in VLAN 2, while hosts B and C are in
VLAN 3.
On the segment between two switches, a process called VLAN trunking is used.
Let’s say that host A sends a broadcast frame. SW1 “tags” the frame by inserting the
VLAN ID in the header of the frame before sending the frame to SW2. SW2 receives
the frame and knows that the frame belongs to VLAN 3, so it sends the frame only to
host D, since that host is in VLAN 3.
ISL works by encapsulating a frame in an ISL header and trailer. The encapsulated
frame remains unchanged. The VLAN ID is included in the ISL header.
Original frame:
ISL frame:
The port on the phone connected to the switch can carry both data and voice traffic.
To enable this, we need to define two VLANs on the switch port – data VLAN and
voice VLAN. Here is how we can do that:
SW1(config)#vlan 5
SW1(config)#vlan 20
SW1(config)#int fa0/1
We’ve created two VLANs – VLAN 5 that will be used for data sent by the PC and
VLAN 20 for IP phone’s voice traffic. We’ve then placed the port into both VLANs.
The keyword voice indicates that the VLAN 20 will be a voice VLAN.
To verify that the interface indeed carries data from both VLANs, we can use
the show interfaces Fa0/1 switchport command:
Name: Fa0/1
Switchport: Enabled
Voice VLAN: 20
...
Fa0/1 1-1005
Fa0/1 1,5,10
Port Vlans in spanning tree forwarding state and not pruned
Fa0/1 1,5,10
In the output above you can see that all VLANs (1 through 1005) are allowed on the
trunk by default.
We can prevent traffic from certain VLANs from traversing a trunk link using the
following interface mode command:
For example, to prevent traffic from VLAN 5 to traverse the trunk link, we would use
the following command:
SW1(config)#int fa0/1
The same command needs to be entered on the switch on the other end of the link.
To verify that the traffic from VLAN 5 will indeed be blocked from traversing a
trunked link, we can enter the show interfaces trunk command again:
Fa0/1 1-4,6-1005
Fa0/1 1,10
Fa0/1 none
Notice how now only VLANs 1-4 and 6-1005 are allowed on trunk.
NOTE
You can use the switchport trunk allowed vlan all interface mode command to reset the switch
port to its original default setting (permitting all VLANs on the trunk).
What is VTP?
NOTE
This topic is not included in the latest version of the CCNA exam (200-301). If you are studying
for the exam feel free to skip this article.
To better understand the true value of VTP, consider an example network with 100
switches. Without VTP, if you want to create a VLAN on each switch, you would
have to manually enter VLAN configuration commands on every switch! VTP
enables you to create the VLAN only on a single switch. That switch can then
propagate information about the VLAN to every other switch on the network and
cause other switches to create it. Likewise, if you want to delete a VLAN, you only
need to delete it on one switch, and the change is automatically propagated to every
other switch inside the same VTP domain.
On SW1, we have created a new VLAN. SW1 sends a VTP update about the new
VLAN to SW2, which in turn sends its VTP update to SW3. These updates will cause
SW2 and SW3 to create the same VLAN. You can see how this simplifies network
administration – the engineer only had to log in and create the VLAN on the first
switch. Other switches have created the same VLAN automatically.
NOTE
VTP does not advertise information about which switch ports are assigned to which VLAN.
Three VTP versions are available – V1, V2, and V3. The first two versions are similar
except that V2 adds support for token ring VLANs. V3 adds the following features:
enhanced authentication
support for extended VLANs (1006 to 4094). VTP versions 1 and 2 can
propagate only VLANs 1 to 1005.
support for private VLAN
VTP primary server and VTP secondary servers
VTP mode off that disables VTP
backward compatibility with VTP V1 and V2
the ability to be configured on a per-port basis
VTP modes
NOTE
This topic is not included in the latest version of the CCNA exam (200-301). If you are studying
for the exam feel free to skip this article.
VTP client mode – a switch using this mode can’t change its VLAN
configuration. That means that a VTP client switch cannot create or delete VLANs.
However, received VTP updates are processed and forwarded.
VTP server mode – a switch using this mode can create and delete VLANs.
A VTP server switch will propagate VLAN changes. This is the default mode for
Cisco switches.
VTP transparent mode – a switch using this mode doesn’t share its VLAN
database, but it forwards received VTP advertisements. You can create and delete
VLANs on a VTP transparent switch, but these changes will not be sent to other
switches.
VTP mode off – similar to VTP transparent mode, with a difference that a
switch using this mode will not forward received VTP updates. This command is
supported only in VTP V3.
As mentioned above, all switches are configured as VTP servers by default. This is
fine in smaller networks without too many VLANs and VLAN changes, since all
VLAN information can easily be stored in each switch’s NVRAM. However, in larger
networks, it is recommended to specify a couple of higher-quality switches to serve
as VTP servers. All other switches in the network should be set up as VTP clients.
We have a simple network of three switches. SW1 is configured as VTP server. After
the VLAN 5 is created on SW1, this switch will notify the connected switch (SW2)
about the created VLAN. SW2 will receive the update but, since it uses the VTP
transparent mode, it will not create this VLAN in its configuration. However, it will
forward the VTP update to SW3. Since SW3 is configured as VTP client, it will
process the update and create VLAN 5.
VTP configuration
We’ve already learned that using VTP makes it is possible to make configuration
changes on one or more switches and have those changes automatically advertised
to all the other switches in the same VTP domain. In a typical network some
switches are configured as VTP servers and other switches are configured as VTP
clients. A VLAN created on a VTP server switch is automatically advertised to all
switches inside the same VTP domain.
NOTE
With VTP V1 and V2 it is not possible to completely disable VTP on Cisco switches; the best you
can do is to place the switch in the VTP transparent mode. VTP V3 adds the mode off option
which effectively disables VTP. This article describes the configuration of VTP V1 or V2.
We have a network of three switches connected via trunk links. On SW1, we will
configure the VTP domain name using the vtp domain NAME command and VTP
password using the vtp password PASSWORD commands:
NOTE
The default VTP mode on Cisco switches is the server mode, so the command vtp mode
server wasn’t necessary in the SW1 configuration pictured above.
Now we need to configure SW2 and SW3 as VTP clients. We can do it using the following set of
commands:
SW2(config)#vtp mode client
Now, when we create a new VLAN on SW1, the VTP will be sent to SW2 and SW3 and the new
VLAN will be created automatically on SW2 and SW3:
SW2 and SW3 will create the VLAN 30 automatically. We can use the show
vlan command on both switches to verify this (in this example VLAN 2 ‘Accounting’
was also already created on SW1):
SW2:
SW3:
NOTE
This configuration is not supported on Packet Tracer. You can enter the commands but they will
not show up in the running config and the VLAN will not be added on SW2 and SW3
To display the VTP configuration information, we can use the show vtp
status command:
VTP Version :2
Configuration Revision :3
Each time you make a VLAN change on a VTP server, the configuration revision
number is incremented by one and a VTP advertisement is sent. The switch that
receives a VTP packet compares the configuration revision to its own revision. If the
configuration revision number in the received VTP advertisement is higher than its
own revision number, the switch will overwrite its VLAN configurations with the new
information that is being advertised.
NOTE
It is important to check a new switch’s VTP configuration revision number before adding it to your
network. If the revision number on the new switch is higher than the current revision number of
other switches on the network, all current VLANs could be deleted!
What is STP?
Spanning Tree Protocol (STP) is a network protocol designed to prevent layer 2
loops. It is standardized as IEEE 802.D protocol. STP blocks some ports on switches
with redundant links to prevent broadcast storms and ensure loop-free topology.
With STP in place, you can have redundant links between switches in order to
provide redundancy.
To better understand the importance of STP and how STP prevents broadcast
storms on a network with redundant links, consider the following example:
SW1 sends a broadcast frame to SW2 and SW3. Both switches receive the frame
and forward the frame out every port, except the port the frame was received on. So
SW2 forwards the frame to SW3. SW3 receives that frame, and forwards it to SW1.
SW1 then again forwards the frame to SW2! The same thing also happens in the
opposite direction. Without STP in place, these frames would loop forever. STP
prevents loops by placing one of the switch ports in blocking state.
In the topology above, STP has placed one port on SW3 in the blocking state. That
port will no longer process any frames except the STP messages. If SW3 receives a
broadcast frame from SW1, it will not forward it out the port connected to SW2.
NOTE
STP enables layer 2 redundancy. In the example above, if the link between SW3 and SW1 fails,
STP would converge and unblock the port on SW3.
1. all switches in a network elect a root switch. All working interfaces on the root
switch are placed in forwarding state.
2. all other switches, called nonroot switches, determine the best path to get to the
root switch. The port used to reach the root switch (root port) is placed in forwarding
state.
3. on the shared Ethernet segments, the switch with the best path to reach the root
switch is placed in forwarding state. That switch is called the designated switch and
its port is known as the designated port.
4. all other interfaces are placed in blocking state and will not forward frames.
NOTE
STP considers only working interfaces – shutdown interfaces or interfaces without the cable
installed are placed in an STP disabled state.
Let’s say that SW1 is elected as the root switch. All ports on SW1 are placed into
forwarding state. SW2 and SW3 choose ports with the lowest cost to reach the root
switch to be the root ports. These ports are also placed in forwarding state. On the
shared Ethernet segment between SW2 and SW3, port Fa0/1 on SW2 has the
lowest cost to reach the root switch. This port is placed in forwarding state. To
prevent loops, port Fa0/1 on SW3 is placed in blocking state.
NOTE
A switch with the lowest switch ID will become the root switch. A switch ID consists of two
components: the switch’s priority (by default 32,768 on Cisco switches) and the switch’s MAC
address.
BPDU (Bridge Protocol Data Unit)
BPDUs are messages used by switches to share STP information with each other in
order to elect a root switch and detect loops. The most common messages are Hello
BPDUs which include the following information:
root switch ID
sender’s switch ID
sender’s root cost
Hello, MaxAge, and forward delay timers
2-byte priority field – by default, all switches have the priority of 32768. This
value can be changed using configuration commands.
6-byte system ID – a value based on the MAC address of each switch.
A switch with the lowest BID will become a root switch, with lower number meaning
better priority.
As mentioned above, the switch with the lower BID wins. Since by default all
switches have the BID priority of 32768, the second comparison has to be made –
the lowest MAC address. In our example SW1 has the lowest MAC address and
becomes the root switch.
NOTE
For simplicity, all ports on switches in the example above are assigned to VLAN 1. Also, note that
STA adds the VLAN number to the priority value, so all switches actually have the BID priority of
32,769.
To influence the election process, you can change the BID priority to a lower value
on a switch you would like to become root. This can be done using the following
command:
The priority must be in increments of 4096, so if you choose any other value, you will
get en error and possible values listed:
SW1 has won the election process and is the root switch. Consider the SW3’s
perspective for choosing its root port. Two paths are available to reach the root
switch, one direct path over Fa0/1 and the other going out Fa0/2 and through SW2.
The direct path has a cost of 19, while the indirect path has the cost of 38 (19+19).
That is why Fa0/1 will become the root port on SW3.
In case the best root cost ties for two or more paths, the following tiebreakers are
applied:
the lowest neighbor bridge ID
the lowest neighbor port priority
the lowThe default port cost is defined by the operating speed of the interface:
Speed Cost
10 Mbps 100
100 Mbps 19
1 Gbps 4
10 Gbps 2
You can override the default value on the per-interface basis using the following
command:
1. the switch with the lowest cost to reach the root becomes the designated
switch on that link.
2. in case of a tie, the switch with the lowest BID becomes the designated
switch.
What is RSTP?
RSTP (Rapid Spanning Tree Protocol) is an evolution of STP. It was originally
introduced as IEEE 802.1w standard and in 2004 IEEE decided to replace STP with
RSTP in 802.1D standard. Finally, in 2011, in the IEEE decided to move all the
RSTP details into 802.1Q standard.
RSTP is backwards-compatible with STP and there are many similarities between
the two protocols, such as:
the root switch is elected using the same set of rules in both protocols
root ports are selected with the same rules, as well as designated port on LAN
segments
both STP and RSTP place each port in either forwarding or blocking state.
The blocking state in RSTP is called the discarding state.
In order to avoid loops, RSTP has placed one port on SW3 in the alternate state.
This port will not process or forward any frames except the RSTP messages.
However, if the root port on SW3 fails, the alternate port will rapidly become the root
port and start forwarding frames.
1. all switches in a network elect a root switch. All working interfaces on the root
switch are placed in forwarding state.
2. all other switches, called nonroot switches, determine the best path to get to the
root switch. The port used to reach the root switch (root port) is placed in forwarding
state.
3. on the shared Ethernet segments, the switch with the best path to reach the root
switch is placed in forwarding state. That switch is called the designated switch and
its port is known as the designated port.
4. all other interfaces are placed in discarding state and will not forward frames.
NOTE
RSTP is backwards-compatible with STP and they both can be used in the same network.
Consider the following example:
Let’s say that SW1 is elected as the root switch. All ports on SW1 are placed in
forwarding state. SW2 and SW3 choose ports with the lowest cost to reach the root
switch to be the root ports. These ports are also placed in forwarding state. On the
shared Ethernet segment between SW2 and SW3, port Fa0/1 on SW2 has the
lowest cost to reach the root switch. This port is placed in forwarding state. To
prevent loops, port Fa0/1 on SW3 is placed in discarding state. If the root port on
SW3 fails, this alternate port will quickly take over and become the root port.
NOTE
RSTP also introduces a concept of backup port. This port serves as a replacement for the
designated port inside the same collision domain. This can only occur when using hubs in your
network.
Configuring RSTP
Most newer Cisco switches use RSTP by default. RSTP prevents frame looping out
of the box and no additional configuration is necessary. To check whether a switch
runs RSTP, the show spanning-tree command is used:
SW1#show spanning-tree
VLAN0001
Address 0004.9A47.1039
Address 0004.9A47.1039
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
If RSTP is not being used, the following command will enable it:
However, to perform switch management over the network or use protocols such as
SNMP, the switch will need to have an IP address. The IP address is configured
under a logical interface, known as the management domain or VLAN. Usually, the
default VLAN 1 acts like the switch’s own NIC for connecting into a LAN to send IP
packets. Here are the steps to configure an IP address under VLAN 1:
SW1(config)#int vlan 1
SW1(config-if)#
SW1(config-if)#
SW1(config-if)#no shutdown
SW1(config-if)#
To verify the IP address set on a switch, we can use the show int vlan 1 command:
....
We can verify that the host can reach the switch using its IP address by pinging it
from Host A:
C:\>ping 10.0.0.2
...
1. Use a router, with one router LAN interface connected to the switch for each
VLAN. Since you need one Ethernet interface on your router to connect to each
VLAN, this option is not really scalable and rarely used today.
2. Use one router interface with trunking enabled. This option is called router on a
stick (ROAS) and enables all VLANs to communicate over a single interface.
3. Use a Layer 3 switch, which is a device that performs both the switching and
routing operations.
SW1(config)#int fa0/3
SW1(config-if)#int fa0/4
SW1(config-if)#int fa0/2
SW1(config-if)#int fa0/1
Notice how we’ve configured the Fa0/1 port on a switch (the port connected to the
router’s Gi0/0 interface) as the trunk port. Other ports were configured as access
ports and placed into respective VLANs since they are connected to end devices.
Now, let’s configure the router:
R1(config)#int Gi0/0
R1(config-if)#no shutdown
R1(config-if)#
R1(config-if)#int Gi0/0.1
R1(config-subif)#
R1(config-subif)#encapsulation dot1q 3
R1(config-subif)#int Gi0/0.2
R1(config-subif)#
R1(config-subif)#encapsulation dot1q 10
R1(config-subif)#int Gi0/0.3
R1(config-subif)#
R1(config-subif)#encapsulation dot1q 5
In the output above you can see that the router’s physical interface Gi0/0 was
divided into three subinterfaces that were then configured as trunk interfaces and
assigned the IP addresses.
To test whether the intervlan communication works, we can try to ping Host C from
Host A:
C:\>ping 10.0.5.10
-------------------------------------------
NOTE
To delete the static entry from the MAC address table, re-enter the command with
the no keyword in front.
We can verify the speed and duplex settings using the show interface command on
SW1:
...
Half-duplex, 100Mb/s
...
...
Full-duplex, 100Mb/s
...
As you can see from the output above, the interface Fa0/1 will use the speed of 100
Mbps and half-duplex. The Fa0/2 interface will use the same speed, but it will use
the full duplex communication.
It is recommended that devices on both sides of a link should have the auto-
negotiation setting turned on, or both sides should have it off. If you encounter a
device that has speed and duplex parameters manually configured, you can use the
interface mode speed and duplex commands to set the duplex and speed settings,
e.g.:
SW1(config)#int Fa0/3
SW1(config-if)#speed 100
SW1(config-if)#duplex full
When one device uses autonegotiation and the other one has disabled it, the device
using autonegotiation will choose the default duplex setting based on the current
speed. The defaults are:
If the speed is not known, 10 Mbps and half duplex settings will be used.
And If the device successfully senses the speed without IEEE autonegotiation, by
just looking at the signal on the cable.
Full-duplex, 100Mb/s
As you can see from the output above, this command gives us plenty of information
about the specified interface. Here is a brief description of the most important lines:
The first line of the output indicates the working state of the interface. The first
status code (known as line status) indicates that the Layer 1 is working
(FastEthernet0/1 is up). The second status code (known as protocol status)
indicates that Layer 2 is also working (line protocol is up) and is
always Down if the line status is Down. Finally, the word at the end of the line
indicates the working state of the interface (connected in our case).
All possible combinations of the status codes are given in the table below:
NOTE
Only interfaces with status codes of up and up will forward or receive frames.
SW1(config-if-range)#description END_HOSTS
Building configuration...
...
interface FastEthernet0/3
!
interface FastEthernet0/4
description END_HOSTS
!
interface FastEthernet0/5
description END_HOSTS
!
interface FastEthernet0/6
description END_HOSTS
!
interface FastEthernet0/7
description END_HOSTS
!
interface FastEthernet0/8
description END_HOSTS
!
interface FastEthernet0/9
!
....
SW1#show version
....
cisco WS-C2960-24TT-L (PowerPC405) processor (revision B0) with 65536K bytes of memory.
24 FastEthernet interfaces
Version ID : V02
As you can see from the output above, this command gives us detailed information
about the IOS device. Here is a brief description of the most important information:
Port security
By default, all interfaces on a Cisco switch are turned on. That means that an
attacker could connect to your network through a wall socket and potentially threaten
your network. If you know which devices will be connected to which ports, you can
use the Cisco security feature called port security. By using port security, a network
administrator can associate specific MAC addresses with the interface, which can
prevent an attacker to connect his device. This way you can restrict access to an
interface so that only the authorized devices can use it. If an unathorized device is
connected, you can decide what action the switch will take, for example discarding
the traffic and shutting down the port.
1. define what action the switch will take when receiving a frame from an unathorized
device by using the port security violation {protect | restrict | shutdown} interface
subcommand. All three options discards the traffic from the unauthorized device. The
restrict and shutdown options send a log messsages when a violation occurs. Shut
down mode also shuts down the port.
2. define the maximum number of MAC addresses that can be used on the port by
using the switchport port-security maximum NUMBER interface submode command
The following example shows the configuration of port security on a Cisco switch:
First, we need to enable port security and define which MAC addresses are allowed
to send frames:
Next, by using the show port-security interface fa0/1 we can see that the switch has
learned the MAC address of host A:
The status code of err-disabled means that the security violation occured on the
port.
NOTE
To enable the port, we need to use the shutdown and no shutdown interface subcommands.
What is IP routing?
IP routing is the process of sending packets from a host on one network to another
host on a different remote network. This process is usually done by routers. Routers
examine the destination IP address of a packet , determine the next-hop address,
and forward the packet. Routers use routing tables to determine the next hop
address to which the packet should be forwarded.
Host A wants to communicate with host B, but host B is on another network. Host A
is configured to send all packets destined for remote networks to router R1. Router
R1 receives the packets, examines the destination IP address and forwards the
packet to the outgoing interface associated with the destination network.
Default gateway
A default gateway is a router that hosts use to communicate with other hosts on
remote networks. A default gateway is used when a host doesn’t have a route entry
for the specific remote network and doesn’t know how to reach that network. Hosts
can be configured to send all packets destined to remote networks to the default
gateway, which has a route to reach that network.
The following example explains the concept of a default gateway more thoroughly.
Routing table
Each router maintains a routing table and stores it in RAM. A routing table is used by
routers to determine the path to the destination network. Each routing table consists
of the following entries:
Consider the following example. Host A wants to communicate with host B, but host
B is on another network. Host A is configured to send all packets destined for remote
networks to the router. The router receives the packets, checks the routing table to
see if it has an entry for the destination address. If it does, the router forwards the
packet out the appropriate interface port. If the router doesn’t find the entry, it
discards the packet.
We can use the show ip route command from the enabled mode to display the
router’s routing table.
Router#show ip route
As you can see from the output above, this router has two directly connected routes
to the subnets 10.0.0.0/8 and 192.168.0.0/24. The character C in the routing table
indicates that a route is a directly connected route. So when host A sends the packet
to host B, the router will look up into its routing table and find the route to the
10.0.0.0/8 network on which host B resides. The router will then use that route to
route packets received from host A to host B.
Connected routes
Subnets directly connected to a router’s interface are added to the router’s routing
table. Interface has to have an IP address configured and both interface status
codes must be in the up and up state. A router will be able to route all packets
destined for all hosts in subnets directly connected to its active interfaces.
Consider the following example. The router has two active interfaces, Fa0/0 and
Fa0/1. Each interface has been configured with an IP address and is currently in the
up-up state, so the router adds these subnets to its routing table.
As you can see from the output above, the router has two directly connected routes
to the subnets 10.0.0.0/8 and 192.168.0.0/24. The character C in the routing table
indicates that a route is a directly connected route.
NOTE
You can see only connected routes in a router’s routing table by typing the show ip route
connected command.
Static routes
By adding static routes, a router can learn a route to a remote network that is not
directly connected to one of its interfaces. Static routes are configured manually by
typing the global configuration mode command ip route DESTINATION_NETWORK
SUBNET_MASK NEXT_HOP_IP_ADDRESS. This type of configuration is usually
used in smaller networks because of scalability reasons (you have to configure each
route on each router).
A simple example will help you understand the concept of static routes.
First, consider the router A’s routing table before we add the static route:
Now, we’ll use the static route command to configure router A to reach the subnet
10.0.0.0/24. The router now has the route to reach the subnet.
The character S in the routing table indicates that a route is a statically configured
route.
Another version of the ip route command exists. You don’t have to specify the next-
hop IP address. You can rather specify the exit interface of the local router. In the
example above we could have typed the ip route DEST_NETWORK
NEXT_HOP_INTERFACE command to instruct router A to send all traffic destined
for the subnet out the right interface. In our case, the command would be ip route
10.0.0.0 255.255.255.0 Fa0/0.
R1#show ip route
Notice the lack of the default gateway or default route. If R1 tries to access a public
IP address (e.g. 4.2.2.2), the packets will be dropped because no route to that IP
address has been found in the routing table:
To create a default static route on R1, we need to use the following command:
The command above instructs R1 to match all IP address and subnet masks and
send the packets to 10.0.0.2 (the interface on R3 that is connected to R1). The
routing table on R1 now looks like this:
R1#show ip route
Notice how the gateway of last restort is now set to 10.0.0.2. There is also a route
marked with S* in the routing table, which means that the static default route we’ve
just configured is a candidate default route (since routers can learn about multiple
default routes), and * indicates that this static route is a candidate to become the
default route.
R1#ping 4.2.2.2
!!!!!
NOTE
Connected routes always take precedence over static or dynamically discovered routes because
they have the administrative distance value of 0 (the lowest possible value). In our case, this
means that R1 will send out packets destined for 192.168.0.0/24 according to the specified
connected route.
Dynamic routes
A router can learn dynamic routes if a routing protocol is enabled. A routing protocol
is used by routers to exchange routing information with each other. Every router in
the network can then use information to build its routing table. A routing protocol can
dynamicaly choose a different route if a link goes down, so this type of routing is
fault-tolerant. Also, unlike with static routing, there is no need to manually configure
every route on every router, which greatly reduces the administrative overhead. You
only need to define which routes will be advertised on a router that connect directly
to the corresponding subnets – routing protocols take care of the rest.
The disadvantage of dynamic routing is that it increases memory and CPU usage on
a router, because every router has to process received routing information and
calculate its routing table.
To better understand the advantages that dynamic routing procotols bring, consider
the following example:
Both routers are running a routing protocol, namely EIGRP. There is no static routes
on Router A, so R1 doesn’t know how to reach the subnet 10.0.0.0/24 that is directly
connected to Router B. Router B then advertises the subnet to Router A using
EIGRP. Now Router A has the route to reach the subnet. This can be verified by
typing the show ip route command:
You can see that Router A has learned the subnet from EIGRP. The letter D in front
of the route indicates that the route has been learned through EIGRP. If the subnet
10.0.0.0/24 fails, Router B can immediately inform Router A that the subnet is no
longer reachable.
You can display the administrative distance of all routes on your router by typing
the show ip route command:
In the case above, the router has only a single route in its routing table learned from
a dynamic routing protocols – the EIGRP route.
Metric
If a router learns two different paths for the same network from the same routing
protocol, it has to decide which route is better and will be placed in the routing table.
Metric is the measure used to decide which route is better (lower number is better).
Each routing protocol uses its own metric. For example, RIP uses hop counts as a
metric, while OSPF uses cost.
The following example explains the way RIP calculates its metric and why it chooses
one path over another.
RIP has been configured on all routers. Router 1 has two paths to reach the subnet
10.0.0.0/24. One path is goes through Router 2, while the other path goes through
Router 3 and then Router 4. Because RIP uses the hop count as its metric, the path
through Router 2 will be used to reach the 10.0.0.0/24 subnet. This is because that
subnet is only one router away on the path. The other path will have a higher metric
of 2, because the subnet is two routers away.
NOTE
The example above can be used to illustrate a disadvantage of using RIP as a routing protocol.
Imagine if the first path through R2 was the 56k modem link, while the other path (R3-R4) is a
high speed WAN link. Router R1 would still chose the path through R2 as the best route,
because RIP uses only the hop count as its metric.
The following table lists the parameters that various routing protocols use to
calculate the metric:
Routing protocols
Dynamic routes are routes learned via routing protocols. Routing protocols are
configured on routers with the purpose of exchanging routing information. There are
many benefits of using routing protocols in your network, such as:
unlike static routing, you don’t need to manually configure every route on each
router in the network. You just need to configure the networks to be advertised on a
router directly connected to them.
if a link fails and the network topology changes, routers can advertise that
some routes have failed and pick a new route to that network.
Cisco has created its own routing protocol – EIGRP. EIGRP is considered to be an
advanced distance vector protocol, although some materials erroneously state that
EIGRP is a hybrid routing protocol, a combination of distance vector and link state.
All of the routing protocols mentioned above are interior routing protocols (IGP),
which means that they are used to exchange routing information within one
autonomous system. BGP (Border Gateway Protocol) is an example of an exterior
routing protocol (EGP) which is used to exchange routing information between
autonomous systems on the Internet.
Distance vector protocols usually send the complete routing table to each neighbor
(a neighbor is directly connected router that runs the same routing protocol). They
employ some version of Bellman-Ford algorithm to calculate the best routes.
Compared with link state routing protocols, distance vector protocols are easier to
configure and require little management, but are susceptible to routing loops and
converge slower than the link state routing protocols. Distance vector protocols also
use more bandwidth because they send complete routing table, while the link state
procotols send specific updates only when topology changes occur.
Each router running a link state routing protocol creates three different tables:
neighbor table – the table of neighboring routers running the same link state
routing protocol.
topology table – the table that stores the topology of the entire network.
routing table – the table that stores the best routes.
Shortest Path First algorithm is used to calculate the best route. OSPF and IS-IS are
examples of link state routing protocols.
RIP overview
NOTE
RIP is not explicitly listed in the latest 200-301 version of the CCNA exam
topics (whereas OSPF is) but you can still be tested on it in the exam.
RIP (Routing Information Protocol) is one of the oldest distance vector routing
protocols. It is usually used on small networks because it is very simple to configure
and maintain, but lacks some advanced features of routing protocols like OSPF or
EIGRP. Two versions of the protocol exists: version 1 and version 2. Both versions
use hop count as a metric and have the administrative distance of 120. RIP version 2
is capable of advertising subnet masks and uses multicast to send routing updates,
while version 1 doesn’t advertise subnet masks and uses broadcast for updates.
Version 2 is backwards compatible with version 1.
RIPv2 sends the entire routing table every 30 seconds, which can consume a lot of
bandwidth. RIPv2 uses multicast address of 224.0.0.9 to send routing updates,
supports authentication and triggered updates (updates that are sent when a change
in the network occurs).
Configuring RIPv2
NOTE
RIP is not explicitly listed in the latest 200-301 version of the CCNA exam
topics (whereas OSPF is) but you can still be tested on it in the exam.
Configuring RIPv2 is a pretty straightforward process. Only three steps are required:
The first two commands are easy to comprehend, but the last command requires a
little bit more thought. With the network command you specify which interfaces will
participate in the routing process. This command takes a classful network as a
parameter and enables RIP on the corresponding interfaces.Let’s configure our
sample network to use RIP.
Router R1 and R2 have directly connected subnets. We want to include these
subnets in the RIP routing process. To do that, we first need to enable RIP on both
routers and then advertise these subnets using the network command.
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#network 10.0.0.0
R1(config-router)#network 172.16.0.0
The configuration on R2 looks similar, but with different network number for the
directly connected subnet:
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#network 192.168.0.0
R2(config-router)#network 172.16.0.0
You can verify that router R1 has a route to R2’s directly connected subnet by typing
the show ip route command:
The legend lists R for all RIP routes in the routing table. Also note that the
administrative distance of 120 is shown, together with the metric of 1.
passive-interface command
NOTE
RIP is not explicitly listed in the latest 200-301 version of the CCNA exam
topics (whereas OSPF is) but you can still be tested on it in the exam.
router rip
version 2
network 10.0.0.0
network 192.168.0.0
So in the example network above, RIP will also be activated on the interface
connected to the workstation on the right. This means that the workstation will also
receive RIP updates, which is pointless. To prevent this from happening, the passive
interface command is used:
R2(config)#router rip
R2(config-router)#passive-interface Gi0/1
Now, the RIP process will no longer send RIP updates out the Gi0/1 interface.
However, all received RIP updates will be processed and the subnet 10.0.0.0/24 will
still be advertised.
Distance vector protocols are susceptible to routing loops. Routing loops occur when
a packet is continually routed through the same routers over and over again, in an
endless circle. Because they can render a network unusable, distance vector routing
protocols (such as RIP and EIGRP) employ several different mechanisms to prevent
routing loops. We will describe them in this article.
Split Horizon
Split horizon is one of the features of distance vector routing protocols that prevents
routing loops. This feature prevents a router from advertising a route back onto the
interface from which it was learned.
Route poisoning
Route poisoning is another method for preventing routing loops employed by
distance vector routing protocols. When a router detects that one of its directly
connected routes has failed, it sends the advertisement for that route with an infinite
metric (poisoning the route). A router that receives the update knows that the route
has failed and doesn’t use it anymore.
Router R1 is directly connected to the 10.0.1.0/24 subnet. Router R1 runs RIP and
the subnet is advertised to R2. When the R1’s Fa0/1 interface fails, the route
advertisement is sent by R1 to R2 indicating that the route has failed. The route has
a metric of 16, which is more than the RIP’s maximum hop count of 15, so R1
considers the route to be unreachable.
Holddown timer
Holddown is another loop-prevention mechanism employed by distance vector
routing protocol. This feature prevents a router from learning new information about
a failed route. When a router receives the information about the unreachable route,
the holddown timer is started. The router ignores all routing updates for that route
until the timer expires (by default, 180 seconds in RIP). Only updates allowed during
that period are updates sent from the router that originally advertised the route. If
that router advertise the update, the holddown timer is stopped and the routing
information is processed.
An example will help you understand the concept better. Consider the following
network topology.
Router R1 has advertised its directly connected subnet 10.0.1.0/24 through RIP.
After some period of time, the interface Fa0/1 on R1 fails and the router R1 sends
the poisoned route to R2. R2 receives the routing update, marks the route as
unreachable and starts the holddown timer. During that time all updates from any
other routers about that route are ignored to prevent routing loops. If interface Fa0/1
on R1 comes back up, R1 again advertises the route. R2 process that update even if
the holddown timer is still running, because the update is sent by the same router
that originally advertised the route.
R3(config)#router rip
R3(config-router)#default-information originate
R1 and R2 don’t need any additional configuration – they learn the default route just
like any other RIP route:
As you can see from the output above, R1 learned about the default route via RIP.
The route is marked with an asterisk (*), indicating that the route is a candidate to be
the default route.
EIGRP overview
NOTE
EIGRP is not explicitly listed in the latest 200-301 version of the CCNA exam
topics (whereas OSPF is) but you can still be tested on it in the exam.
Administrative distance of EIGRP is 90, which is less than both the administrative
distance of RIP and the administrative distance of OSPF, so EIGRP routes will be
preferred over these routes. EIGRP uses Reliable Transport Protocol (RTP) for
sending messages.
EIGRP calculates its metric by using bandwidth, delay, reliability and load. By
default, only bandwidth and delay are used when calulating metric, while reliability
and load are set to zero.
EIGRP Neighbors
EIGRP must establish neighbor relationships with other EIGRP neighboring routers
before exchanging routing information. To establish a neighbor relationships, routers
send hello packets every couple of seconds. Hello packets are sent to the multicast
address of 224.0.0.10.
NOTE
On LAN interfaces hellos are sent every 5 seconds. On WAN interfaces every 60 seconds.
The following fields in a hello packet must be the identical in order for routers to
become neighbors:
Routers send hello packets every couple of seconds to ensure that the neighbor
relationship is still active. By default, routers considers the neighbor to be down after
a hold-down timer has expired. Hold-down timer is, by default, three times the hello
interval. On LAN network the hold-down timer is 15 seconds.
Feasible distance (FD) – the metric of the best route to reach a network.
That route will be listed in the routing table.
Reported distance (RD) – the metric advertised by a neighboring router for a
specific route. It other words, it is the metric of the route used by the neighboring
router to reach the network.
The feasible and reported distance are displayed in R1’s EIGRP topology table:
r - Reply status
the neighbor’s advertised distance (AD) for the route must be less than the
successor’s feasible distance (FD).
The following example explains the concept of a successor and a feasible
successor.
R1 has two paths to reach the subnet 10.0.0.0/24. The path through R2 has the best
metric (20) and it is stored in the R1’s routing table. The other route, through R3, is a
feasible successor route, because the feasiblility condition has been met (R3’s
advertised distance of 15 is less than R1’s feasible distance of 20). R1 stores that
route in the topology table. This route can be immediately used if the primary route
fails.
Best routes (the successors) from the topology table are stored in the routing table.
Feasible successors are only stored in the topology table and can be used
immediately if the primary route fails.
EIGRP configuration
NOTE
EIGRP is not explicitly listed in the latest 200-301 version of the CCNA exam
topics (whereas OSPF is) but you can still be tested on it in the exam.
Configuring EIGRP 1
EIGRP configuration closely resembles RIP configuration. Only two steps are
required:
The network depicted above consists of only two routers. Each router has a directly
connected subnet that needs to be advertised through EIGRP. Here is the EIGRP
configuration on R1 and R2:
You can verify that routers have become neighbors by using the show ip eigrp
neighbors command on either router:
The command above lists all EIGRP neighbors. The address field lists the
neighboring router RID (router ID). The interface field shows on which local interface
the neighbor relationship has been formed.
You can verify that routes are indeed being exchanged by using the show ip
route command on both routers:
R1:
R2:
NOTE
The D character at the beginning of a line in a routing table indicates that the route has been
learned via EIGRP.
Configuring EIGRP 2
By default, the network command uses a classful network as the parameter. All
interfaces inside that classful network will participate in the EIGRP process.To
enable EIGRP only on specific interfaces, a wildcard mask can be used. The syntax
of the command is:
By using the command show ip protocols, you can verify that only the network
10.0.0.0/24 is included in EIGRP:
Wildcard mask in EIGRP
NOTE
EIGRP is not explicitly listed in the latest 200-301 version of the CCNA exam
topics (whereas OSPF is) but you can still be tested on it in the exam.
The network command in EIGRP uses a classful network as the parameter by
default, which means that all interfaces inside the classful network will participate in
the EIGRP process. We can enable EIGRP only for specific networks using wildcard
masks. The syntax of the command is:
The router is directly connected to three subnets. Let’s say that we want to advertise
only the 10.0.0.0/24 subnet in EIGRP. We can use the wildcard mask of 0.0.0.255 to
do this:
R1#show ip protocols
Redistributing: eigrp 1
Maximum path: 4
10.0.0.0/24
Notice that 10.0.0.0/24 is listed under the Routing for Networks column. The other
two networks (10.0.1.0/24 and 10.0.5.0/24) are not included in EIGRP.
Router R1 and R2 are running EIGRP. Router R1 has the locally connected subnet
10.0.1.0/24 that is advertised to the router R2. Because of the auto summary feature,
the router R1 summarizes the network 10.0.1.0/24 before sending the route to R2.
With the auto summary feature turned on, R1 sends the classful route 10.0.0.0/8 to
R2 instead of the more specific 10.0.1.0/24 route.
But, because of the auto-summary feature, R2 receives the route to the classful
network 10.0.0.0/8:
The auto summary feature can cause problems with discontiguous networks. This is
why this feature is usually turned off. This is done by using the no auto-
summary command:
Now R2 has the classless route to reach the subnet 10.0.1.0/24:
NOTE
After typing the no auto-summary command, the neighbor relationship will be re-established.
EIGRP manual summarization
One of the advantages of EIGRP over some other routing protocols (like OSPF) is
that manual summarization can be done on any router within a network. A single
route can be used to represent multiple routes, which reduces the size of routing
tables in a network.
We could configure R1 to advertise only one summary route for both subnets, which
helps reduce R2’s routing table. To do this, the following command can be used:
Now, R1 is sending only one route to reach both subnets to R2. We can verify that
by using the show ip route command on R2:
Now R2 has only one route to reach both subnets on R1.
NOTE
In the example above, the ip summary command included two subnets on R1, but also some
other addresses that are not in these subnets. The range of the summarized addresses
is 10.0.0.0 – 10.0.255.255, so R2 thinks that R1 has the routes for all addresses inside that
range. That could cause some problems if these addresses exist somewhere else in the network.
EIGRP authentication
EIGRP authentication is used to prevent an attacker from forming the EIGRP
neighbor relationship with your router and advertising incorrect routing information.
By using the same preshared key (PSK) on all routers you can force EIGRP to
authenticate each EIGRP message. That way you can ensure that your router
accepts routing updates only from the trusted sources. To authenticate every
message, the MD5 (Message Digest 5) algorithm is used.
1. creating a keychain
2. specifying a key string for a key
3. configuring EIGRP to use authentication
EIGRP uses the concept of key chains. Each key chain can have many keys, just
like in real life. You can specify a different lifetime interval of each key. That way the
second key in a key chain can be used after the first one is expired, the third one
after the second and so on. After you have created a key chain with the
corresponding keys, you need to enable EIGRP authentication for a particular
interface.
To configure a router to use EIGRP configuration the following commands are used:
1. (global-config) key chain NAME – creates a keychain
2. (config-keychain) key NUMBER – identifies the key number
3. (config-keychain-key) key-string STRING – specifies the key string for the key
To establish a time frame for the validity of a key, you need to configure the accept-
lifetime and the send-lifetime parameters. The syntax of the commands is:
The first command specifies the time period during which the key will be accepted.
The second command specifies the time period during which the key will be sent.
For example, if we want to use a key only from January 1st, 2013 to December 1st,
2013, the following commands are used:
To better understand the equal-cost load balancing concept, consider the following
example.
All three routers are running EIGRP. Routers R2 and R3 are connected to the subnet
10.0.1.0/24. Both routers advertise the route to reach that subnet to R1. Router R1
receives the two routing updates for the subnet 10.0.1.0/24 with the same metric (the
metric is the same because both routers connect to the subnet 10.0.1.0/24 and R1
across the links with the same bandwidth and delay values). Router R1 places both
routes in the routing table and load balances across three links.
You can verify that R1 is indeed using both paths by typing the show ip
route command:
One of the advantages of EIGRP is that, unlike OSPF and many other routing
protocols, EIGRP also supports unequal-cost load balancing. You can set up your
router to load balance over links with different metric to reach the destination. To
accomplish unequal-cost load balancing, the variance command is used. The
command takes one parameter, the multiplier, which tells the router to load balance
across each link with the metric for the destination less than the feasible distance
multiplied by the multiplier value.
NOTE
The multiplier value, by default, is 1. The maximum value is 128.
All three routers are running EIGRP. Routers R2 and R3 are connected to the subnet
10.0.1.0/24. Both routers advertise the route to reach that subnet to R1. Router R1
chooses the route from R2 as the best route. Let’s say that R1 calculated the metric
of 40 for the path through R2. That route is placed in the R1’s routing table. But what
if we want to load balance traffic across the other link? The route through R3 has a
feasible distance of 30, which is less than the metric of the successor route, so the
feasibility condition has been met and that route has been placed in the R1’s
topology table. Let’s say that R1 calculated the metric of 60 for the route through R3.
To enable load balancing across that link, you need to use the variance command:
In our example, the variance 2 command can be used. This tells the router to load
balance across any links with the metric less then 80 (because 40 times 2 is 80). The
route through R3 is added to the routing table.
NOTE
A path has to be a feasible successor route to be used in unequal load balancing.
NOTE
The acronym RTP is also used for a different protocol – Real-time Transport Protocol (RTP),
used for VoIP communication.
EIGRP stores all routes advertised by all EIGRP neighbors. The metric of these
routes is used by DUAL to select the efficient and loop free paths. DUAL selects
routes that will be inserted into the routing table. If a route fails, and there is no
feasible successor, DUAL chooses a replacement route, which usually takes a
couple of seconds.
The following requirements must be met in order for DUAL to work properly:
EIGRP neighbors must discovered.
all transmitted EIGRP messages should be received correctly.
all changes and messages should be processed in the order in which they’re
detected.
EIGRP summary
NOTE
EIGRP is not explicitly listed in the latest 200-301 version of the CCNA exam
topics (whereas OSPF is) but you can still be tested on it in the exam.
OSPF overview
OSPF (Open Shortest Path First) is a link state routing protocol. Because it is an
open standard, it is implemented by a variety of network vendors. OSPF will run on
most routers that doesn’t necessarily have to be Cisco routers (unlike EIGRP which
can be run only on Cisco routers).
OSPF neighbors
OSPF routers need to establish a neighbor relationship before exchanging routing
updates. OSPF neighbors are dynamically discovered by sending Hello packets out
each OSPF-enabled interface on a router. Hello packets are sent to the multicast IP
address of 224.0.0.5.
Routers R1 and R2 are directly connected. After OSFP is enabled both routers send
Hellos to each other to establish a neighbor relationship. You can verify that the
neighbor relationship has indeed been established by typing the show ip ospf
neighbors command.
In the example above, you can see that the router-id of R2 is 2.2.2.2. Each OSPF
router is assigned a router ID. A router ID is determined by using one of the
following:
The following fields in the Hello packets must be the same on both routers in order
for routers to become neighbors:
subnet
area id
hello and dead interval timers
authentication
area stub flag
MTU
By default, OSPF sends hello packets every 10 second on an Ethernet network
(Hello interval). A dead timer is four times the value of the hello interval, so if a
routers on an Ethernet network doesn’t receive at least one Hello packet from an
OSFP neighbor for 40 seconds, the routers declares that neighbor to be down.
1. Init state – a router has received a Hello message from the other OSFP router
2. 2-way state – the neighbor has received the Hello message and replied with a
Hello message of his own
3. Exstart state – beginning of the LSDB exchange between both routers. Routers
are starting to exchange link state information.
4. Exchange state – DBD (Database Descriptor) packets are exchanged. DBDs
contain LSAs headers. Routers will use this information to see what LSAs need to be
exchanged.
5. Loading state – one neighbor sends LSRs (Link State Requests) for every
network it doesn’t know about. The other neighbor replies with the LSUs (Link State
Updates) which contain information about requested networks. After all the
requested information have been received, other neighbor goes through the same
process
6. Full state – both routers have the synchronized database and are fully adjacent
with each other.
OSPF areas
OSPF uses the concept of areas. An area is a logical grouping of contiguous
networks and routers. All routers in the same area have the same topology table, but
they don’t know about routers in the other areas. The main benefits of creating areas
is that the size of the topology and the routing table on a router is reduced, less time
is required to run the SFP algorithm and routing updates are also reduced.
Each area in the OSPF network has to connect to the backbone area (area 0). All
router inside an area must have the same area ID to become OSPF neighbors. A
router that has interfaces in more than one area (area 0 and area 1, for example) is
called Area Border Router (ABR). A router that connects an OSPF network to other
routing domains (EIGRP network, for example) is called Autonomous System
Border Router (ASBR).
NOTE
In OSPF, manual route summarization is possible only on ABRs and ASBRs.
OSPF configuration
Configuring OSPF 1
OSPF basic configuration is very simple. Just like with other routing protocols
covered so far (RIP, EIGRP) first you need to enable OSPF on a router. This is done
by using the router ospf PROCESS-ID global configuration command. Next, you
need to define on which interfaces OSPF will run and what networks will be
advertised. This is done by using the network IP_ADDRESS WILDCARD_MASK
AREA_ID command from the ospf configuration mode.
NOTE
The OSPF process number doesn’t have to be the same on all routers in order to establish a
neighbor relationship, but the Area ID has to be the same on all neighboring routers in order for
routers to become neighbors.
Let’s get started with some basic OSPF configuration. We will use the following
network topology:
First, we need to enable OSPF on both routers. Then we need to define what
network will be advertised into OSPF. This can be done by using the following
sequence of commands on both routers:
The network commands entered on both routers include subnets directly connected
to both routers. We can verify that the routers have become neighbors by typing
the show ip ospf neighbors command on either router:
You can see that R1 has learned about the network 192.168.0.0/24 through OSPF.
Configuring OSPF 2
Although basic OSPF configuration can be very simple, OSPF provides many extra
features that can get really complex. In this example, we will configure multiarea
OSPF network and some other OSPF features.
In this example we have two OSPF areas – area 0 and area 1. As you can see from
the network topology depicted above, routers R1 and R3 are in the area 0 and area
1, respectively. Router 2 connects to both areas, which makes him an ABR (Area
Border Router). Our goal is to advertise the subnets directly connected to R1 and
R3. To do that, the following configuration on R1 will be used:
NOTE
We have used the router-id 1.1.1.1 command to manually specify the router ID of this router.
OSPF process will use that RID (router-id) when communicating with other OSPF neighbors.
Configuration of R3 looks similar, but with one difference, namely area number. R3 is
in the area 1.
Now R2 should have neighbor relationship with both R1 and R3. We can verify that
by using the show ip ospf neighbor command:
To verify if directly connected subnets are really advertised into the different area, we
can use the show ip route ospf command on both R1 and R3:
Characters IA in front of the routes indicate that these routes reside in different
areas.
NOTE
Since they reside in different areas, R1 and R3 will never establish a neighbor relationship.
Every router on a network segment will establish a full neighbor relationship with the
DR and BDR. Non-DR and non-BDR routers will establish a two way neighbor
relationship between themselves.
NOTE
On point-to-point links, a DR and BDR are not elected since only two routers are directly
connected.
On LANs, DR and BDR have to be elected. Two rules are used to elect a DR and
BDR:
1. router with the highest OSPF priority will become a DR. By default, all routers
have a priority of 1.
2. if there is a tie, a router with the highest router ID wins the election. The router
with the second highest OSPF priority or router ID will become a BDR.
We can verify that R1 and R2 are indeed the DR and BDR of the segment by typing
the show ip ospf neighbors command on R3:
NOTE
You can influence the DR and BDR election process by manually configuring the OSPF priority.
This is done by using the ip ospf priority VALUE command interface command.
OSPF authentication
OSPF can be configured to authenticate every OSPF message. This is usually done
to prevent a rogue router from injecting false routing information and therefore
causing a Denial-of-Service attack.
Both routers are running OSPF. On R1, we need to enter the following commands:
To verify that clear-text authentication is indeed turned on, we can use the show ip
ospf interface INTERFACE_NUMBER/INTERFACE_TYPE command on either
router:
Configuring OSPF MD5 authentication is very similar to configuring clear-text
authentication. Two commands are also used:
1. First you need to configure the MD5 value on an interface by using the ip ospf
message-digest-key 1 md5 VALUE interface command
2. Next, you need to configure the interface to use MD5 authentication by using
the ip ospf authentication message-digest interface command
You can verify that R1 is using OSPF MD5 authentication by typing the show ip ospf
INTERFACE/INTERFACE_TYPE command:
NOTE
OSPF authentication type can also be enabled on an area basis, instead of configuring OSPF
authentication type per interface basis. This is done by using the area AREA_ID authentication
[message-digest] command under the OSPF configuration mode. If you omit the message-
digest keyword, a clear-text authentication will be used for that area. All interfaces inside the
area will use OSPF authentication.
OSPF summarization
Route summarization helps reduce OSPF traffic and route computation. OSPF,
unlike EIGRP, doesn’t support automatic summarization. Also, unlike EIGRP, where
you can summarize routes on every router in an EIGRP network, OSFP can
summarize routes only on ABRs and ASBRs.
All three routers are running OSPF and exchanging routes. Before OSPF
summarization is configured, the router R1 inside the backbone area has two entries
for the networks 11.0.0.0/24 and 11.0.1.0/24 in its routing table.
Router#show ip route
We could summarize these two subnets on R2, so that R1 receives only one routing
update for both subnets. To do that, the following command can be used on R2:
Router(config)#router ospf 1
Now, R1 has only one entry in its routing table for R3’s directly connected subnets:
Router#show ip route
OSPF summary
Here is a list of the most important OSPF features:
converges fast
open standard
For example on how ACLs are used, consider the following network topology:
Let’s say that server S1 holds some important documents that need to be available
only to the company’s management. We could configure an access list on R1 to
enable access to S1 only to users from the management network. All other traffic
going to S1 will be blocked. This way, we can ensure that only authorized user can
access the sensitive files on S1.
Types of ACLs
There are two types of access lists:
1. standard access lists – with standard access lists, you can filter only on the
source IP address of a packet. These types of access list are not as powerful as
extended access lists, but they are less processor intensive for the router.
The following example describes the way in which standard access lists can be
used.
Let’s say that server S1 holds some important documents that need to be available
only to company’s management. We could configure an access list on R1 to enable
access to S1 only to users from the management network. All other traffic going to
S1 will be blocked. This way, we can ensure that only authorized user can access
sensitive files on S1.
2. extended access lists – with extended access lists, you can be more precise in
your filtering. You can evaluate source and destination IP addresses, type of layer 3
protocol, source and destination port, etc. Extended access lists are more complex
to configure and consume more CPU time than the standard access lists, but they
allow a much more granular level of control.
To demonstrate the usefulness of extended ACLs, we will use the following example.
In the example network above, we have used the standard access list to prevent all
users to access server S1. But, with that configuration, we have also disable access
to S2! To be more specific, we can use extended access lists. Let’s say that we need
to prevent users from accessing server S1. We could place an extended access list
on R1 to prevent users only from accessing S1 (we would use an access list to filter
the traffic according to the destination IP address). That way, no other traffic is
forbidden, and users can still access the other server, S2:
Configuring standard ACLs
To create an standard access list on a Cisco router, the following command is used
from the router’s global configuration mode:
NOTE
ACL number for the standard ACLs has to be between 1–99 and 1300–1999.
You can also use the host keyword to specify the host you want to permit or deny:
Once the access list is created, it needs to be applied to an interface. You do that by
using the ip access-group ACL_NUMBER in|out interface
subcommand. in and out keywords specify in which direction you are activating the
ACL. in means that ACL is applied to the traffic coming into the interface, while
the out keyword means that the ACL is applied to the traffic leaving the interface.
We want to allow traffic from the management LAN to the server S1. First, we need
to write an ACL to permit traffic from LAN 10.0.0.0/24 to S1. We can use the
following command on R1:
The command above permits traffic from all IP addresses that begin with 10.0.0. We
could also target the specific host by using the host keyword:
The command above permits traffic only from the host with the IP address of
10.0.0.1.
Next, we need to apply the access list to an interface. It is recommended to place the
standard access lists as close to the destination as possible. In our case, this is
the Fa0/0 interface on R1. Since we want to evaluate all packets trying to exit
out Fa0/0, we will specify the outbound direction with the out keyword:
NOTE
At the end of each ACL there is an implicit deny all statement. This means that all traffic not
specified in earlier ACL statements will be forbidden, so the second ACL statement (access-list 1
deny 11.0.0.0 0.0.0.255) wasn’t even necessary.
With extended access lists, you can evaluate additional packet information, such as:
NOTE
Extended access lists numbers are in ranges from 100 to 199 and from 2000 to 2699. You
should always place extended ACLs as close to the source of the packets that are being
evaluated as possible.
To better understand the concept of extended access lists, consider the following
example:
We want to enable the administrator’s workstation (10.0.0.1/24) unrestricted access
to Server (192.168.0.1/24). We will also deny any type of access to Server from the
user’s workstation (10.0.0.2/24).
First, we’ll create a statement that will permit the administrator’s workstation access
to Server:
Next, we need to create a statement that will deny the user’s workstation access to
Server:
R1(config)#int f0/0
This will force the router to evaluate all packets entering Fa0/0. If the administrator
tries to access Server, the traffic will be allowed, because of the first statement.
However, if User tries to access Server, the traffic will be forbidden because of the
second ACL statement.
NOTE
At the end of each access list there is an explicit deny all statement, so the second ACL
statement wasn’t really necessary. After applying an access list, every traffic not explicitly
permited will be denied.
What if we need to allow traffic to Server only for certain services? For example, let’s
say that Server was a web server and users should be able to access the web pages
stored on it. We can allow traffic to Server only to certain ports (in this case, port 80),
and deny any other type of traffic. Consider the following example:
On the right side, we have a Server that serves as a web server, listening on port 80.
We need to permit User to access web sites on S1 (port 80), but we also need to
deny other type of access.
First, we need to allow traffic from User to the Server port of 80. We can do that
using the following command:
By using the tcp keyword, we can filter packets by the source and destination ports.
In the example above, we have permitted traffic from 10.0.0.2 (User’s workstation) to
192.168.0.1 (Server) on port 80. The last part of the statement, eq 80, specifies the
destination port of 80.
Since at the end of each access list there is an implicit deny all statement, we don’t
need to define any more statement. After applying an access list, every traffic not
originating from 10.0.0.2 and going to 192.168.0.1, port 80 will be denied.
R1(config)#int f0/0
We can verify whether our configuration was successful by trying to access Server
from the User’s workstation using different methods. For example, the ping will fail:
C:\>ping 192.168.0.1
C:\>telnet 192.168.0.1 21
The command above moves you to the ACL configuration mode, where you can
configure the permit and deny statements. Just like with numbered ACLs, named
ACLs ends with the implicit deny statement, so any traffic not explicitly permitted will
be forbidden.
Once inside the ACL config mode, we need to create a statement that will deny the
user’s workstation access to the Domain server:
Now, we will execute a statement that will permit the workstation access to the File
share:
Lastly, we need to apply the access list to the Gi0/0 interface on R1:
R1(config)#int Gi0/0
The commands above will force the router to evaluate all packets trying to enter
Gi0/0. If the workstation tries to access the Domain server, the traffic will be
forbidden because of the first ACL statement. However. if the user tries to access
the File server, the traffic will be allowed, because of the second statement.
R1#show ip access-lists
Notice the sequence number at the beginning of each entry. If we need to stick a
new entry between these two entries, we can do that by specifying a sequence
number in the range between 20 and 50. If we don’t specify the sequence number,
the entry will be added to the bottom of the list.
C:\>ping 192.168.0.1
C:\>
C:\>ping 192.168.0.2
As you can see from the ping output above, the traffic is being filtered properly.
What is NAT?
NAT (Network Address Translation) is a process of changing the source and
destination IP addresses and ports. Address translation reduces the need for IPv4
public addresses and hides private network address ranges. This process is usually
done by routers or firewalls.
1. Static NAT – translates one private IP address to a public one. The public IP
address is always the same.
2. Dynamic NAT – private IP addresses are mapped to the pool of public IP
addresses.
3. Port Address Translation (PAT) – one public IP address is used for all
internal devices, but a different port is assigned to each private IP address. Also
known as NAT Overload.
4.Static NAT
5. With static NAT, routers or firewalls translate one private IP address to a
single public IP address. Each private IP address is mapped to a single public
IP address. Static NAT is not often used because it requires one public IP
address for each private IP address.
6. To configure static NAT, three steps are required:
7. 1. configure private/public IP address mapping by using the ip nat inside
source static PRIVATE_IP PUBLIC_IP command
2. configure the router’s inside interface using the ip nat inside command
3. configure the router’s outside interface using the ip nat outside command
8. Here is an example.
9.
10. Computer A requests a web resource from S1. Computer A uses its private IP
address when sending the request to router R1. Router R1 receives the
request, changes the private IP address to the public one and sends the
request to S1. S1 responds to R1. R1 receives the response, looks up in its
NAT table and changes the destination IP address to the private IP address
of Computer A.
11. In the example above, we need to configure static NAT. To do that, the
following commands are required on R1:
12.
13. Using the commands above, we have configured a static mapping between
Computer A’s private IP address of 10.0.0.2 and router’s R1 public IP address
of 59.50.50.1. To check NAT, you can use the show ip nat
translations command:
14.
Dynamic NAT
Unlike with static NAT, where you had to manually define a static mapping between
a private and public address, dynamic NAT does the mapping of a local address to
a global address happens dynamically. This means that the router dynamically picks
an address from the global address pool that is not currently assigned. The dynamic
entry stays in the NAT translations table as long as the traffic is exchanged. The
entry times out after a period of inactivity and the global IP address can be used for
new translations.
With dynamic NAT, you need to specify two sets of addresses on your Cisco router:
1. First we need to configure the router’s inside and outside NAT interfaces:
R1(config)#int f0/0
R1(config-if)#int f0/1
2. Next, we need to configure an ACL that will include a list of the inside source
addresses that will be translated. In this example we want to translate all inside hosts
on the 10.0.0.0/24 network:
The command above tells the router to translate all addresses specified in
the access list 1 to the pool of global addresses named MY POOL.
You can list all NAT translations using the show ip nat translations command.
In the output above you can see that the translation has been made between the
Host A’s private IP address (Inside local, 10.0.0.100) to the first available public IP
address from the pool (Inside global, 155.4.12.1) and it is connecting to the server on
the outside (Outside local and Outside global, 155.4.12.5) .
NOTE
You can remove all NAT translations from the table by using the clear ip nat translation
* command.
PAT allows you to support many hosts with only few public IP addresses. It works by
creating dynamic NAT mapping, in which a global (public) IP address and a unique
port number are selected. The router keeps a NAT table entry for every unique
combination of the private IP address and port, with translation to the global address
and a unique port number.
We will use the following example network to explain the benefits of using PAT:
As you can see in the picture above, PAT uses unique source port numbers on the
inside global (public) IP address to distinguish between translations. For example, if
the host with the IP address of 10.0.0.101 wants to access the server S1 on the
Internet, the host’s private IP address will be translated by R1 to 155.4.12.1:1056
and the request will be sent to S1. S1 will respond to 155.4.12.1:1056. R1 will
receive that response, look up in its NAT translation table, and forward the request to
the host.
Here is how we would configure PAT for the network picture above.
R1(config-if)#int Gi0/1
Next, we will define an access list that will include all private IP addresses we would
like to translate:
The access list defined above includes all IP addresses from the 10.0.0.0 –
10.0.0.255 range.
Now we need to enable NAT and refer to the ACL created in the previous step and
to the interface whose IP address will be used for translations:
Notice that the same IP address (155.4.12.1) has been used to translate three
private IP addresses (10.0.0.100, 10.0.0.101, and 10.0.0.102). The port number of
the public IP address is unique for each connection. So when S1 responds to
155.4.12.1:1026, R1 look into its NAT translations table and forward the response to
10.0.0.102:1025
What is IPv6?
IPv6 is the newest version of the IP protocol. IPv6 was developed to overcome many
deficiencies of IPv4, most notably the problem of IPv4 address exhaustion. Unlike
IPv4, which has only about 4.3 billion (2 raised to power 32) available addresses,
IPv6 allows for 3.4 × 10 raised to power 38 addresses.
IPv6 features
Here is a list of the most important features of IPv6:
IPv6 address shortening
The IPv6 address given above looks daunting, right? Well, there are two
conventions that can help you shorten what must be typed for an IP address:
1. a leading zero can be omitted
For example, the address listed above
(2340:0023:AABA:0A01:0055:5054:9ABC:ABB0) can be shortened
to 2340:23:AABA:A01:55:5054:9ABC:ABB0
2. successive fields of zeroes can be represented as two colons (::)
For example, 2340:0000:0000:0000:0455:0000:AAAB:1121 can be written
as 2340::0455:0000:AAAB:1121
NOTE
You can shorten an address this way only for one such occurrence. The reason is
obvious – if you had more than occurence of double colon you wouldn’t know how many
sets of zeroes were being omitted from each part.
Here is a couple of more examples that can help you grasp the concept of
IPv6 address shortening:
Long version: 1454:0045:0000:0000:4140:0141:0055:ABBB
Shortened version: 1454:45::4140:141:55:ABBB
Long version: 0000:0000:0001:AAAA:BBBC:A222:BBBA:0001
Shortened version: ::1:AAAA:BBBC:A222:BBBA:1
NOTE
IPv6 doesn’t use the broadcast method, but multicast to all hosts on the network provides the
functional equivalent.
Unicast Addresses
Figure 4-6 diagrams the three types of addresses: unicast, multicast, and anycast. We begin by
looking at unicast addresses. Don’t be intimidated by all the different types of unicast addresses. The
most significant types are global unicast addresses, which are equivalent to IPv4 public addresses,
and link-local addresses. These address types are discussed in detail in Chapters 5 and 6.
Figure 4-6 IPv6 Address Types: Unicast Addresses
A unicast address uniquely identifies an interface on an IPv6 device. A packet sent to a unicast
address is received by the interface that is assigned to that address. Similar to IPv4, a source IPv6
addresses must be a unicast address.
NOTE
Notice that there is no broadcast address shown in Figure 4-6. Remember that IPv6 does not include
a broadcast address.
This section covers the different types of unicast addresses, as illustrated in Figure 4-6. The following
is a quick preview of each type of unicast address discussed in this section:
Global unicast: A routable address in the IPv6 Internet, similar to a public IPv4 address
(covered in more detail in Chapter 5).
Link-local: Used only to communicate with devices on the same local link (covered in more
detail in Chapter 6).
Loopback: An address not assigned to any physical interface that can be used for a host to
send an IPv6 packet to itself.
Unspecified address: Used only as a source address and indicates the absence of an IPv6
address.
Unique local: Similar to a private address in IPv4 (RFC 1918) and not intended to be
routable in the IPv6 Internet. However, unlike RFC 1918 addresses, these addresses are not
intended to be statefully translated to a global unicast address.
IPv4 embedded: An IPv6 address that carries an IPv4 address in the low-order 32 bits of the
address.
Figure 4-7 shows the generic structure of a GUA, which has three fields:
Global Routing Prefix: The Global Routing Prefix is the prefix or network portion of the
address assigned by the provider, such as an ISP, to the customer site.
Subnet ID: The Subnet ID is a separate field for allocating subnets within the customer site.
Unlike with IPv4, it is not necessary to borrow bits from the Interface ID (host portion) to
create subnets. The number of bits in the Subnet ID falls between where the Global Routing
Prefix ends and where the Interface ID begins. This makes subnetting simple and
manageable.
Interface ID: The Interface ID identifies the interface on the subnet, equivalent to the host
portion of an IPv4 address. The Interface ID in most cases is 64 bits.
Link-Local Address
A link-local address is an IPv6 unicast address that can be automatically configured on any
interface using the link-local prefix FE80::/10 (1111 1110 10) and the interface identifier in
the modified EUI-64 format. Link-local addresses are used in the neighbor discovery protocol
and the stateless autoconfiguration process. Nodes on a local link can use link-local addresses
to communicate; the nodes do not need globally unique addresses to communicate. The figure
below shows the structure of a link-local address.
IPv6 devices must not forward packets that have link-local source or destination addresses to
other links.
Figure Link-Local Address Format
2
IPv6 Address Type Multicast
An IPv6 multicast address is an IPv6 address that has a prefix of FF00::/8 (1111 1111). An
IPv6 multicast address is an identifier for a set of interfaces that typically belong to different
nodes. A packet sent to a multicast address is delivered to all interfaces identified by the
multicast address. The second octet following the prefix defines the lifetime and scope of the
multicast address. A permanent multicast address has a lifetime parameter equal to 0; a
temporary multicast address has a lifetime parameter equal to 1. A multicast address that has
the scope of a node, link, site, or organization, or a global scope has a scope parameter of 1,
2, 5, 8, or E, respectively. For example, a multicast address with the prefix FF02::/16 is a
permanent multicast address with a link scope. The figure below shows the format of the
IPv6 multicast address.
Figure IPv6 Multicast Address Format
6
IPv6 nodes (hosts and routers) are required to join (receive packets destined for) the
following multicast groups:
IPv6 routers must also join the all-routers multicast group FF02:0:0:0:0:0:0:2 (scope is link-
local).
The solicited-node multicast address is a multicast group that corresponds to an IPv6 unicast
or anycast address. IPv6 nodes must join the associated solicited-node multicast group for
every unicast and anycast address to which it is assigned. The IPv6 solicited-node multicast
address has the prefix FF02:0:0:0:0:1:FF00:0000/104 concatenated with the 24 low-order bits
of a corresponding IPv6 unicast or anycast address (see the figure below). For example, the
solicited-node multicast address corresponding to the IPv6 address 2037::01:800:200E:8C6C
is FF02::1:FF0E:8C6C. Solicited-node addresses are used in neighbor solicitation messages.
Figure IPv6 Solicited-Node Multicast Address Format
7
Not There are no broadcast addresses in IPv6. IPv6 multicast addresses are used instead
e of broadcast addresses.
An IPv6 address must be configured on an interface before the interface can forward IPv6
traffic. Configuring a site-local or global IPv6 address on an interface automatically
configures a link-local address and activates IPv6 for that interface. Additionally, the
configured interface automatically joins the following required multicast groups for that link:
Not The solicited-node multicast address is used in the neighbor discovery process.
e
All-nodes link-local multicast group FF02::1
All-routers link-local multicast group FF02::2
When IPv6 or IPv4 command output displays an IPv6 address, a long IPv6 address can
overflow into neighboring fields, causing the output to be difficult to read. The output fields
were designed to work with the longest possible IPv4 address, which has 15 characters; IPv6
addresses can be up to 39 characters long. The following scheme has been adopted in IPv4
and IPv6 commands to allow the appropriate length of IPv6 address to be displayed and
move the following fields to the next line, if necessary. The fields that are moved are kept in
alignment with the header row.
The following example displays eight connections. The first six connections feature IPv6
addresses; the last two connections feature IPv4 addresses.
Device# where
Conn Host Address Byte Idle Conn Name
1 test5 2001:DB8:3333:4::5 6 24 test5
2 test4 2001:DB8:3333:44::5
6 24 test4
3 2001:DB8:3333:4::5 2001:DB8:3333:4::5 6 24 2001:DB8:3333:4::5
4 2001:DB8:3333:44::5
2001:DB8:3333:44::5
6 23 2001:DB8:3333:44::5
5 2001:DB8:3000:4000:5000:6000:7000:8001
2001:DB8:3000:4000:5000:6000:7000:8001
6 20
2001:DB8:3000:4000:5000:6000:
6 2001:DB8:1::1 2001:DB8:1::1 0 1 2001:DB8:1::1
7 10.1.9.1 10.1.9.1 0 0 10.1.9.1
8 10.222.111.222 10.222.111.222 0 0 10.222.111.222
Connection 1 contains an IPv6 address that uses the maximum address length in the address
field. Connection 2 shows the IPv6 address overflowing the address field and the following
fields moved to the next line, but in alignment with the appropriate headers. Connection 3
contains an IPv6 address that fills the maximum length of the hostname and address fields
without wrapping any lines. Connection 4 shows the effect of both the hostname and address
fields containing a long IPv6 address. The output is shown over three lines keeping the
correct heading alignment. Connection 5 displays a similar effect as connection 4 with a very
long IPv6 address in the hostname and address fields. Note that the connection name field is
actually truncated. Connection 6 displays a very short IPv6 address that does not require any
change in the display. Connections 7 and 8 display short and long IPv4 addresses.
Not The IPv6 address output display applies to all commands that display IPv6 addresses.
e
The basic IPv4 packet header has 12 fields with a total size of 20 octets (160 bits) (see the
figure below). The 12 fields may be followed by an Options field, which is followed by a
data portion that is usually the transport-layer packet. The variable length of the Options field
adds to the total size of the IPv4 packet header. The shaded fields of the IPv4 packet header
shown in the figure below are not included in the IPv6 packet header.
Figure IPv6 Packet Header Format
9
The table below lists the fields in the basic IPv6 packet header.
Field Description
Traffic Class Similar to the Type of Service field in the IPv4 packet
header. The Traffic Class field tags packets with a traffic
class that is used in differentiated services.
Flow Label A new field in the IPv6 packet header. The Flow Label
field tags packets with a specific flow that differentiates
the packets at the network layer.
Payload Length Similar to the Total Length field in the IPv4 packet
header. The Payload Length field indicates the total
length of the data portion of the packet.
Next Header Similar to the Protocol field in the IPv4 packet header.
The value of the Next Header field determines the type
of information following the basic IPv6 header. The type
of information following the basic IPv6 header can be a
transport-layer packet, for example, a TCP or UDP
packet, or an Extension Header, as shown in the figure
immediately above.
Hop Limit Similar to the Time to Live field in the IPv4 packet
header. The value of the Hop Limit field specifies the
maximum number of devices that an IPv6 packet can
pass through before the packet is considered invalid.
Each device decrements the value by one. Because no
checksum is in the IPv6 header, the device can
decrement the value without needing to recalculate the
checksum, which saves processing resources.
Source Address Similar to the Source Address field in the IPv4 packet
header, except that the field contains a 128-bit source
address for IPv6 instead of a 32-bit source address for
IPv4.
Following the eight fields of the basic IPv6 packet header are optional extension headers and the
data portion of the packet. If present, each extension header is aligned to 64 bits. There is no
fixed number of extension headers in an IPv6 packet. The extension headers form a chain of
headers. Each extension header is identified by the Next Header field of the previous header.
Typically, the final extension header has a Next Header field of a transport-layer protocol, such
as TCP or UDP. The figure below shows the IPv6 extension header format.
For more information about IPv6 addressing, see RFC 3513, Internet Protocol Version 6
(IPv6) Addressing Architecture.
IPv6 interface identifier
The second part of an IPv6 unicast or anycast address is typically a 64-bit interface
identifier used to identify a host’s network interface. A 64-bit interface ID is created
by inserting the hex value of FFFE in the middle of the MAC address of the network
card. Also, the 7th Bit in the first byte is flipped to a binary 1 (if the 7th bit is set to 0 it
means that the MAC address is a burned-in MAC address). When this is done, the
interface ID is commonly called the modified extended unique identifier 64 (EUI-
64).
hex 00BBCCDD1122
binary 0000 0000 1011 1011 1100 1100 1101 1101 0001 0001 0010 0010
binary 0000 0010 1011 1011 1100 1100 1101 1101 0001 0001 0010 0010
hex 02BBCCDD1122
Next we need to insert FFFE in the middle of the address listed above:
hex 02BBCCFFFEDD1122
binary: 0000 0010 0000 0000 0000 1100 0100 0011 0010 1010 0011 0101
hex: 02000C432A35
interface ID: 02000CFFFE432A35
As with IPv4, IPv6 routing protocols can be distance vector and link-state. An
example of a distance vector protocol is RIPng with hop count as the metric. An
example of a link-state routing protocol is OSPF with cost as the metric.
Here is an IPv6 configuration example:
R1(config)#ipv6 unicast-routing
R1(config)#int Gi0/0
We can verify that the IPv6 address has been configured by using the show ipv6
interface Gi0/0 command:
FF02::1
FF02::2
FF02::1:FF65:3E01
....
1. the link local IPv6 address has been automatically configured. Link local IP
addresses begin with FE80::/10 and the interface ID is used for the rest of the
address. Because the MAC address of the interface is 00:01:42:65:3E01, the
calculated address is FE80::201:42FF:FE65:3E01.
2. the global IPv6 address has been created using the modified EUI-64 method.
Remember that IPv6 global addresses begin with 2000::/3. So in our case, the IPv6
global address is 2001:BB9:AABB:1234:201:42FF:FE65:3E01.
We will also create an IPv6 address on another router. This time we will enter the
whole address:
!!!!!
As you can see from the output above, the devices can communicate with each
other.
RIPng
RIPng is an extension of RIP developed for support of IPv6. Here are some of its
features:
just like RIP for IPv4, it uses hop count as the metric
sends updates every 30 seconds
RIPng messages use the UDP port 521 and the multicast address of FF02::9
1. enable RIPng using the global configuration command ipv6 router rip tag. The tag
is used to differentiate between multiple RIP processes. It does not have to be the
same on all routers in order to exchange routing information..
2. enable the routing protocol on the interface using the ipv6 rip tag enable. The tag
has to match the one used in the ipv6 router rip tag command.
Here is an example:
We have done a similar configuration on the second router. To verify that routers are
indeed exchanging route information using RIPng we can use the show ipv6
route command:
In the picture above, we can see that the router has received a route to the
network 2001:BBBB:CCCC:DDDD::/64.