Static Routing in CISCO Routers and Switch

Following example will describes the IP Routing

Lab_A configuration 
// here i'm using WIC-2T slot for establishing serial connection between two routers.

Router>en
Router#config t
Router(config)#hostname Lab_A
Lab_A(config)#enable secret todd
Lab_A(config)#interface fa0/0
Lab_A(config-if)#ip address 192.168.10.1 255.255.255.0
Lab_A(config-if)#description Lab_A LAN Connection
Lab_A(config-if)#no shut
Lab_A(config-if)#interface serial 0/0
Lab_A(config-if)#ip address 192.168.20.1 255.255.255.0
Lab_A(config-if)#description WAN Connection to Lab_B
Lab_A(config-if)#no shut
Lab_A(config-if)#exit
Lab_A(config)#line console 0
Lab_A(config-line)#password todd
Lab_A(config-line)#login
Lab_A(config-line)#line aux 0
Lab_A(config-line)#password todd
Lab_A(config-line)#login
Lab_A(config-line)#line vty 0 4
Lab_A(config-line)#password todd
Lab_A(config-line)#login
Lab_A(config-line)#exit
Lab_A(config)#banner motd #
This is the Lab_A router
#
Lab_A(config)#^z
Lab_A#copy running-config startup-config
Destination filename [startup-config]? [Enter]
Lab_A#

-----------------------
let check the IP route of Lab_A
Lab_A#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 NSS 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, P -
periodic downloaded static route, T - traffic
engineered route
Gateway of last resort is not set
C 192.168.10.0/24 is directly connected, FastEthernet0/0
C 192.168.20.0/24 is directly connected, Serial 0/0
-------------------------------------------------------------
Lab_B configuration
Router>en
Router#config t
Router(config)#hostname Lab_B
Lab_B(config)#enable secret todd
Lab_B(config)#interface fa0/0
Lab_B(config-if)#ip address 192.168.30.1 255.255.255.0
Lab_B(config-if)#description Lab_B LAN Connection
Lab_B(config-if)#no shut
Lab_B(config-if)#interface serial 0/0
Lab_B(config-if)#ip address 192.168.20.2 255.255.255.0
Lab_B(config-if)#description WAN Connection to Lab_A
Lab_B(config-if)#clock rate 64000
Lab_B(config-if)#no shut
Lab_B(config-if)#interface serial 0/1
Lab_B(config-if)#ip address 192.168.40.1 255.255.255.0
Lab_B(config-if)#description WAN Connection to Lab_C
Lab_B(config-if)#clock rate 64000
Lab_B(config-if)#no shut
Lab_B(config-if)#exit
Lab_B(config)#line console 0
Lab_B(config-line)#password todd
Lab_B(config-line)#login
Lab_B(config-line)#line aux 0
Lab_B(config-line)#password todd
Lab_B(config-line)#login
Lab_B(config-line)#line vty 0 4
Lab_B(config-line)#password todd
Lab_B(config-line)#login
Lab_B(config-line)#exit
Lab_B(config)#banner motd #
This is the Lab_B router
#
Lab_B(config)#^z
Lab_B#copy running-config startup-config
Destination filename [startup-config]? [Enter]
Lab_B#

Lab_B#sh ip route
[output cut]
Gateway of last resort is not set
C 192.168.20.0/24 is directly connected, Serial0/0
C 192.168.40.0/24 is directly connected, Serial0/1
C 192.168.30.0 is directly connected FastEthernet 0/0
---------------------------------------------------------------------------
Lab_C configuration
Router>en
Router#config t
Router(config)#hostname Lab_C
Lab_C(config)#enable secret todd
Lab_C(config)#interface fa0/0
Lab_C(config-if)#ip address 192.168.50.1 255.255.255.0
Lab_C(config-if)#description Lab_C LAN Connection
Lab_C(config-if)#no shut
Lab_C(config-if)#interface serial 0/0
Lab_C(config-if)#ip address 192.168.40.2 255.255.255.0
Lab_C(config-if)#description WAN Connection to Lab_B
Lab_C(config-if)#no shut
Lab_C(config-if)#exit
Lab_C(config)#line console 0
Lab_C(config-line)#password todd
Lab_C(config-line)#login
Lab_C(config-line)#line aux 0
Lab_C(config-line)#password todd
Lab_C(config-line)#login
Lab_C(config-line)#line vty 0 4
Lab_C(config-line)#password todd
Lab_C(config-line)#login
Lab_C(config-line)#exit
Lab_C(config)#banner motd #
This is the Lab_C router
#
Lab_C(config)# ^z
Lab_C#copy running-config startup-config
Destination filename [startup-config]? [Enter]
Lab_C#


Lab_C#sh ip route
[output cut]
Gateway of last resort is not set
C 192.168.50.0/24 is directly connected, FastEthernet0/0
C 192.168.40.0/24 is directly connected, Serial0/0
------------------------------------------------------------------------

Static Routing
Static routing occurs when you manually add routes in each router’s routing table. There are
pros and cons to static routing, but that’s true for all routing processes.
Static routing has the following benefits:
There is no overhead on the router CPU, which means you could possibly buy a cheaper
router than if you were using dynamic routing.
There is no bandwidth usage between routers, which means you could possibly save money
on WAN links.
It adds security, because the administrator can choose to allow routing access to certain networks
only.
Static routing has the following disadvantages:
The administrator must really understand the internetwork and how each router is connected
in order to configure routes correctly.
If a network is added to the internetwork, the administrator has to add a route to it on all
routers—by hand.
It’s not feasible in large networks because maintaining it would be a full-time job in itself.
Okay—that said, here’s the command syntax you use to add a static route to a routing table:
ip route [destination_network] [mask] [next-hop_address or exitinterface]
[administrative_distance] [permanent]
This list describes each command in the string:
ip route The command used to create the static route.
destination_network The network you’re placing in the routing table.
mask The subnet mask being used on the network.
next-hop_address The address of the next-hop router that will receive the packet and forward
it to the remote network. This is a router interface that’s on a directly connected network.
You must be able to ping the router interface before you add the route. If you type in the wrong
next-hop address, or the interface to that router is down, the static route will show up in the
router’s configuration, but not in the routing table.
exitinterface You can use it in place of the next-hop address if you want, but it’s got
to be on a point-to-point link, such as a WAN. This command won’t work on a LAN such
as Ethernet.
administrative_distance By default, static routes have an administrative distance of 1 (or
even 0 if you use an exit interface instead of a next-hop address). You can change the default
value by adding an administrative weight at the end of the command. I’ll talk a lot more about
this subject later in the chapter when we get to the section on dynamic routing.
permanent If the interface is shut down, or the router can’t communicate to the next-hop
router, the route will automatically be discarded from the routing table. Choosing the permanent
option keeps the entry in the routing table no matter what happens.
Before we dive into configuring static routes, let’s take a look at a sample static route and see
what we can find out about it.
Router(config)#ip route 172.16.3.0 255.255.255.0 192.168.2.4
The ip route command tells us simply that it is a static route.
172.16.3.0 is the remote network we want to send packets to.
255.255.255.0 is the mask of the remote network.
192.168.2.4 is the next hop, or router, we will send packets to.
However, if the static route looked like this:
Router(config)#ip route 172.16.3.0 255.255.255.0 192.168.2.4 150
the 150 at the end changes the default administrative distance (AD) of 1 to 150. No worries—
I’ll talk much more about AD when we get into dynamic routing. For now, just remember that
the AD is the trustworthiness of a route, where 0 is best and 255 is worst.
To help you understand how static routes work, I’ll demonstrate the configuration on the
internetwork shown previously in Figure 5.6.
Lab_A
Each routing table automatically includes directly connected networks. To be able to route to
all networks in the internetwork, the routing table must include information that describes
where these other networks are located and how to get there.
The Lab_A router is connected to networks 192.168.10.0 and 192.168.20.0. For the Lab_
A router to be able to route to all networks, the following networks have to be configured in its
routing table:
192.168.30.0
192.168.40.0
192.168.50.0
The following router output shows the configuration of static routes on the Lab_A router
and the routing table after the configuration. For the Lab_A router to find the remote networks,
an entry is placed in the routing table describing the network, the mask, and where to send the
packets. Notice that each static route sends the packets to 192.168.20.2, which is the Lab_A
router’s next hop.
Lab_A(config)#ip route 192.168.30.0 255.255.255.0
192.168.20.2
Lab_A(config)#ip route 192.168.40.0 255.255.255.0
192.168.20.2
Lab_A(config)#ip route 192.168.50.0 255.255.255.0
192.168.20.2
After the router is configured, you can type show running-config and show ip route to
see the static routes:
Lab_A#sh ip route
[output cut]
S 192.168.50.0 [1/0] via 192.168.20.2
S 192.168.40.0 [1/0] via 192.168.20.2
S 192.168.30.0 [1/0] via 192.168.20.2
C 192.168.20.0 is directly connected, Serial 0/0
C 192.168.10.0 is directly connected, FastEthernet0/0
Lab_A#
Remember that if the routes don’t appear in the routing table, it’s because the router cannot
communicate with the next-hop address you configured. You can use the permanent parameter
to keep the route in the routing table even if the next-hop device can’t be contacted.
The S in the routing table entries above means that the network is a static entry. The [1/0]
is the administrative distance and metric, which I’ll discuss below, to the remote network. Here
the next-hop interface is 0, indicating that it’s directly connected.
The Lab_A router now has all the information it needs to communicate with the other
remote networks. However, if the Lab_B and Lab_C routers are not configured with all the
same information, the packets will be discarded at Lab_B and at Lab_C. We need to fix this with
static routes.
Lab_B
The Lab_B router is connected to the networks 192.168.20.0, 192.168.30.0, and 192.168.40.0.
The following static routes must be configured on the Lab_B router:
192.168.10.0
192.168.50.0
Here’s the configuration for the Lab_B router:
Lab_B(config)#ip route 192.168.10.0 255.255.255.0
192.168.20.1
Lab_B(config)#ip route 192.168.50.0 255.255.255.0
192.168.40.2
By looking at the routing table, you can see that the Lab_B router now understands how to
find each network:
Lab_B#sh ip route
[output cut]
S 192.168.50.0 [1/0] via 192.168.40.2
C 192.168.40.0 is directly connected, Serial0/1
C 192.168.30.0 is directly connected, FastEthernet 0/0
C 192.168.20.0 is directly connected, Serial0/0
S 192.168.10.0 [1/0] via 192.168.20.1
Lab_B#
The Lab_B router now has a complete routing table. As soon as the other routers in the internetwork
have all the networks in their routing table, Lab_B can communicate to all remote networks.
Lab_C
The Lab_C router is directly connected to networks 192.168.40.0 and 192.168.50.0. Three
routes need to be added:
192.168.30.0
192.168.20.0
192.168.10.0
Here’s the configuration for the Lab_C router:
Lab_C(config)#ip route 192.168.30.0 255.255.255.0
192.168.40.1
Lab_C(config)#ip route 192.168.20.0 255.255.255.0
192.16.40.1
Lab_C(config)#ip route 192.168.10.0 255.255.255.0
192.168.40.1
The following output shows the routing table on the Lab_C router:
Lab_C#sh ip route
[output cut]
C 192.168.50.0 is directly connected, FastEthernet0/0
C 192.168.40.0 is directly connected, Serial0/0
S 192.168.30.0 [1/0] via 192.168.40.1
S 192.168.20.0 [1/0] via 192.168.40.1
S 192.168.10.0 [1/0] via 192.168.40.1
Lab_C#
Lab_C now shows all the networks in the internetwork and can communicate with all routers
and networks. All the routers have the correct routing table, and all the routers and hosts should
be able to communicate without a problem—for now. But if you add even one more network or
another router to the internetwork, you’ll have to update all routers’ routing tables by hand. As
I said, this isn’t a problem at all if you’ve got a small network, but it’s way too time-consuming a
task if you’re dealing with a large internetwork.
Verifying Your Configuration
Once all the routers’ routing tables are configured, they need to be verified. The best way to do
this, besides using the show ip route command, is with the Ping program. By pinging from
routers Lab_A and Lab_C, the whole internetwork will be tested end-to-end.

Post a Comment

0 Comments