Static Routes

Types of 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 IP address.

Next-Hop (Inferred) Route

In a next-hop static route, only the next-hop IP address is specified. The exit interface is derived from the routing table.

R1(config)# ip route 172.16.1.0 255.255.255.0 172.16.2.2
R1(config)# ipv6 route 2001:db8:acad:1::/64 2001:db8:acad:2::2

Directly Connected Route

When configuring a static route, a directly connected static route uses the exit interface to specify the next-hop destination.

R1(config)# ip route 172.16.1.0 255.255.255.0 s0/1/0
R1(config)# ipv6 route 2001:db8:cafe:1::/64 s0/1/0

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.

Fully Specified 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.

R1(config)# ip route 172.16.1.0 255.255.255.0 GigabitEthernet 0/0/1 172.16.2.2
R1(config)# ipv6 route 2001:db8:acad:1::/64 s0/1/0 fe80::2

If the IPv6 static route uses an IPv6 link-local address as the next-hop address, you must create a fully specified static route. IPv6 link-local addresses are not contained in the IPv6 routing table.

Default Static Route

A default route is a static route that matches all packets. Instead of routers storing routes for all of the networks in the internet, they can store a single default route to represent any network that is not in the routing table.

Default routes do not require any far-left bits to match against the destination IP address. A default route is used when no other routes in the routing table match the destination IP address of the packet: if a more specific match does not exist, then the default route is used as the Gateway of Last Resort.

Default static routes are commonly used when connecting an edge router to a service provider network, or a stub router (a router with only one upstream neighbor router).

R1(config)# ip route 0.0.0.0 0.0.0.0 172.16.2.2
R1(config)# ipv6 route ::/0 2001:db8:acad:2::2

Floating Static Route

Floating static routes are static routes that are used to provide a backup path to a primary static or dynamic route, in the event of a link failure. The floating static route is only used when the primary route is not available.

To accomplish this, the floating static route is configured with a higher administrative distance than the primary route. If multiple paths to the destination exist, the router will choose the path with the lowest administrative distance.

R1(config)# ip route 172.16.1.0 255.255.255.0 172.16.2.2 5
R1(config)# ipv6 route 2001:db8:acad:1::/64 2001:db8:acad:2::2 5

By default, static routes have an administrative distance of 1, making them preferable to routes learned from dynamic routing protocols. In this way, the static route “floats” and is not used when the route with the better administrative distance is active.

This table lists the administrative distance default values of the protocols that Cisco supports:

Route Source Distance
Connected interface 0
Static route 1
Enhanced Interior Gateway Routing Protocol
(EIGRP) summary route
5
External Border Gateway Protocol (BGP) 20
Internal EIGRP 90
IGRP 100
OSPF 110
Intermediate System-to-
Intermediate System (IS-IS)
115
Routing Information Protocol (RIP) 120
Exterior Gateway Protocol (EGP) 140
On Demand Routing (ODR) 160
External EIGRP 170
Internal BGP 200
Unknown 255

If the administrative distance is 255 or greater, the router does not believe the source of that route and does not install the route in the routing table.

Static Host Route

A host route is an IPv4 address with a 32-bit mask, or an IPv6 address with a 128-bit mask.

When an active interface on a router is configured with an IP address, a (local) host route is automatically added to the routing table. The local routes are marked with L in the output of the routing table. This is in addition to the connected route, designated with a C in the routing table, for the network address of the interface.

A host route can be a manually configured static route to direct traffic to a specific destination device. The static route uses a destination IP address and a 255.255.255.255 (/32) mask for IPv4 host routes, and a /128 prefix length for IPv6 host routes.

R1(config)# ip route 209.165.200.238 255.255.255.255 198.51.100.2
R1(config)# ipv6 route 2001:db8:acad:2::238/128 2001:db8:acad:1::2

For IPv6 static routes, the next-hop address can be the link-local address of the adjacent router.

Branch(config)# ipv6 route 2001:db8:acad:2::238/128 serial 0/1/0 fe80::2

If an IPv6 local host route uses an IPv6 link-local address as the next-hop address, you must create a fully specified static route.

IPv4 Configuration Command

IPv4 static routes are configured using the following global configuration command:

Router(config)# ip route network-address subnet-mask { ip-address | exit-intf [ip-address]} [distance]

The ip route command parameters are described below:

Parameter Description
network-address
Identifies the destination IPv4 network address of the remote network to add to the routing table.
subnet-mask
  • Identifies the subnet mask of the remote network.
  • The subnet mask can be modified to summarize a group of networks and create a summary static route.
ip-address
  • Identifies the next-hop router IPv4 address.
  • Typically used with broadcast networks (i.e., Ethernet).
  • Could create a recursive static route where the router performs an additional lookup to find the exit interface.
exit-intf
  • Identifies the exit interface to forward packets.
  • Creates a directly connected static route.
  • Typically used in a point-to-point configuration.
exit-intf ip-address
Creates a fully specified static route because it specifies the exit interface and next-hop IPv4 address.
distance
  • Optional command that can be used to assign an administrative distance value between 1 and 255.
  • Typically used to configure a floating static route by setting an administrative distance that is higher than a dynamically learned route.

Default Static Route

The command syntax for an IPv4 default static route is similar to any other IPv4 static route, except that the network address is 0.0.0.0 and the subnet mask is 0.0.0.0. The 0.0.0.0 0.0.0.0 in the route will match any network address.

Router(config)# ip route 0.0.0.0 0.0.0.0 {ip-address | exit-intf}

IPv4 default static routes are commonly referred to as quad-zero routes.

IPv6 Configuration Command

The ipv6 unicast-routing global configuration command must be configured to enable the router to forward IPv6 packets.

IPv6 static routes are configured using the following global configuration command:

Router(config)# ipv6 route ipv6-prefix/prefix-length {ipv6-address | exit-intf [ipv6-address]} [distance]

Most of parameters are identical to the IPv4 version of the command.

The ipv6 route command parameters are described below:

Parameter Description
ipv6-prefix
Identifies the destination IPv6 network address of the remote network to add to the routing table.
/prefix-length
Identifies the prefix length of the remote network.
ipv6-address
  • Identifies the next-hop router IPv6 address.
  • Typically used with broadcast networks (i.e., Ethernet).
  • Could create a recursive static route where the router performs an additional lookup to find the exit interface.
exit-intf
  • Identifies the exit interface to forward packets.
  • Creates a directly connected static route.
  • Typically used in a point-to-point configuration.
exit-intf ipv6-address
Creates a fully specified static route because it specifies the exit interface and next-hop IPv6 address.
distance
  • Optional command that can be used to assign an administrative distance value between 1 and 255.
  • Typically used to configure a floating static route by setting an administrative distance that is higher than a dynamically learned route.

Default Static Route

The command syntax for an IPv6 default static route is similar to any other IPv6 static route, except that the ipv6-prefix/prefix-length is ::/0, which matches all routes.

Router(config)# ipv6 route ::/0 {ipv6-address | exit-intf}

Verify a Static Route

IPv4

Display Static Routes in Routing Table

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#

Display a Specific Network

! 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#

Default Static Route

R1# show ip route static | begin Gateway
! 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#

Static Route Configurations

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#

IPv6

Display Static Routes in Routing Table

R1# show ipv6 route static
! IPv6 Routing Table - default - 8 entries
!    <...output truncated...>
! 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#

Display a Specific Network

R1# 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#

Default Static Route

R1# show ipv6 route static | include ::/0
! IPv6 Routing Table - default - 8 entries
!    <...output truncated...>
! S   ::/0 [1/0]
!      via 2001:DB8:ACAD:2::2
R1#

Static Route Configurations

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#

Test a Floating Static Route

To simulate route failure, shut down an interface used exclusively by any dynamic or primary static route for the Destination router (R2).

R2(config)# interface s0/1/0
R2(config-if)# shut
! *Sep 18 23:36:27.000: %LINK-5-CHANGED: Interface Serial0/1/0, changed state to administratively down
! *Sep 18 23:36:28.000: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1/0, changed state to down
R2(config-if)# interface s0/1/1
R2(config-if)# shut
! *Sep 18 23:36:41.598: %LINK-5-CHANGED: Interface Serial0/1/1, changed state to administratively down
! *Sep 18 23:36:42.598: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1/1, changed state to down

A look at the IP routing tables of R1 verifies that the floating static default routes are now installed as the default routes and are pointing to an alternate link (R3) as the next-hop router.

R1# show ip route static | begin Gateway
Gateway of last resort is 10.10.10.2 to network 0.0.0.0
S*    0.0.0.0/0 [5/0] via 10.10.10.2
R1# show ipv6 route static | begin :: 
S   ::/0 [5/0] 
   via 2001:DB8:FEED:10::2
R1#