Configuring static and default routing
Configuring static and
default routing
In the article, "IP
routing in 40 short steps," we described how a packet is sent from an
originating host on one network over to another host on a different network
through an internetwork, as well as exactly what happens to those packets
during that process. This article is going to take things a step further and
focus on both IP routing and how routers use a routing table to accomplish
the task of forwarding those packets properly throughout an internetwork.
There are three different ways a routing table is built:
- Statically
- By default
- Dynamically
I'm going to talk about the first two-static and default routing tables that
are built by network administrators.
A little review
But first, a little review...Remember that an internetwork is defined as
two or more networks connected with a router or routers. Also recall that
routers don't keep track of, or care even the slightest bit about, hosts,
but they are extremely concerned about networks and the best path to access
each one.
Logical addressing (IP, for example) is what's used to identify each host on
the internetwork. Routers read the network portion of an IP address to
figure out where in the Net world a host is and then use a routing table to
determine the best path to the network that the destination host is located
on.
Once that network is located, the packet is sent to the destination network
by forwarding the packet, hop-to-hop, until it reaches the specific router
that's directly connected to the destination host's network. From there, the
destination host's unique hardware address is used to get the packet to the
host that's supposed to receive it.
It's all about maps
Routers have maps, or at least a form of them. They must have a map of
the entire internetwork to explain to them where each logical network is
located, as well as to guide their decision in choosing the quickest, most
efficient way to get there. This map is called a routing table, and each
routed protocol you use has to have its own map. For instance, if you're
running IP, IPX, and AppleTalk on your network, each of your routers will
have three maps-one for each routing protocol-all describing the same
physical networks in a different way.
It's kind of a language barrier thing; the reason each protocol has separate
routing tables is because each protocol really is like a different language.
Say you've built a gated community, and in it, you have a street you named
Cat Street. Everyone on that block speaks English, and the street sign is in
English. Then a Spanish family moves in that doesn't speak any English, so
you add a sign that reads Avenida Gato. Next, a French family moves in-they
don't speak English or Spanish-so you add Le Chat to the sign. You now have
three separate signs describing Cat Street in three different ways.
Take a look at Figure A, which has two 2500 routers connected with a
serial link.
Figure A |
|
Each router must have all three networks in
the routing table in order to send packets through the
internetwork. |
By default, each router will have the directly
connected networks in its routing table. Before we take a look at the
routing tables, let's view the configuration used on each router.
Here's the basic configuration for the 2500A
router. |
Basic configuration for 2500A router |
|
|
Router>
Router>en
Router#config t
Enter configuration commands, one per
line. End with CNTL/Z.
Router(config)#hostname 2500A
2500A(config)#interface ethernet0
2500A(config-if)#ip address 192.168.10.33
255.255.255.224
2500A(config-if)#no shut
2500A(config-if)#int serial0
2500A(config-if)#
00:16:04: %LINK-3-UPDOWN: Interface
Ethernet0, changed state to up
00:16:05: %LINEPROTO-5-UPDOWN: Line
protocol on Interface Ethernet0, changed sta
te to up
2500A(config-if)#ip address 192.168.10.65
255.255.255.224
2500A(config-if)#no shut
2500A(config-if)#
00:16:28: %LINK-3-UPDOWN: Interface
Serial0, changed state to up
00:16:29: %LINEPROTO-5-UPDOWN: Line
protocol on Interface Serial0, changed state
to up
2500A(config-if)# ^Z
2500A#
|
|
Here's the basic configuration for the 2500B
router. |
Basic configuration for 2500B router |
|
|
Router>en
Router#config t
Enter configuration commands, one per
line. End with CNTL/Z.
Router(config)#hostname 2500B
2500B(config)#interface ethernet0
2500B(config-if)#ip address 192.168.10.97
255.255.255.224
2500B(config-if)#no shut
2500B(config-if)#interface serial0
2500B(config-if)#
00:19:27: %LINK-3-UPDOWN: Interface
Ethernet0, changed state to up
00:19:28: %LINEPROTO-5-UPDOWN: Line
protocol on Interface Ethernet0, changed sta
te to up
2500B(config-if)#ip address 192.168.10.66
255.255.255.224
2500B(config-if)#clock rate 1000000
2500B(config-if)#no shut
2500B(config-if)#^Z
2500B#
00:19:47: %SYS-5-CONFIG_I: Configured
from console by console
00:19:48: %LINK-3-UPDOWN: Interface
Serial0, changed state to up
00:19:49: %LINEPROTO-5-UPDOWN: Line
protocol on Interface Serial0, changed state
to up
2500B# |
|
The 2500B router had the DCE end of the serial link, so
the clock rate command needed to be added. We should now have two networks
in each routing table. Let's view each table with the show ip route command
(or the short form: sh ip route).
Here's the 2500A router.
|
Viewing the 2500A routing table with
the show ip route command |
|
|
2500A#sh ip route
Codes: C - connected, S - static, I -
IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O
- OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2
- OSPF NSSA external type 2
E1 - OSPF external type 1, E2 -
OSPF external type 2, E - EGP
i - IS-IS, L2500A#sh ip route
Codes: C - connected, S - static, I -
IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O
- OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2
- OSPF NSSA external type 2
E1 - OSPF external type 1, E2 -
OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2
- IS-IS level-2, * - candidate default
U - per-user static route, o - ODR
Gateway of last resort is not set
192.168.10.0/27 is subnetted, 2
subnets
C 192.168.10.64 is directly
connected, Serial0
C 192.168.10.32 is directly
connected, Ethernet0
2500A#
1 - IS-IS level-1, L2 - IS-IS level-2, *
- candidate default
U - per-user static route, o - ODR
Gateway of last resort is not set
192.168.10.0/27 is subnetted, 2
subnets
C 192.168.10.64 is directly
connected, Serial0
C 192.168.10.32 is directly
connected, Ethernet0
2500A# |
|
And here's the 2500B router. |
Viewing the 2500B routing table with
the show ip route command |
|
|
2500B#sh ip route
Codes: C - connected, S - static, I -
IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O
- OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2
- OSPF NSSA external type 2
E1 - OSPF external type 1, E2 -
OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2
- IS-IS level-2, * - candidate default
U - per-user static route, o - ODR
Gateway of last resort is not set
192.168.10.0/27 is subnetted, 2
subnets
C 192.168.10.96 is directly
connected, Ethernet0
C 192.168.10.64 is directly
connected, Serial0
2500B# |
|
The 2500A router is directly connected to subnets 32
and 64. The 2500A must have a route entered for the 96 subnet. The 2500B
router is directly connected to the 64 and 96 subnets. The 2500B router must
have an entry for the 32 subnet.
Configuring static routes
Static routes are routes configured and entered into the routing table
by the administrator. Typically, in larger networks, creating nothing but
static routes would be a gruesome task (if not impossible), so dynamic
routing is usually used (examples are RIP and OSPF). However, in smaller
networks, static routing can work well; it saves overhead on the router CPU
and bandwidth on the serial links that dynamic routing protocols greedily
consume as fast as my golden retriever will steal and swallow an unattended
turkey sandwich!
To configure a static route, use the global configuration command ip route.
Since the 2500A router must understand how to get to the 96 subnet, let's
configure a static route that describes to the router what to do when it
receives a packet with a destination IP network of 192.168.10.96.
Configuring a static route with the ip
route command |
|
|
2500A#config t
Enter configuration commands, one per
line. End with CNTL/Z.
2500A(config)#ip route 192.168.10.96
255.255.255.224 192.168.10.66
2500A(config)#^Z
2500A#
00:31:11: %SYS-5-CONFIG_I: Configured
from console by console
2500A#sh ip route
Codes: C - connected, S - static, I -
IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O
- OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2
- OSPF NSSA external type 2
E1 - OSPF external type 1, E2 -
OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2
- IS-IS level-2, * - candidate default
U - per-user static route, o - ODR
Gateway of last resort is not set
192.168.10.0/27 is subnetted, 3
subnets
S 192.168.10.96 [1/0] via
192.168.10.66
C 192.168.10.64 is directly
connected, Serial0
C 192.168.10.32 is directly
connected, Ethernet0
2500A# |
|
The ip route command is broken down as follows:
- ip route: The command issued to add a route to a
routing table
- 192.168.10.96: The destination network
- 255.255.255.224: The subnet mask used on the
network
- 192.168.10.66: Where to send a packet with a
destination IP network of 192.168.10.96
Notice that the IP routing table now has an entry for the 192.168.10.96
subnet via 192.168.10.66, which is the next hop gateway from the 2500A
router.
This is working great; we're halfway to finishing our
routing tables. The reason we're only half done is that the 2500B router
still doesn't know how to send packets to the 32 subnet. If a packet is sent
from HostA on the 32 subnet over to HostB on the 96 subnet, it'll definitely
get to HostB, and HostB will respond by sending a new packet back to the
configured default gateway. The problem is that 2500B will discard the
packet since it doesn't know how to get to the 32 subnet. So, let's
configure 2500B with a route to network 192.168.10.32.
2500B configured with a route to
192.168.10.32 |
|
|
2500B>en
2500B#config t
Enter configuration commands, one per
line. End with CNTL/Z.
2500B(config)#ip route 192.168.10.32
255.255.255.224 192.168.10.65
2500B(config)#^Z
2500B#
00:46:42: %SYS-5-CONFIG_I: Configured
from console by console
2500B#sh ip route
Codes: C - connected, S - static, I -
IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O
- OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2
- OSPF NSSA external type 2
E1 - OSPF external type 1, E2 -
OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2
- IS-IS level-2, * - candidate default
U - per-user static route, o - ODR
Gateway of last resort is not set
192.168.10.0/27 is subnetted, 3
subnets
C 192.168.10.96 is directly
connected, Ethernet0
C 192.168.10.64 is directly
connected, Serial0
S 192.168.10.32 [1/0] via
192.168.10.65
2500B# |
|
The ip route command is broken down as follows:
- ip route: The command used to add a static route
- 192.168.10.32: The destination route we want
router 2500B to know about
- 255.255.255.224: The mask used in the network
- 192.168.10.65: The next hop router used to get to
subnet 32
The routing table for the 2500B router now knows how to get to subnet 32 and
packets can be sent from HostA to HostB and back again.
Configuring default routing
Since we have an Internet connection off the 2500B serial 0 interface, we
need to add a default route to the routing table of the 2500B router. This
is just like adding a static route, except wildcards of all zeros (0s) are
used instead of a network and mask.
Here is an example of configuring the serial 1 interface on the 2500B router
and then setting up default route. The ISP provided an IP address of
200.43.89.65/30 for the interface. Since /30 is a block size of 4, the valid
hosts are 65 and 66. We can set our next hop to 66 since we were given 65
for our router’s interface.
Configuring the serial 1 interface |
|
|
2500B#config t
Enter configuration commands, one per
line. End with CNTL/Z.
2500B(config)#int s1
2500B(config-if)#ip address 200.43.89.65
255.255.255.252
2500B(config-if)#no shut
2500B(config-if)#
00:53:31: %LINK-3-UPDOWN: Interface
Serial1, changed state to down
2500B(config-if)#exit
2500B(config)#ip route 0.0.0.0 0.0.0.0
200.43.89.66
2500B(config)#ip classless
2500B(config)#^Z
2500B#
00:53:58: %SYS-5-CONFIG_I: Configured
from console by console
2500B# |
|
The default route command is broken down as follows:
- ip route: The command used to add a static or
default route
- 0.0.0.0: The wildcard used to say “any" network
not already in the routing table
- 0.0.0.0: Wildcard mask to say “any" network mask
- 200.43.89.66: Next hop gateway
If you don't know the next hop gateway for some reason, you can always
create the command like this:
ip route 0.0.0.0 0.0.0.0 s1
This will tell the router to send packets that aren't in the routing table
out serial 1. Also, notice that I used the ip classless command. This tells
the route not to drop packets that are destined for a network that's not in
the routing table, but to use the default route instead. If you don't use
the ip classless command, packets like that would be dropped before being
sent to the default route. (ip classless is on by default in IOS 12.x.)
Okay, so the routing table on the 2500B router
now looks like this. |
The 2500B routing table |
|
|
2500B#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route, o - ODR
Gateway of last resort is 200.43.89.66 to network 0.0.0.0
192.168.10.0/27 is subnetted, 3 subnets
C 192.168.10.96 is directly connected, Ethernet0
C 192.168.10.64 is directly connected, Serial0
S 192.168.10.32 [1/0] via 192.168.10.65
200.43.89.0/30 is subnetted, 1 subnets
C 200.43.89.64 is directly connected, Serial1
S* 0.0.0.0/0 [1/0] via 200.43.89.66
2500B#
|
|
The S* is a static default route. Notice also that the
gateway of last resort is now set as well. Since a router cannot set a
default gateway and since it actually is the default gateway for a network,
routers use a gateway of last resort instead, which is really a default
route.
A couple of tips
- Routers need current, up-to-date "maps." If a
routing table doesn't have a route to each network that it's going to be
required to send packets to, then packets will be dropped.
- Troubleshooting a routing table problem is tough.
But by using the ping program and Traceroute command, you can find
exactly where a packet is failing in an internetwork. Each of these
commands will be discussed in future articles.
Conclusion
By now it should be pretty clear both why it's important to understand how a
routing table is used in an internetwork and how important it is to be able
to read a routing table and understand the output. There are many tools that
can help you understand this concept, but the best tool is experience. Use
the tools I've shown you, and eventually, you'll be whipping up routing
tables faster than you can say "cat" in three different languages.
|