---
# System prepended metadata

title: Static Routes
tags: [' networking', ' switch', Cisco IOS, ' manual', ' router', ' reference', ' technical']

---

---
title: Static Routes
tags: Cisco IOS, networking, manual, reference, router, switch, technical
---

<header>
<h6>Static Routes</h6>

> [toc]
</header>
---

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

:::success
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.
```pug
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.
```pug
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
```
:::warning
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.
```pug
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
```

:::danger
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).
```pug
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.

```pug
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
```

:::info
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<br>(EIGRP) summary route                    |   5 |
| External Border Gateway Protocol (BGP) |  20 |
| Internal EIGRP                         |  90 |
| IGRP                                   | 100 |
| OSPF                                   | 110 |
| Intermediate System-to-<br>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 |

:::success
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.
```pug
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.
```pug
Branch(config)# ipv6 route 2001:db8:acad:2::238/128 serial 0/1/0 fe80::2
```
:::warning
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:
```pug
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 |
| ------------------- | -------- |
| <div class='mono'>*network-address*</div> | Identifies the destination IPv4 network address of the remote network to add to the routing table. |
| <div class='mono'>*subnet-mask*</div> | <ul><li>Identifies the subnet mask of the remote network.</li><li>The subnet mask can be modified to summarize a group of networks and create a summary static route.</li></ul> |
| <div class='mono'>*ip-address*</div> | <ul><li>Identifies the next-hop router IPv4 address.</li><li>Typically used with broadcast networks (i.e., Ethernet).</li><li>Could create a recursive static route where the router performs an additional lookup to find the exit interface.</li></ul> |
| <div class='mono'>*exit-intf*</div> | <ul><li>Identifies the exit interface to forward packets.</li><li>Creates a directly connected static route.</li><li>Typically used in a point-to-point configuration.</li></ul> |
| <div class='mono'>*exit-intf ip-address*</div> | Creates a fully specified static route because it specifies the exit interface and next-hop IPv4 address. |
| <div class='mono'>*distance*</div> | <ul><li>Optional command that can be used to assign an administrative distance value between 1 and 255.</li><li>Typically used to configure a floating static route by setting an administrative distance that is higher than a dynamically learned route.</li></ul> |

## 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.
```pug
Router(config)# ip route 0.0.0.0 0.0.0.0 {ip-address | exit-intf}
```
:::success
IPv4 default static routes are commonly referred to as quad-zero routes.
:::


# IPv6 Configuration Command
:::warning
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:
```pug
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 |
| ------------------- | -------- |
| <div class='mono'>*ipv6-prefix*</div> | Identifies the destination IPv6 network address of the remote network to add to the routing table. |
| <div class='mono'>*/prefix-length*</div> | Identifies the prefix length of the remote network. |
| <div class='mono'>*ipv6-address*</div> | <ul><li>Identifies the next-hop router IPv6 address.</li><li>Typically used with broadcast networks (i.e., Ethernet).</li><li>Could create a recursive static route where the router performs an additional lookup to find the exit interface.</li></ul> |
| <div class='mono'>*exit-intf*</div> | <ul><li>Identifies the exit interface to forward packets.</li><li>Creates a directly connected static route.</li><li>Typically used in a point-to-point configuration.</li></ul> |
| <div class='mono'>*exit-intf ipv6-address*</div> | Creates a fully specified static route because it specifies the exit interface and next-hop IPv6 address. |
| <div class='mono'>*distance*</div> | <ul><li>Optional command that can be used to assign an administrative distance value between 1 and 255.</li><li>Typically used to configure a floating static route by setting an administrative distance that is higher than a dynamically learned route.</li></ul> |

## 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.
```pug
Router(config)# ipv6 route ::/0 {ipv6-address | exit-intf}
```


# Verify a Static Route

## IPv4

### Display Static Routes in Routing Table
```pug
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
```pug
! 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
```pug
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
```pug
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
```pug
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
```pug
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
```pug
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
```pug
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).
```pug
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.
```pug
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#
```


---
---


{%hackmd 7PGmjAHeTXak2VUM3iw5Wg %}