Lec 5,6
Lec 5,6
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 1
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.
▪ Consider the following example of IP routing:
▪ 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.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 2
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.
▪ Host A has an IP address of the router R1 configured as the default gateway address. Host A
is trying to communicate with host B, a host on another, remote network. Host A looks up
in its routing table to check if there is an entry for that destination network. If the entry is
not found, the host sends all data to the router R1. Router R1 receives the packets and
forwards them to host B.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 3
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:
▪ network destination and subnet mask – specifies a range of IP addresses.
▪ remote router – IP address of the router used to reach that network.
▪ outgoing interface – outgoing interface the packet should go out to reach the
destination network.
▪ There are three different methods for populating a routing table:
➢ directly connected subnets
➢ using static routing
➢ using dynamic routing
▪ Consider the 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.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 4
Routing table
▪ We can use the show ip route command from the enabled mode to display the router’s routing table.
▪ 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.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 5
Connected, static &
dynamic routes
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 6
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 7
Routers Determine the Best Path
▪ When a router only has its interfaces configured, and the routing
table contains the directly connected networks but no other routes,
only devices on those directly connected networks are reachable.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 11
Devices on Directly Connected Networks
? X?
X
▪ When a router only has its interfaces configured, and the routing
table contains the directly connected networks but no other routes,
only devices on those directly connected networks are reachable.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 12
Routers Determine the Best Path
Data for Host
192.168.3.22 / 24
The host determines that
the destination network is
different from its network.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 13
Configuring Static Routes
▪ R1 in our chapter topology knows
about its directly connected networks.
▪ By adding static routes, a router can
learn a route to a remote network that
is not directly connected to one of its
interfaces. This type of configuration
is usually used in smaller networks
(you have to configure each route on
each router).
▪ The character S in the routing table
indicates that a route is a statically
configured route.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 14
Configuring Static Routes
172.16.2.2 / 24
172.16.2.1 / 24
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 16
Configuring a Static Route with an Exit Interface
▪ Notice that the entry in the routing table no longer refers to the next-
hop IP address but refers directly to the exit interface.
• The table lookup will now resolve the route to the same Serial 0/0/0
interface in a single lookup.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 17
Resolving to an Exit Interface
Packet for 192.168.2.20
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 18
Exit Interface is Down
BEFORE
AFTER
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 19
Exit Interface is Down
REINSTATED
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 20
Modifying Static Routes
▪ There is no way to modify a static route. It must be
deleted and reconfigured.
You have entered this static route and testing fails.
OOOPS! That’s the wrong next-hop address!
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 21
Default route
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 22
Default static route
▪ A default route defines where packets will be sent if no specific route for the destination network
is listed in the routing table. If no default route is set, the router will discard all packets with
destination addresses not found its routing table.
▪ Consider the following example:
▪ We have a network of three routers. R1 is directly connected to two subnets – 192.168.0.0/24 and
10.0.0.0/24. R3 is connected to the Internet.
▪ Here is the routing table on R1:
▪ 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
Chapter 1
routing table:
ITE PC v4.0
© 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 23
Default static route
▪ 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:
▪ Notice how the gateway of last resort 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
ITE PC v4.0route is a candidate to become the default route.
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. 24
Cisco Public
Static Routes and Packet Forwarding
▪ Packet forwarding with
static routes.
▪ Router 1
➢ Packet arrives on R1’s
Fastethernet 0/0 interface
➢ R1 does not have a route
to the destination network,
192.168.2.0/24
➢ R1 uses the default
static route.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 25
Static Routes and Packet Forwarding
▪ Packet forwarding with static routes.
▪ Router 2
The packet arrives on the Serial 0/0/0 interface on R2.
R2 has a static route to 192.168.2.0/24 out Serial0/0/1.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 26
Static Routes and Packet Forwarding
▪ Packet forwarding with static routes.
▪ Router 3
The packet arrives on the Serial0/0/1 interface on R3.
R3 has a connected route to 192.168.2.0/24 out Fastethernet 0/1.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 27
Static Routes and Packet Forwarding
▪ Troubleshooting a Missing Route
▪ Tools that can be used to isolate routing problems
include:
-Ping– tests end to end connectivity
-Traceroute– used to discover all of the hops (routers) along the
path between 2 points
-Show IP route– used to display routing table & ascertain
forwarding process
-Show ip interface brief- used to show status of router interfaces
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 28
Static Routes and Packet Forwarding
▪ Solving a Missing Route
▪ Finding a missing or mis-configured route requires
methodically using the correct tools
-Start with PING. If ping fails then use traceroute to determine
where packets are failing to arrive
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 29
Static Routes and Packet Forwarding
▪ Solving a Missing Route
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 30
host route
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 31
Create a static host route
▪ In one of the previous lessons we’ve defined a static route for a specific subnet by using the
subnet mask of 255.255.255.0 in the ip route command. IOS also allows you to specify a
static host route for a single host by specifying the 255.255.255.255 (/32) subnet mask in
the ip route command.
▪ Static host routes are usually used when redundant paths exist. Consider the following
example:
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 32
Create a static host route
▪ In the example above you can see that we have a network of three routers and a switch
connected to the 10.0.0.0/24 subnet. R1 has two paths to reach that subnet – one going
through R2, and the other one through R3. Let’s say that we want to use the path going
through R2 for all hosts, except the 10.0.0.10/24 host. For that host, we want to use the
route going through R3. Here is how this can be done:
▪ In the first command we’ve specified R1 to send all packets destined for the 10.0.0.0/24
network to 192.168.0.2 (the IP address of the interface on R2 connected to R1). However,
for packets destined for the 10.0.0.10 host, we’ve instructed R1 to send all packets to
172.16.0.2 (the IP address of the interface on R3).
▪ The two routes specified in the ip routes command above overlap (e.g. the IP address
10.0.0.10 is also included in the first command); however, routers always use a more
specific route with the longer prefix length. Since /32 is a more specific route than /24, R1
will use the route going through R3 to reach 10.0.0.10.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 33
Create a static host route
▪ We can verify that packets are indeed going through desired routes by
using the traceroute command on R1:
▪ NOTE
The hosts also need to be configured with a correct default gateway –
10.0.0.10 needs to have the IP address of R3 configured as its default
gateway, and other hosts on the 10.0.0.0/24 subnet need to have R2
configure as their default gateway.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 34
Floating route
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 35
Floating Static Route
▪ Static routes have a very low administrative distance of 1, this means that your router will
prefer a static route over any routes that were learned through a dynamic routing protocol. If
we want to use a static route as a backup route, we’ll have to change its administrative
distance. This is called a floating static route.
▪ R1 can use R2 or R3 to get to the 192.168.23.0/24 network.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 36
Floating Static Route
▪ R1 should now be able to reach this network through R2:
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 37
Floating Static Route
▪ When we now check our routing table:
▪ There it is, our floating static route is now installed in the routing table. You can
see it shows the AD of 121. If you would un-shut the interface of R2, it will
install the RIP route again.
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 38
Interfaces
▪ Examining Router Interfaces
-Show IP route command – used to view routing table
-Show Interfaces command – used to show status of an
interface
-Show IP Interface brief command – used to show a portion of
the interface information
-Show running-config command – used to show configuration
file in RAM
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 39
Interfaces
▪ Verifying Ethernet interface
-Show interfaces for fastEthernet 0/0 – command used to show
status of fast Ethernet
port
-Show ip interface brief
-Show running-config
▪ Ethernet interfaces participate in ARP
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 40
▪ To configure an Ethernet interface
▪Example:
-R2(config)#interface fastethernet 0/0
-R2(config-if)#ip address 172.16.1.1 255.255.255.0
-R2(config-if)#no shutdown
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 41
Static Routing Problems
▪ Recommended when there is only one path from source to destination
▪ Large Networks
▪ Network Changes
▪ Routing Loops
▪ Routing Loops & TTL (Time To Live)
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 42
ITE PC v4.0
Chapter 1 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 43