Monday 7 October 2019

How to configure the Static Routing on Cisco Router

How to configure the Static Routing on Cisco Router

In this article we learn the basic routing that is How to configure the Static Routing on Cisco Router. Static routes are configured with the ip route global configuration command. The basic syntax of the command is shown below:
Router (config) # ip route network-address subnet-mask {ip-address | exit-intf}

Syntax of the ip route command.
ParameterDescription
network-addressAddress of the destination network of the remote network that will be added to the routing table
subnet-mask
  • Subnet mask of the remote network that will be added to the routing table.
  • It can be modified to summarize a group of networks.
ip-address
  • Called the IP address of the router of the next hop.
  • Usually used for connection to a broadcast medium (ethernet) and usually create a recursive search.
exit-intf
  • Named static route directly connected.
  • Use the outbound interface to forward packets to the destination network.
  • It is usually used to connect in a point-to-point configuration.
If you want to learn about IPv6 static routing configuration on cisco you can visit here.
The following parameters are required to configure static routing:
  • Network address: destination network address of the remote network that is added to the routing table, also called “prefix”.
  • subnet mask: subnet mask, or simply mask, of the remote network that is added to the routing table. The subnet mask can be modified to summarize a group of networks.

In addition, one of the following parameters or both must be used:

  • ip-address : IP address of the connection router to be used to forward the packet to the remote destination network. It is usually called "next jump."
  • exit-intf : exit interface to be used to forward the packet to the next hop.

 Static Routing on Cisco Router

Let's look at an example: Note in the code below that each router has inputs only for directly connected networks and their associated local addresses. None of the routers have knowledge of the networks that are outside the directly connected interfaces.
 Static Routing on Cisco Router

R1 router routing table:
R1 # show ip route | begin gateway
Gateway of last resort is not set
   172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
 C 172.16.2.0/24 is directly connected, Serial0 / 0/0
 L 172.16.2.1/32 is directly connected, Serial0 / 0/0
 C 172.16.3.0/24 is directly connected, GigabitEthernet0 / 0
 L 172.16.3.1/32 is directly connected, GigabitEthernet0 / 0
R1 #
Router table of router R2:
R2 # show ip route | begin gateway
Gateway of last resort is not set
 172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
 C 172.16.1.0/24 is directly connected, GigabitEthernet0 / 0
 L 172.16.1.1/32 is directly connected, GigabitEthernet0 / 0
 C 172.16.2.0/24 is directly connected, Serial0 / 0/0
 L 172.16.2.2/32 is directly connected, Serial0 / 0/0
 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
 C 192.168.1.0/24 is directly connected, Serial0 / 0/1
 L 192.168.1.2/32 is directly connected, Serial0 / 0/1
R2 #
R3 router routing table:
R3 # show ip route | include C
 Codes: L - local, C - connected, S - static, R - RIP, M - mobile,
B - BGP
 C 192.168.1.0/24 is directly connected, Serial0 / 0/1
 C 192.168.2.0/24 is directly connected, GigabitEthernet0 / 0
R3 #
For example, R1 has no knowledge of networks:
172.16.1.0/24: LAN on R2
192.168.1.0/24: serial network between R2 and R3
192.168.2.0/24: LAN on R3
If we try to ping R1 through R2 we will see that it performs correctly.
The next hop can be identified by an IP address, an outgoing interface, or both. The way in which the destination is specified generates one of the following three types of route:

  • Next hop route : only the IP address of the next hop is specified
  • Static route directly connected : only the router's output interface is specified
  • Static route specified completely : the IP address of the next hop and the output interface are specified

SETTING A STATIC NEXT HOP ROUTE

On a static next hop route, only the IP address of the next hop is specified. The output interface is derived from the next jump. Continuing with the previous example:

We will configure three static routes of next hop on R1 with the IP address of the next hop, R2:

R1 (config) # ip route 172.16.1.0 255.255.255.0 172.16.2.2
R1 (config) # ip route 192.168.1.0 255.255.255.0 172.16.2.2
R1 (config) # ip route 192.168.2.0 255.255.255.0 172.16.2.2
R1 (config) #


Before a router resends a packet, the routing table process must determine which output interface it will use to resend the packet. This is known as route resolution.

Next, we detail the basic process of sending packages in the routing table for R1.

R1 # <b> show ip route | begin gateway
Gateway of last resort is not set
  172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
S 172.16.1.0/24 [1/0] via 172.16.2.2
C 172.16.2.0/24 is directly connected, Serial0 / 0/0
L 172.16.2.1/32 is directly connected, Serial0 / 0/0
C 172.16.3.0/24 is directly connected, GigabitEthernet0 / 0
L 172.16.3.1/32 is directly connected, GigabitEthernet0 / 0
S 192.168.1.0/24 [1/0] via 172.16.2.2
S 192.168.2.0/24 [1/0] via 172.16.2.2
R1 #

When a packet is destined for the 192.168.2.0/24 network, R1:


  1. Look for a match in the routing table and find that it must forward packets to the IPv4 address 172.16.2.2 of the next hop. All routes that refer only to the IPv4 address of the next hop and that do not refer to an outbound interface must resolve the IPv4 address of the next hop with another route in the routing table that has an outbound interface.
  2. In this instance, R1 must determine how to reach address 172.16.2.2. Therefore, look for a second time if there is a match for 172.16.2.2. In this case, the IPv4 address matches the route of the directly connected network 172.16.2.0/24 with the Serial 0/0/0 output interface. This search informs the routing table process that this packet is forwarded outside that interface.
Actually, two search processes are required in the routing table to forward any packet to the 192.168.2.0/24 network. When the router performs several searches in the routing table before resending a packet, it performs a process known as " recursive search . " Because recursive searches consume router resources, they should be avoided whenever possible.
A recursive static route is valid (that is, it is a candidate to be added to the routing table) only when the next specified hop resolves to a valid output interface, either directly or indirectly. If the output interface is "down" (inactive) or "administratively down" (administratively inactive), the static route will not be installed in the routing table.

SETTING UP A DIRECTLY CONNECTED STATIC ROUTE

When configuring a static route, another option is to use the output interface to specify the address of the next hop. Continuing with the example:

Three static routes connected directly on R1 are configured through the output interface:

R1 (config) # ip route 172.16.1.0 255.255.255.0 s0 / 0/0
R1 (config) # ip route 192.168.1.0 255.255.255.0 s0 / 0/0
R1 (config) # ip route 192.168.2.0 255.255.255.0 s0 / 0/0
R1 (config) #

The routing table for R1 (below) shows that when a packet is destined for the 192.168.2.0/24 network, R1 searches for a match in the routing table and finds that it can resend the packet from its 0/0 serial interface / 0. No other search is needed.

R1 # show ip route | begin gateway
 Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
S 172.16.1.0/24 is directly connected, Serial0 / 0/0
C 172.16.2.0/24 is directly connected, Serial0 / 0/0
L 172.16.2.1/32 is directly connected, Serial0 / 0/0
C 172.16.3.0/24 is directly connected, GigabitEthernet0 / 0
L 172.16.3.1/32 is directly connected, GigabitEthernet0 / 0
S 192.168.1.0/24 is directly connected, Serial
S 192.168.2.0/24 is directly connected, Serial0 / 0/0
R1 #

Note that the routing table looks different for the route configured with an output interface than for the route configured with a recursive entry.

The configuration of a static route directly connected to an output interface allows the routing table to solve this interface in a single search , not in two. Although the routing table entry indicates “directly connected”, the administrative distance of the static route remains 1. Only a directly connected interface can have an administrative distance of 0.

CONFIGURING A FULLY SPECIFIED STATIC ROUTE

A fully specified static route has both the exit interface and the IP address of the next hop . This is another type of static route that is used in older versions of IOS, before CEF (Cisco Express Forwarding). This form of static route is used when the exit interface is a multiple access interface and the next hop must be explicitly identified. The next hop must be connected directly to the specified output interface.
Static Routing on Cisco Router

Assume that the network link between R1 and R2 is an Ethernet link and that the GigabitEthernet 0/1 interface of R1 is connected to that network. * CEF is not enabled. To eliminate recursive search, you can implement a directly connected static route using the following command: (Static Routing on Cisco Router)

R1 (config) # ip route 192.168.2.0 255.255.255.0 GigabitEthernet 0/1
However, this can cause incongruous or unexpected results. The difference between a multi-access Ethernet network and a point-to-point serial network is that the latter only has one more device in that network , the router at the other end of the link. With Ethernet networks, there may be many different devices that share the same multi-access network, including hosts and even multiple routers. The designation of the Ethernet output interface on the static route alone does not provide the router with sufficient information to determine which device is the next hop device.
R1 knows that the packet must be encapsulated in an Ethernet frame and that it must be sent from the GigabitEthernet 0/1 interface. However, R1 does not know the IPv4 address of the next hop; therefore, you cannot determine the destination MAC address for the Ethernet frame.
Depending on the topology and configurations of other routers, this static route may or may not work. When the output interface is an Ethernet network, it is recommended to use a fully specified static route , including the output interface and the address of the next hop.

R1 (config) # ip route 172.16.1.0 255.255.255.0 G0 / 1 172.16.2.2
R1 (config) # ip route 192.168.1.0 255.255.255.0 G0 / 1 172.16.2.2
R1 (config) # ip route 192.168.2.0 255.255.255.0 G0 / 1 172.16.2.2
R1 (config) #

As shown in the following query, when forwarding packets to R2, the output interface is GigabitEthernet 0/1 and the IPv4 address of the next hop is 172.16.2.2.

R1 # show ip route | begin gateway
Gateway of last resort is not set

172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
S 172.16.1.0/24 [1/0] via 172.16.2.2, GigabitEthernet 0/1
C 172.16.2.0/24 is directly connected, GigabitEthernet 0/1
L 172.16.2.1/32 is directly connected, GigabitEthernet 0/1
C 172.16.3.0/24 is directly connected, GigabitEthernet0 / 0
L 172.16.3.1/32 is directly connected, GigabitEthernet0 / 0
S 192.168.1.0/24 [1/0] via 172.16.2.2, GigabitEthernet 0/1
S 192.168.2.0/24 [1/0] via 172.16.2.2, GigabitEthernet 0/1
R1 #


VERIFICATION OF A STATIC ROUTE

In addition to ping and traceroute , useful commands to verify static routes include:
show ip route
show ip route static
show ip route red

An example of the result generated by the show ip route static command is shown below In the example, the result is filtered with the vertical bar (|) and the begin parameter The result reflects the use of static routes with the direction of the next jump.
R1 # show ip route static | begin gateway
Gateway of last resort is not set

172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
S 172.16.1.0/24 [1/0] via 172.16.2.2
S 192.168.1.0/24 [1/0] via 172.16.2.2
S 192.168.2.0/24 [1/0] via 172.16.2.2
R1 #
More sample examples:
R1 # show ip route 192.168.2.1
Routing entry for 192.168.2.0/24
 Known via "static", distance 1, metric 0
 Routing Descriptor Blocks:
 * 172.16.2.2
 Route metric is 0, traffic share count is 1
R1 #
R1 # show running-config | section ip route
ip route 172.16.1.0 255.255.255.0 172.16.2.2
ip route 192.168.1.0 255.255.255.0 172.16.2.2
ip route 192.168.2.0 255.255.255.0 172.16.2.2
R1 #

IPV4 Default route configuration on Cisco Router

Routers often use default routes configured locally, or discovered by another router, using a dynamic routing protocol . A default route does not require that any more significant bit match between the default route and the destination IPv4 address. A default route is used when no other route in the routing table matches the destination IP address of the packet. That is, if there is no more specific match, then the default route is used as the gateway of last resort .

In general, the default static routes are used when connecting:
  • A perimeter router to a service provider's network
  • An internal route router (one with only an upstream neighbor router)
As shown in the following table, the command syntax for a default static route is similar to the command syntax for any other static route, with the exception 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 {ip-address | exit-intf}

SETTING A DEFAULT STATIC ROUTE

R1 can be configured with three static routes to reach all remote networks in the example topology. However, R1 is an internal route router, since it is connected only to R2. Therefore, it would be more efficient to configure a default static route.
From the previous figure, a default static route is configured on R1. With this configuration, any packet that does not match more specific route entries is forwarded to 172.16.2.2.

R1 (config) # ip route 0.0.0.0 0.0.0.0 172.16.2.2
R1 (config) #


VERIFICATION OF A DEFAULT STATIC ROUTE

We use the show ip route static command to display the content of static routes in the routing table.

R1 # show ip route static 
Codes: L - local, C - connected, S - static , 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, i - IS-IS, 
 su - IS-IS summary, L1 - IS-IS level-1, 
 L2 - IS-IS level-2, ia - IS-IS inter area, 
 * - candidate default , U - per-user static route
 or - ODR, P - periodic downloaded static route, 
 H - NHRP, l - LISP, + - replicated route, 
 % - next hop override
Gateway of last resort is 172.16.2.2 to network 0.0.0.0

S * 0.0.0.0/0 [1/0] via 172.16.2.2 
R1 #
Observe the asterisk (*) next to the route with the code “S”. The asterisk indicates that this static route is a default candidate route, which is why it is selected as a gateway of last resort.

The key to this setting is the mask / 0 . The subnet mask in a routing table determines how many bits must match between the destination IP address of the packet and the route in the routing table. A binary 1 indicates that the bits must match. A binary 0 indicates that the bits do not have to match . A mask / 0 in this path entry indicates that none of the bits are required to match. The default static route matches all packages for which there is no more specific match.

No comments:

Post a Comment