Configuring Routing–Cisco Configuring a Network
Whenever there is a reachability problem, the best place to start looking for the problem is the routing table, which you can see by using show ip route. Figure 23-8 illustrates the parts of show ip route’s output.
Figure 23-8 The Routing Table
The show ip route command displays the router’s routing table, including which destinations the router knows how to reach and other information about each reachable destination.
The top of the show ip route command’s output is a list of the sources where the routing table might learn a route. Most of these are routing protocols, but two are locally learned:
• C means this route is connected or a destination directly connected to a physical or virtual interface on this device.
• S means the network administrator statically configures this route.
The following section shows the gateway of last resort, also known as the default gateway. The default gateway is where the router will send packets if it has no other routing table entry for the packet’s destination address.
Finally, each route is listed on a separate line. This line includes information about
• Where the router forwards traffic; in this case, it is directly connected.
• How long this route has been in the local routing table.
• What interface the router sends packets to; in this case, it is the three connected interfaces configured earlier in this chapter.
Notice there is a route to 192.0.2.32, which contains 192.0.2.34, so the router knows where to send packets when you ping the address. There is not, however, any routing table entry for 192.0.2.92, which is the network containing 192.0.2.94. When you ping 192.0.2.94, the router has no information about where to send the packets, so the ping fails.
We need to tell router F about 192.0.2.92 somehow. The easiest way is to configure a static route telling router F about 192.0.2.92, including where to send packets to destinations contained in this network. Example 23-6 demonstrates the commands used to configure a static route on router F.
Example 23-6 Configuring a Static Route router-f# config terminal router-f (config)# ip route 192.0.2.92 255.255.2 router-f (config)# exit
The ip route command creates a static route that will be inserted in the local routing table and forwards packets to the indicated destination.
Pinging from router F to 192.0.2.93 now works, as Example 23-7 shows.
Example 23-7 ping Command Output router-f# ping 192.0.2.93
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.0.2.93, ti
!!!!!
Success rate is 100 percent (5/5)
The static route now shows up in router F’s routing table, as
Example 23-8 Confirming a Static Route router-f# show ip route
Gateway of last resort is not set
C 192.0.2.16 is directly connected, 0:01:00,
C 192.0.2.32 is directly connected, 0:01:00,
C 192.0.2.128 is directly connected, 0:01:00,
S 192.0.2.92 [1/0] via 192.0.2.34, 0:01:00, F
Sourcing the ping from router F interface fe2, however, causes the ping to fail once more, as Example 23-9 shows.
Example 23-9 ping Command Output router-f# ping
Protocol [ip]:
Target IP address: 192.0.2.93
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 192.0.2.17
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.0.2.93, ti
Success rate is 0 percent (0/5)
What could the problem be? Looking at router D’s routing table in Example 23-10 reveals some clues.
Example 23-10 Using show ip route to Determine Possible Causes of a Problem router-d# show ip route
Gateway of last resort is not set
C 192.0.2.32 is directly connected, 0:01:00,
C 192.0.2.48 is directly connected, 0:01:00,
C 192.0.2.64 is directly connected, 0:01:00,
C 192.0.2.92 is directly connected, 0:01:00,
Router D does not have a route to 192.0.2.16, which contains 192.0.2.17, the source of the ping packets. You can resolve this once again by creating a static route at router D, as demonstrated in Example 23-11.
Example 23-11 Configuring a Static Route router-d# config terminal router-d (config)# ip route 192.0.2.16 255.255.2 router-d (config)# exit
To make every host reachable from every other host, you must configure static routes for every network on every router. There is an easier way, however—running a routing protocol. Detailed routing protocol operation is outside the scope of this book, but configuring the Open Shortest Path First (OSPF) protocol takes a few configuration commands, as demonstrated in Example 23- 12.
Example 23-12 Configuring OSPF
router-f (config)# router ospf 1
router-f (config-router)# network 192.0.2.16 0.0
router-f (config-router)# network 192.0.2.32 0.0
router-f (config-router)# exit
router-f (config)# exit
router-f#
Insert 2 pt rule hererouter-d (config)# route
router-d (config-router)# network 192.0.2.92 0.0
router-d (config-router)# network 192.0.2.64 0.0
router-d (config-router)# network 192.0.2.48 0.0
router-d (config-router)# network 192.0.2.32 0.0
router-d (config-router)# exit
router-d (config)# exit
router-d#
router-e (config)# router ospf 1
router-e (config-router)# network 192.0.2.16 0.0
router-e (config-router)# network 192.0.2.48 0.0
router-e (config-router)# network 192.0.2.0 0.0.
router-e (config-router)# exit
router-e (config)# exit
In this set of commands:
• router ospf 1 starts OSPF process 1. You can run multiple OSPF processes on a router, each routing for different interfaces; the process number allows you to differentiate between the processes.
• network <ip address> <inverse mask> enables OSPF on any interface with an IP address covered by the network statement.
For instance, 192.0.2.1 is in the 192.0.2.0/28 network, which can also be written as 192.0.2.0 255.255.240. Inverting the last digit in the network mask gives us .15 rather than .240.
Note
OSPF areas are outside the scope of this book.
Example 23-13 shows what the routing table on router F now contains.
Example 23-13 Displaying a Routing Table
Gateway of last resort is not set
C 192.0.2.16 is directly connected, 0:01:00,
C 192.0.2.32 is directly connected, 0:01:00,
C 192.0.2.128 is directly connected, 0:01:00,
O 192.0.2.92 [110/20] via 192.0.2.34, 0:01:00,
O 192.0.2.64 [110/20] via 192.0.2.34, 0:01:00,
O 192.0.2.0 [110/20] via 192.0.2.18, 0:01:00, F
OSPF learned every reachable destination and advertised it throughout the network so the other routers could calculate paths to them.
One last routing problem to solve is reaching networks in the Organization network. Solving this problem is especially difficult because the networks reachable within Organization are not given.
The default route is designed to solve this problem. Begin by configuring a static default route on router F, as demonstrated
Example 23-14 Configuring a Static Default Route
router-f# config terminal
router-f (config)# ip route 0.0.0.0 0.0.0.0 192.0.2.12
router-f (config)# exit
The 0.0.0.0/0 route is a special route called the default. Routers send any packets they do not know how to forward to this special route. Remember, Organization indicated 192.0.2.129 was its router’s address. As Example 23-15 shows, router F’s routing table shows this new route; the default gateway is now set.
Example 23-15 show ip route with a Default Route router-f# show ip route
Gateway of last resort is 192.0.2.129 to network
C 192.0.2.16 is directly connected, 0:01:00,
C 192.0.2.32 is directly connected, 0:01:00,
C 192.0.2.128 is directly connected, 0:01:00,
O 192.0.2.92 [110/20] via 192.0.2.34, 0:01:00,
O 192.0.2.64 [110/20] via 192.0.2.34, 0:01:00,
O 192.0.2.0 [110/20] via 192.0.2.18, 0:01:00, F
S 0.0.0.0 [1/1] via 192.0.2.129, 0:01:00, Fas
Configuring a static default route works for router F, but what about routers E and D? You can configure a static default in each router, or you can configure OSPF to advertise this default route to routers E and D, as demonstrated in Example 23-16.
Example 23-16 Advertising a Default Route Using OSPF
router-f (config)# router ospf 1
router-f (config-router)# default-information or
always Always advertise default route
metric OSPF default metric
metric-type OSPF metric type for default rout
route-map Route-map reference
The question mark (?) at the end of the command means “Tell me what options are available here.” The ? is one of the most valuable additions to the Cisco IOS Software CLI. If you cannot remember a command, put a ? at the end of what you can remember and let the router help you.
None of these options are essential for this example, so use the default-information originate command by itself as demonstrated in Example 23-17.
Example 23-17 Advertising a Default Route Using OSPF
router-f (config)# router ospf 1
router-f (config-router)# default-information or
Router E’s routing table now has a default route, as Example 23-
Example 23-18 show ip route with Default Route router-e# show ip route
Gateway of last resort is 192.0.2.17 to network
C 192.0.2.0 is directly connected, 0:01:00, F
C 192.0.2.16 is directly connected, 0:01:00,
C 192.0.2.48 is directly connected, 0:01:00,
O 192.0.2.92 [110/20] via 192.0.2.49, 0:01:00,
O 192.0.2.64 [110/20] via 192.0.2.49, 0:01:00,
O 192.0.2.32 [110/20] via 192.0.2.17, 0:01:00,
O*E2 0.0.0.0 [110/20] via 192.0.2.17, 0:01:00, F
Note
Advertising the routes within this network to the routers in the Organization is outside the scope of this book. You would normally use a routing
protocol, like OSPF, to advertise the routes.