A static route is a manually configured route. Static routes will not automatically change if a link or neighboring router fails. In general, static routes should only be used for very simple network topologies, or to override the behaviour of a dynamic routing protocol for a small number of routes.
Static routes can be configured for IPv4 and IPv6. Each route can be specified as to be used for unicast forwarding, or as part of the multicast topology used by multicast routing, or both.
The term RIB refers to the router’s Routing Information Base. This is the collection of all routes the router has learned from its configuration or from its dynamic routing protocols. The RIB maintains separate collections of routes for IPv4 and IPv6. Within each of those collections, the router also maintains separate route tables for unicast routes and for multicast routes. Unicast routes will be used to determine the forwarding table used for unicast packet forwarding. Multicast routes do not directly determine the multicast forwarding table, but instead are used by multicast routing protocols such as PIM. PIM uses this to determine the RPF (Reverse-Path Forwarding) information1 needed to route multicast control information that in turn sets up the multicast forwarding tree. The part of the RIB used to contain multicast topology information is called the Multicast RIB or MRIB.
When a static route is specified, it is necessary to indicate not only the destination subnet and next-hop router, but also whether the route should be placed in the unicast RIB or in the MRIB or both.
The syntax for defining static routes is shown below.
protocols {
static {
targetname: text
disable: bool
route IPv4-addr/int(0..32) {
next-hop: IPv4-addr
metric: uint(1..65535)
qualified-next-hop IPv4-addr {
metric: uint(1..65535)
}
}
route IPv6-addr/int(0..128) {
next-hop: IPv6-addr
metric: uint(1..65535)
qualified-next-hop IPv6-addr {
metric: uint(1..65535)
}
}
mrib-route IPv4-addr/int(0..32) {
next-hop: IPv4-addr
metric: uint(1..65535)
qualified-next-hop IPv4-addr {
metric: uint(1..65535)
}
}
mrib-route IPv6-addr/int(0..128) {
next-hop: IPv6-addr
metric: uint(1..65535)
qualified-next-hop IPv6-addr {
metric: uint(1..65535)
}
}
interface-route IPv4-addr/int(0..32) {
next-hop-interface: text
next-hop-vif: text
next-hop-router: IPv4-addr
metric: uint(1..65535)
qualified-next-interface text {
qualified-next-vif text {
next-hop-router: IPv4-addr
metric: uint(1..65535)
}
}
}
interface-route IPv6-addr/int(0..128) {
next-hop-interface: text
next-hop-vif: text
next-hop-router: IPv6-addr
metric: uint(1..65535)
qualified-next-interface text {
qualified-next-vif text {
next-hop-router: IPv6-addr
metric: uint(1..65535)
}
}
}
mrib-interface-route IPv4-addr/int(0..32) {
next-hop-interface: text
next-hop-vif: text
next-hop-router: IPv4-addr
metric: uint(1..65535)
qualified-next-interface text {
qualified-next-vif text {
next-hop-router: IPv4-addr
metric: uint(1..65535)
}
}
}
mrib-interface-route IPv6-addr/int(0..128) {
next-hop-interface: text
next-hop-vif: text
next-hop-router: IPv6-addr
metric: uint(1..65535)
qualified-next-interface text {
qualified-next-vif text {
next-hop-router: IPv6-addr
metric: uint(1..65535)
}
}
}
}
}
The configuration parameters are used as follows:
| Keyword | Description |
|---|---|
| protocols | This delimits the configuration for all routing protocols in the XORP router configuration. It is mandatory that BGP configuration is under the protocols node in the configuration. |
| static | |
| targetname | This is the name for this instance of static routes. It defaults to “static routes”, and it is not recommended that this default is overridden under normal usage scenarios. |
| disable | This takes the value true or false, and determines whether any static routes are installed or not. Setting it to true has the same effect as deleting the whole static routes configuration, but without losing what the old configuration actually was. |
| route | This specifies an unicast route to be installed in the RIB. The parameter is an IPv4 or IPv6 destination subnet expressed in the form address/prefix-length. Each route: specification takes the following attributes:
next-hop: this specifies the IPv4 or IPv6 address (in case of IPv4 or IPv6 destination respectively)
of the nexthop router towards the destination subnet 4 . It is mandatory.
metric: this specifies the routing metric or cost for this route. It is a non-negative integer. The
metric for a static route is not directly used to decide which route to use, but may affect the
choice of routes for protocols such as BGP and PIM-SM that indirectly use this information.
For example, BGP uses the IGP metric to the nexthop to decide between alternative routes as
part of its decision process. As with all routing metrics, lower values indicate better routes. The
default is 1.
qualified-next-hop: this specifies an alternative nexthop router for the route, but with a
different metric. Typically it is used to install a backup static route that will be used in case the
original next hop becomes unreachable (e.g., the interface toward it is disabled, or the cable has
been disconnected).
Each qualified-next-hop: specification takes the following attributes:
metric: this specifies the routing metric or cost for this qualified route. It is a non-negative
integer. Typically its value is larger than the metric for the primary next-hop. The default is
10.
|
| mrib-route | This specifies an multicast route to be installed in the Multicast RIB 5 . The parameter is an IPv4 or IPv6 destination subnet expressed in the form address/prefix-length. This route will not directly affect forwarding, but will be used by multicast routing protocols such as PIM-SM to control how multicast trees are formed. An mrib-route specification takes the same attributes as a route specification. interface-route: this specifies an unicast route to be installed in the RIB 6 . The parameter is an IPv4
or IPv6 destination subnet expressed in the form address/prefix-length. Typically, this specification
will be used in wireless environment to install static routes where this router and next-hop router don’t
share the same subnet address on some (wireless) interface.
Each interface-route: specification takes the following attributes:
next-hop-interface: this specifies the name of the nexthop interface towards the destination
subnet. It is mandatory.
next-hop-vif: this specifies the name of the nexthop vif towards the destination subnet. It is
mandatory.
next-hop-router: this specifies the IPv4 or IPv6 address (in case of IPv4 or IPv6 destination
respectively) of the nexthop router towards the destination subnet. The default is 0.0.0.0 or ::
(for IPv4 and IPv6 respectively).
metric: this specifies the routing metric or cost for this route. See route metric for details. The
default is 1.
qualified-next-hop-interface: this specifies an alternative nexthop interface for the
route, but with a different metric. Typically it is used to install a backup static route that will be
used in case the original next hop becomes unreachable.
Each qualified-next-hop-interface: specification takes the following attributes:
qualified-next-hop-vif: this specifies an alternative nexthop vif for the route, but
with a different metric.
Each qualified-next-hop-vif: specification takes the following attributes:
next-hop-router: this specifies the IPv4 or IPv6 address (in case of IPv4 or IPv6
destination respectively) of the nexthop router towards the destination subnet.
metric: this specifies the routing metric or cost for this qualified route. It is a non-
negative integer. Typically its value is larger than the metric for the primary next-hop.
The default is 10.
|
The mrib-interface-route specification is same as the interface-route specification, except that it is used to configure routes that are to be installed in the Multicast RIB.
protocols {
static {
route 10.20.0.0/16 {
next-hop: 10.10.10.20
metric: 1
qualified-next-hop 172.17.0.2 {
metric: 10
}
}
route 2001:DB8:AAAA:20::/64 {
next-hop: 2001:DB8:10:10:10:10:10:20
metric: 1
}
mrib-route 10.20.0.0/16 {
next-hop: 10.10.10.30
metric: 1
}
mrib-route 2001:DB8:AAAA:20::/64 {
next-hop: 2001:DB8:10:10:10:10:10:30
metric: 1
}
interface-route 10.30.0.0/16 {
next-hop-interface: rl0
next-hop-vif: rl0
metric: 1
qualified-next-hop-interface rl1 {
qualified-next-hop-vif rl1 {
metric: 10
}
}
}
interface-route 2001:DB8:AAAA:30::/64 {
next-hop-interface: rl0
next-hop-vif: rl0
metric: 1
}
mrib-interface-route 10.30.0.0/16 {
next-hop-interface: rl1
next-hop-vif: rl1
metric: 1
}
mrib-interface-route 2001:DB8:AAAA:30::/64 {
next-hop-interface: rl1
next-hop-vif: rl1
metric: 1
}
}
}
IPv4 unicast static routes can be displayed using the command:
show route table ipv4 unicast static
user@hostname> show route table ipv4 unicast static
192.168.0.0/24 [static(1)/1]
> to 192.150.187.1 via fxp0/fxp0
192.168.1.0/24 [static(1)/1]
> to 192.150.187.2 via fxp0/fxp0
The information shown for each route not only indicates the configured information (network, nexthop and metric), but also the interface and vif via which this route will forward packets.
If the nexthop is not actually reachable, the route will not be shown by this command because there is not current interface or vif.
IPv6 unicast static routes can be displayed using the command:
show route table ipv6 unicast static
The Multicast RIB static routes can be displayed using the commands:
show route table ipv4 multicast static show route table ipv6 multicast static