Computer Networks Lab
Lab.7 Static Routing & Default Routes
Objectives
1. To understand the concept of static routing
2. To understand the concept of a default route and use it.
3. To apply static routing using Cisco routers.
4. To practice troubleshooting problems with static routing.
Pre-lab Preparation:
1. Read thoroughly and prepare the experiment sheet.
2. Review the Ethernet frame format, the IPv4 packet format and the TCP/UDP segment
formats.
3. You must bring a printed copy of this experiment with you to the lab.
Procedure:
Static Routing:
A router can learn about remote networks in one of two ways:
Manually, from configured static routes
Automatically, from a dynamic routing protocol
Static Routes
Static routes are commonly used when routing from a network to a stub network. A stub network
is a network accessed by a single route. For an example, see the figure below. Here we see that
any network attached to R1 would only have one way to reach other destinations, whether to
networks attached to R2 or to destinations beyond R2. Therefore, network 172.16.3.0 is a stub
network and R1 is a stub router. Running a routing protocol between R1 and R2 is a waste of
resources because R1 has only one way out for sending non-local traffic. Therefore, static routes
are configured for connectivity to remote networks that are not directly connected to a router.
Again, referring to the figure, we would configure a static route on R2 to the LAN attached to R1.
We will also see how to configure a default static route from R1 to R2 later, so that R1 can send
traffic to any destination beyond R2.
Page 1 of 13
The ip route Command
The command for configuring a static route is ip route. The complete syntax for configuring a
static route is:
Router(config)#ip route prefix mask {ip-address | interface-type interface-number [ip-
address]} [distance] [name] [permanent] [tag tag]
Most of these parameters are not relevant for our studies. Therefore, we will use a simpler version
of the syntax:
Router(config)#ip route network-address subnet-mask {ip-address | exit-interface }
The following parameters are used:
network-address - Destination network address of the remote network to be added to the
routing table
subnet-mask - Subnet mask of the remote network to be added to the routing table. The
subnet mask can be modified to summarize a group of networks.
One or both of the following parameters must also be used:
ip-address - Commonly referred to as the next-hop router's IP address
exit-interface - Outgoing interface that would be used in forwarding packets to the
destination network.
Page 2 of 13
Real Life Static Routing Example
Let's say that you are a network administrator and you just added a new segment to your network
and you've successfully added it to your network's routing tables. Suddenly users on that segment
can't get to a network resource such as an email server, or they can't get out to the Internet.
Static routes are a great quick fix. You can use a static route to get the users where they need to
be, which gives you time to find out what the problem is with the dynamic routing protocol.
Static routes are configured with the ip route command, followed by the destination network and
mask. After that, you must specify either the next-hop IP address or the local exit interface. Both
of the following masks are acceptable:
ip route 172.10.1.0 255.255.255.0 210.1.1.1
ip route 172.10.1.0 255.255.255.0 serial 0
Remember, you're specifying either the next-hop router's IP address or the local router's exit
interface!
Default Static Route
It is possible that the destination IP address of a packet will match multiple routes in the routing
table. For example, what if we had the following two static routes in the routing table:
172.16.0.0/24 is subnetted, 2 subnets
S 172.16.1.0 is directly connected, Serial0/0/0 and
S 172.16.0.0/16 is directly connected, Serial0/0/1
Consider a packet with the destination IP address 172.16.1.10. This IP address matches both
routes. The routing table lookup process will use the most-specific match. Because 24 bits match
the 172.16.1.0/24 route, and only 16 bits of the 172.16.0.0/16 route match, the static route with
the 24 bit match will be used. This is the longest match. The packet will then be encapsulated in a
Layer 2 frame and sent via the Serial 0/0/0 interface. Remember, the subnet mask in the route
entry is what determines how many bits must match the packet's destination IP address for this
route to be a match.
Note: This process is the same for all routes in the routing table including static routes, routes
learned from a routing protocol and directly connected networks.
The default Static Route Matches All Packets
A default static route is a route that will match all packets. Default static routes are used:
When no other routes in the routing table match the packet's destination IP address. In
other words, when a more specific match does not exist. A common use is when
connecting a company's edge router to the ISP network.
When a router has only one other router to which it is connected. This condition is known
as a stub router.
Lab Practice 1:
Page 3 of 13
Let’s send the data between 2 PCs across just 2 routers like the following network topology.
Step 1 : Place the routers.
Fist thing first, we need to place the routers on the workspace. We can pick one of them
from Network Devices > Routers > 4331 in bottom panel.
Any type of routers will do, 4331 is just the nearest to our cursor’s current position.
Bottom Panel : Routers
Step 2 : Place the PCs.
PC can be picked from End Deivces > End Devices > PC. Place them on the workspace.
Bottom Panel : PC
Step 3 : Connect all hosts physically, and accordingly.
Page 4 of 13
We can pick one of the physical media from Connections > Connections.
We are going to use ethernet connection, so we pick between Straight Through or Cross-
Over copper cable (choose Straight if unsure).
Bottom Panel : Copper Straight-Through
Next, click on one of the hosts, and choose one of the available ethernet ports. Then click on
the other host while we see the cable being dragged.
Choosing physical port.Repeat the similar steps for connecting a PC and one of the routers.
Step 4 : Configure the PCs.
There is Desktop tab in each PC’s pop-up window. We are going to use IP Configuration and
Command Prompt application here.
Page 5 of 13
PC : Desktop applications
Choose IP Configuration to do IP configurations, and insert the following informations.
For PC0.
IP Address : 192.168.1.2
Netmask : 255.255.255.0
Gateway : 192.168.1.1
Page 6 of 13
For PC1.
IP Address : 192.168.2.2
Netmask : 255.255.255.0
Gateway : 192.168.2.1
PC : IP configuration
Page 7 of 13
Step 5 : Configure the routers.
Click on a router to bring up a pop-up window. Then open CLI tab.
Router : Pop-up window
Page 8 of 13
In Router0 CLI, paste the following script.
En
conf t
int gi0/0/0
ip address 10.10.10.1 255.255.255.248
no shutdown
exit
int gi0/0/1
ip address 192.168.1.1 255.255.255.0
no shutdown
exit
ip route 192.168.2.0 255.255.255.0 10.10.10.2
Page 9 of 13
And the following into Router1.
en
conf t
int gi0/0/0
ip address 10.10.10.2 255.255.255.248
no shutdown
exit
int gi0/0/1
ip address 192.168.2.1 255.255.255.0
no shutdown
exit
ip route 192.168.1.0 255.255.255.0 10.10.10.1
Page 10 of 13
Type “no” for answering the following question beforehand if popping up.
Would you like to enter the initial configuration dialog? [yes/no]:
Step 6 : Ping test between the two PCs.
Let’s open Command Prompt of the two PCs. Here’s the syntax of ping command:
ping <dst-address>
ping 192.168.1.2 from PC0, and ping 192.168.2.2 from PC1.Attach your results.
Page 11 of 13
Task1:
Configuring a Default Static Route
The syntax for a default static route is similar to any other static route, except that the network
address is 0.0.0.0 and the subnet mask is 0.0.0.0:
Router(config)#ip route 0.0.0.0 0.0.0.0 [exit-interface | ip-address ]
The 0.0.0.0 0.0.0.0 network address and mask is called a "quad-zero" route.
Referring to the figure above, R1 is a stub router. It is only connected to R2. Currently R1 has
three static routes, which are used to reach all of the remote networks in our topology. All three
static routes have the exit interface Serial 0/0/0, forwarding packets to the next-hop router R2.
The three static routes on R1 are:
ip route 172.16.1.0 255.255.255.0 serial 0/0/0
ip route 192.168.1.0 255.255.255.0 serial 0/0/0
Page 12 of 13
ip route 192.168.2.0 255.255.255.0 serial 0/0/0
R1 is an ideal candidate to have all of its static routes replaced by a single default route. First,
delete the three static routes:
R1(config)#no ip route 172.16.1.0 255.255.255.0 serial 0/0/0
R1(config)#no ip route 192.168.1.0 255.255.255.0 serial 0/0/0
R1(config)#no ip route 192.168.2.0 255.255.255.0 serial 0/0/0
Next, configure the single default static route using the same Serial 0/0/0 exit interface as the
three previous static routes:
R1(config)#ip route 0.0.0.0 0.0.0.0 serial 0/0/0
Page 13 of 13