Configure IP Static Routes
Configure IP Static Routes

Configure IP Static Routes

Configure IP Static Routes
5

Summary

This topic configure IPv4 and IPv6 static routes. Start learning CCNA 200-301 for free right now!!

Note: Welcome: This topic is part of Module 15 of the Cisco CCNA 2 course, for a better follow up of the course you can go to the CCNA 2 section to guide you through an order.

IPv4 Next-Hop Static Route

The commands to configure standard static routes varies slightly between IPv4 and IPv6. This topic shows you how to configure standard next-hop, directly connected, and full specified static routes for both IPv4 and Ipv6.

In a next-hop static route, only the next-hop IP address is specified. The exit interface is derived from the next hop. For example, three next-hop IPv4 static routes are configured on R1 using the IP address of the next hop, R2.

Dual-Stack Topology
Dual-Stack Topology

The commands to configure R1 with the IPv4 static routes to the three remote networks are as follows:

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

The routing table for R1 now has routes to the three remote IPv4 networks.

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
C        172.16.2.0/24 is directly connected, Serial0/1/0
L        172.16.2.1/32 is directly connected, Serial0/1/0
C        172.16.3.0/24 is directly connected, GigabitEthernet0/0/0
L        172.16.3.1/32 is directly connected, GigabitEthernet0/0/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#

IPv6 Next-Hop Static Route

The commands to configure R1 with the IPv6 static routes to the three remote networks are as follows:

R1(config)# ipv6 unicast-routing
R1(config)# ipv6 route 2001:db8:acad:1::/64 2001:db8:acad:2::2
R1(config)# ipv6 route 2001:db8:cafe:1::/64 2001:db8:acad:2::2
R1(config)# ipv6 route 2001:db8:cafe:2::/64 2001:db8:acad:2::2

The routing table for R1 now has routes to the three remote IPv6 networks.

R1# show ipv6 route
IPv6 Routing Table - default - 8 entries
Codes: C - Connected, L - Local, S - Static, U - Per-user Static route
       B - BGP, R - RIP, H - NHRP, I1 - ISIS L1
       I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary, D - EIGRP
       EX - EIGRP external, ND - ND Default, NDp - ND Prefix, DCE - Destination
       NDr - Redirect, RL - RPL, O - OSPF Intra, OI - OSPF Inter
       OE1 - OSPF ext 1, OE2 - OSPF ext 2, ON1 - OSPF NSSA ext 1
       ON2 - OSPF NSSA ext 2, la - LISP alt, lr - LISP site-registrations
       ld - LISP dyn-eid, lA - LISP away, le - LISP extranet-policy
       a - Application
S   2001:DB8:ACAD:1::/64 [1/0]
     via 2001:DB8:ACAD:2::2
C   2001:DB8:ACAD:2::/64 [0/0]
     via Serial0/1/0, directly connected
L   2001:DB8:ACAD:2::1/128 [0/0]
     via Serial0/1/0, receive
C   2001:DB8:ACAD:3::/64 [0/0]
     via GigabitEthernet0/0/0, directly connected
L   2001:DB8:ACAD:3::1/128 [0/0]
     via GigabitEthernet0/0/0, receive
S   2001:DB8:CAFE:1::/64 [1/0]
     via 2001:DB8:ACAD:2::2
S   2001:DB8:CAFE:2::/64 [1/0]
     via 2001:DB8:ACAD:2::2
L   FF00::/8 [0/0]
     via Null0, receive

IPv4 Directly Connected Static Route

When configuring a static route, another option is to use the exit interface to specify the next-hop address. The figure shows the topology again.

Dual-Stack Topology
Dual-Stack Topology

Three directly connected IPv4 static routes are configured on R1 using the exit interface.

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

The IPv4 routing table for R1 shows that when a packet is destined for the 192.168.2.0/24 network, R1 looks for a match in the routing table, and finds that it can forward the packet out of its Serial 0/1/0 interface.

Note: Using a next-hop address is generally recommended. Directly connected static routes should only be used with point-to-point serial interfaces, as in this example.

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/1/0
C        172.16.2.0/24 is directly connected, Serial0/1/0
L        172.16.2.1/32 is directly connected, Serial0/1/0
C        172.16.3.0/24 is directly connected, GigabitEthernet0/0/0
L        172.16.3.1/32 is directly connected, GigabitEthernet0/0/0
S     192.168.1.0/24 is directly connected, Serial0/1/0
S     192.168.2.0/24 is directly connected, Serial0/1/0

IPv6 Directly Connected Static Route

In the example, three directly connected IPv6 static routes are configured on R1 using the exit interface.

R1(config)# ipv6 route 2001:db8:acad:1::/64 s0/1/0
R1(config)# ipv6 route 2001:db8:cafe:1::/64 s0/1/0
R1(config)# ipv6 route 2001:db8:cafe:2::/64 s0/1/0

The IPv6 routing table for R1 in the example output shows that when a packet is destined for the 2001:db8:cafe:2::/64 network, R1 looks for a match in the routing table and finds that it can forward the packet out of its Serial 0/1/0 interface.

Note: Using a next-hop address is generally recommended. Directly connected static routes should only be used with point-to-point serial interfaces, as in this example.

R1# show ipv6 route
IPv6 Routing Table - default - 8 entries
Codes: C - Connected, L - Local, S - Static, U - Per-user Static route
       B - BGP, R - RIP, H - NHRP, I1 - ISIS L1
       I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary, D - EIGRP
       EX - EIGRP external, ND - ND Default, NDp - ND Prefix, DCE - Destination
       NDr - Redirect, RL - RPL, O - OSPF Intra, OI - OSPF Inter
       OE1 - OSPF ext 1, OE2 - OSPF ext 2, ON1 - OSPF NSSA ext 1
       ON2 - OSPF NSSA ext 2, la - LISP alt, lr - LISP site-registrations
       ld - LISP dyn-eid, lA - LISP away, le - LISP extranet-policy
       a - Application
S   2001:DB8:ACAD:1::/64 [1/0]
     via Serial0/1/0, directly connected
C   2001:DB8:ACAD:2::/64 [0/0]
     via Serial0/1/0, directly connected
L   2001:DB8:ACAD:2::1/128 [0/0]
     via Serial0/1/0, receive
C   2001:DB8:ACAD:3::/64 [0/0]
     via GigabitEthernet0/0/0, directly connected
L   2001:DB8:ACAD:3::1/128 [0/0]
     via GigabitEthernet0/0/0, receive
S   2001:DB8:CAFE:1::/64 [1/0]
     via Serial0/1/0, directly connected
S   2001:DB8:CAFE:2::/64 [1/0]
     via Serial0/1/0, directly connected
L   FF00::/8 [0/0]
     via Null0, receiveIPv6 Routing Table - default - 8 entries
R1#

IPv4 Fully Specified Static Route

In a fully specified static route, both the exit interface and the next-hop IP address are specified. This form of static route is used when the exit interface is a multi-access interface and it is necessary to explicitly identify the next hop. The next hop must be directly connected to the specified exit interface. Using an exit interface is optional, however it is necessary to use a next-hop address.

Suppose that the network link between R1 and R2 is an Ethernet link and that the GigabitEthernet 0/0/1 interface of R1 is connected to that network, as shown in the figure.

IPv4 Fully Specified Static Route
IPv4 Fully Specified Static Route

The difference between an Ethernet multi-access network and a point-to-point serial network is that a point-to-point serial network has only one other device on that network, the router at the other end of the link. With Ethernet networks, there may be many different devices sharing the same multi-access network, including hosts and even multiple routers.

It is recommended that when the exit interface is an Ethernet network, that the static route includes a next-hop address. You can also use a fully specified static route that includes both the exit interface and the next-hop address.

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

When forwarding packets to R2, the exit interface is GigabitEthernet 0/0/1 and the next-hop IPv4 address is 172.16.2.2 as shown in the show ip route output from R1.

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, GigabitEthernet0/0/1
C        172.16.2.0/24 is directly connected, GigabitEthernet0/0/1
L        172.16.2.1/32 is directly connected, GigabitEthernet0/0/1
C        172.16.3.0/24 is directly connected, GigabitEthernet0/0/0
L        172.16.3.1/32 is directly connected, GigabitEthernet0/0/0
S     192.168.1.0/24 [1/0] via 172.16.2.2, GigabitEthernet0/0/1
S     192.168.2.0/24 [1/0] via 172.16.2.2, GigabitEthernet0/0/1

IPv6 Fully Specified Static Route

In a fully specified IPv6 static route, both the exit interface and the next-hop IPv6 address are specified. There is a situation in IPv6 when a fully specified static route must be used. If the IPv6 static route uses an IPv6 link-local address as the next-hop address, use a fully specified static route. The figure shows an example of a fully specified IPv6 static route using an IPv6 link-local address as the next-hop address.

IPv6 Fully Specified Static Route
IPv6 Fully Specified Static Route
R1(config)# ipv6 route 2001:db8:acad:1::/64 fe80::2
%Interface has to be specified for a link-local nexthop
R1(config)# ipv6 route 2001:db8:acad:1::/64 s0/1/0 fe80::2

In the example, a fully specified static route is configured using the link-local address of R2 as the next-hop address. Notice that IOS requires that an exit interface be specified.

The reason a fully specified static route must be used is because IPv6 link-local addresses are not contained in the IPv6 routing table. Link-local addresses are only unique on a given link or network. The next-hop link-local address may be a valid address on multiple networks connected to the router. Therefore, it is necessary that the exit interface be included.

The following example shows the IPv6 routing table entry for this route. Notice that both the next-hop link-local address and the exit interface are included.

R1# show ipv6 route static | begin 2001:db8:acad:1::/64
S   2001:DB8:ACAD:1::/64 [1/0]
    via FE80::2, Seria0/1/0

Verify a Static Route

Along with show ip routeshow ipv6 routeping and traceroute, other useful commands to verify static routes include the following:

  • show ip route static
  • show ip route network
  • show running-config | section ip route

Replace ip with ipv6 for the IPv6 versions of the command.

Reference the figure when reviewing the command examples.

Dual-Stack Topology
Dual-Stack Topology

This output shows only the IPv4 static routes in the routing table. Also note where the filter begins the output, excluding all the codes.

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#

This command will show output for only the specified network in the routing table.

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#

This command filters the running configuration for only IPv4 static routes.

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#

This output shows only the IPv6 static routes in the routing table. Also note where the filter begins the output, excluding all the codes.

R1# show ipv6 route static
IPv6 Routing Table - default - 8 entries
Codes: C - Connected, L - Local, S - Static, U - Per-user Static route
       B - BGP, R - RIP, H - NHRP, I1 - ISIS L1
       I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary, D - EIGRP
       EX - EIGRP external, ND - ND Default, NDp - ND Prefix, DCE - Destination
       NDr - Redirect, RL - RPL, O - OSPF Intra, OI - OSPF Inter
       OE1 - OSPF ext 1, OE2 - OSPF ext 2, ON1 - OSPF NSSA ext 1
       ON2 - OSPF NSSA ext 2, la - LISP alt, lr - LISP site-registrations
       ld - LISP dyn-eid, lA - LISP away, le - LISP extranet-policy
       a - Application
S   2001:DB8:ACAD:1::/64 [1/0]
     via 2001:DB8:ACAD:2::2
S   2001:DB8:CAFE:1::/64 [1/0]
     via 2001:DB8:ACAD:2::2
S   2001:DB8:CAFE:2::/64 [1/0]
     via 2001:DB8:ACAD:2::2
R1#

This command will show output for only the specified network in the routing table.

# show ipv6 route 2001:db8:cafe:2:: 
Routing entry for 2001:DB8:CAFE:2::/64
  Known via "static", distance 1, metric 0
  Route count is 1/1, share count 0
  Routing paths:
    2001:DB8:ACAD:2::2
      Last updated 00:23:55 ago

R1#

This command filters the running configuration for only IPv6 static routes.

R1# show running-config | section ipv6 route
ipv6 route 2001:DB8:ACAD:1::/64 2001:DB8:ACAD:2::2
ipv6 route 2001:DB8:CAFE:1::/64 2001:DB8:ACAD:2::2
ipv6 route 2001:DB8:CAFE:2::/64 2001:DB8:ACAD:2::2
R1#

Syntax Checker – Configure Static Routes

Configure static routes based on the specified requirements

Dual-Stack Topology
Dual-Stack Topology
  • Configure an IPv4 next-hop static route on R2 to the 192.168.2.0/24 network using the next-hop address 192.168.1.1.
R2(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.1
  • Configure a fully specified IPv4 static route on R2 to the 172.16.3.0/24 network using the exit interface/next-hop pair: g0/0/1 172.16.2.1
R2(config)#ip route 172.16.3.0 255.255.255.0 g0/0/1 172.16.2.1
  • Configure an IPv6 next-hop static route on R2 to the 2001:db8:cafe:2::/64 network using the next-hop address 2001:db8:cafe:1::1.
R2(config)#ipv6 route 2001:db8:cafe:2::/64 2001:db8:cafe:1::1
  • Configure a fully specified IPv6 static route on R2 to the 2001:db8:acad:3::/64 network using the exit interface/next-hop pair: g0/0/1 / fe80::1
R2(config)#ipv6 route 2001:db8:acad:3::/64 g0/0/1 fe80::1
  • Exit configuration mode and issue the command to display only the IPv4 static routes in the routing table of R2.
R2(config)#exit
\*Sep 18 21:44:32.910: %SYS-5-CONFIG\_I: Configured from console by console
R2#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
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
      172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
S        172.16.3.0/24 \[1/0\] via 172.16.2.1, GigabitEthernet0/0/1
S     192.168.2.0/24 \[1/0\] via 192.168.1.1
  • Issue the command to display only the IPv6 static routes in the routing table of R2.
R2#show ipv6 route static
IPv6 Routing Table - default - 9 entries
Codes: C - Connected, L - Local, S - Static, U - Per-user Static route
       B - BGP, R - RIP, H - NHRP, I1 - ISIS L1
       I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary, D - EIGRP
       EX - EIGRP external, ND - ND Default, NDp - ND Prefix, DCE - Destination
       NDr - Redirect, RL - RPL, O - OSPF Intra, OI - OSPF Inter
       OE1 - OSPF ext 1, OE2 - OSPF ext 2, ON1 - OSPF NSSA ext 1
       ON2 - OSPF NSSA ext 2, a - Application
S   2001:DB8:ACAD:3::/64 \[1/0\]
     via FE80::1, GigabitEthernet0/0/1
S   2001:DB8:CAFE:2::/64 \[1/0\]
     via 2001:DB8:CAFE:1::1
==============================================================

You are now logged into R3:

  • Configure a directly connected IPv4 static route on R3 to the 172.16.3.0/24 network using exit interface S0/1/1.
R3(config)#ip route 172.16.3.0 255.255.255.0 s0/1/1
  • Configure a directly connected IPv4 static route on R3 to the 172.16.1.0/24 network using exit interface S0/1/1.
R3(config)#ip route 172.16.1.0 255.255.255.0 s0/1/1
  • Configure a directly connected IPv4 static route on R3 to the 172.16.2.0/24 network using exit interface S0/1/1.
R3(config)#ip route 172.16.2.0 255.255.255.0 s0/1/1
  • Configure a directly connected IPv6 static route on R3 to the 2001:db8:acad:1::/64 network using exit interface S0/1/1.
R3(config)#ipv6 route 2001:db8:acad:1::/64 s0/1/1
  • Configure a directly connected IPv6 static route on R3 to the 2001:db8:acad:3::/64 network using exit interface S0/1/1.
R3(config)#ipv6 route 2001:db8:acad:3::/64 s0/1/1
  • Configure a directly connected IPv6 static route on R3 to the 2001:db8:acad:2::/64 network using exit interface S0/1/1.
R3(config)#ipv6 route 2001:db8:acad:2::/64 s0/1/1
  • Exit configuration mode and issue the command to display only the IPv4 static routes in the routing table of R3.
R3(config)#exit
Sep 18 21:47:57.894: %SYS-5-CONFIG\_I: Configured from console by console
R3#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
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
      172.16.0.0/24 is subnetted, 3 subnets
S        172.16.1.0 is directly connected, Serial0/1/1
S        172.16.2.0 is directly connected, Serial0/1/1
S        172.16.3.0 is directly connected, Serial0/1/1
  • Issue the command to display only the IPv6 static routes in the routing table of R3.
R3#show ipv6 route static
IPv6 Routing Table - default - 8 entries
Codes: C - Connected, L - Local, S - Static, U - Per-user Static route
       B - BGP, R - RIP, H - NHRP, I1 - ISIS L1
       I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary, D - EIGRP
       EX - EIGRP external, ND - ND Default, NDp - ND Prefix, DCE - Destination
       NDr - Redirect, RL - RPL, O - OSPF Intra, OI - OSPF Inter
       OE1 - OSPF ext 1, OE2 - OSPF ext 2, ON1 - OSPF NSSA ext 1
       ON2 - OSPF NSSA ext 2, a - Application
S   2001:DB8:ACAD:1::/64 \[1/0\]
     via Serial0/1/1, directly connected
S   2001:DB8:ACAD:2::/64 \[1/0\]
     via Serial0/1/1, directly connected
S   2001:DB8:ACAD:3::/64 \[1/0\]
     via Serial0/1/1, directly connected

You have successfully configured and verified IPv4 and IPv6 static routes.

Glossary: If you have doubts about any special term, you can consult this computer network dictionary.

Ready to go! Keep visiting our networking course blog, give Like to our fanpage; and you will find more tools and concepts that will make you a networking professional.