Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Example: Configuring Static Route Preferences and Qualified Next Hops

Understanding Static Route Preferences and Qualified Next Hops

A static route destination address can have multiple next hops associated with it. In this case, multiple routes are inserted into the routing table, and route selection must occur. Because the primary criterion for route selection is the route preference, you can control the routes that are used as the primary route for a particular destination by setting the route preference associated with a particular next hop. The routes with a lower route preference are always used to route traffic. When you do not set a preferred route, traffic is alternated between routes in round-robin fashion.

In general, the default properties assigned to a static route apply to all the next-hop addresses configured for the static route. If, however, you want to configure two possible next-hop addresses for a particular route and have them treated differently, you can define one as a qualified next hop.

Qualified next hops allow you to associate one or more properties with a particular next-hop address. You can set an overall preference for a particular static route and then specify a different preference for the qualified next hop. For example, suppose two next-hop addresses (10.10.10.10 and 10.10.10.7) are associated with the static route 192.168.47.5/32. A general preference is assigned to the entire static route, and then a different preference is assigned to only the qualified next-hop address 10.10.10.7. For example:

route 192.168.47.5/32 {next-hop 10.10.10.10;qualified-next-hop 10.10.10.7 {preference 2;}preference 6;}

In this example, the qualified next hop 10.10.10.7 is assigned the preference 2, and the next-hop 10.10.10.10 is assigned the preference 6.

Note: The preference and metric options only apply to the qualified next hops. The qualified next-hop preference and metric override the route preference and metric (for that specific qualified next hop), similar to how the route preference overrides the default preference and metric (for that specific route).

Example: Configuring Static Route Preferences and Qualified Next Hops

This example shows how to control static route selection.

Requirements

In this example, no special configuration beyond device initialization is required.

Overview

In this example, the static route 192.168.47.0/24 has two possible next hops. Because one link has higher bandwidth, this link is the preferred path. To enforce this preference, the qualified-next-hop statement is included in the configuration on both devices. See Figure 1.

Figure 1: Controlling Static Route Selection

Controlling
Static Route Selection

Configuration

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

Device B

set interfaces ge-1/2/0 unit 0 description B->Dset interfaces ge-1/2/0 unit 0 family inet address 172.16.1.1/24set interfaces fe-1/2/1 unit 2 description secondary-B->Dset interfaces fe-1/2/1 unit 2 family inet address 192.168.2.1/24set interfaces lo0 unit 57 family inet address 10.0.0.1/32set interfaces lo0 unit 57 family inet address 10.0.0.2/32set routing-options static route 192.168.47.0/24 next-hop 172.16.1.2set routing-options static route 192.168.47.0/24 qualified-next-hop 192.168.2.2 preference 25

Device D

set interfaces ge-1/2/0 unit 1 description D->Bset interfaces ge-1/2/0 unit 1 family inet address 172.16.1.2/24set interfaces fe-1/2/1 unit 3 description secondary-D->Bset interfaces fe-1/2/1 unit 3 family inet address 192.168.2.2/24set interfaces lo0 unit 2 family inet address 192.168.47.5/32set interfaces lo0 unit 2 family inet address 192.168.47.6/32set routing-options static route 0.0.0.0/0 next-hop 172.16.1.1set routing-options static route 0.0.0.0/0 qualified-next-hop 192.168.2.1 preference 25

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For instructions on how to do that, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

To control static route selection:

  1. On Device B, configure the interfaces.
    [edit interfaces]user@B# set ge-1/2/0 unit 0 description B->Duser@B# set ge-1/2/0 unit 0 family inet address 172.16.1.1/24user@B# set fe-1/2/1 unit 2 description secondary-B->Duser@B# set fe-1/2/1 unit 2 family inet address 192.168.2.1/24user@B# set lo0 unit 57 family inet address 10.0.0.1/32user@B# set lo0 unit 57 family inet address 10.0.0.2/32
  2. On Device B, configure a static route to the customer network.
    [edit routing-options static route 192.168.47.0/24]user@B# set next-hop 172.16.1.2
  3. On Device B, configure a backup route to the customer network.
    [edit routing options static route 192.168.47.0/24]user@B# set qualified-next-hop 192.168.2.2 preference 25
  4. On Device D, configure the interfaces.
    [edit interfaces]user@D# set ge-1/2/0 unit 1 description D->Buser@D# set ge-1/2/0 unit 1 family inet address 172.16.1.2/24user@D# set fe-1/2/1 unit 3 description secondary-D->Buser@D# set fe-1/2/1 unit 3 family inet address 192.168.2.2/24user@D# set lo0 unit 2 family inet address 192.168.47.5/32user@D# set lo0 unit 2 family inet address 192.168.47.6/32
  5. On Device D, configure a static default route to external networks.
    [edit routing options static route 0.0.0.0/0]user@D# set next-hop 172.16.1.1
  6. On Device D, configure a backup static default route to external networks.
    [edit routing options static route 0.0.0.0/0]user@D# set qualified-next-hop 192.168.2.1 preference 25

Results

Confirm your configuration by issuing the show interfaces and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

user@B# show interfaces
ge-1/2/0 {unit 0 {description B->D;family inet {address 172.16.1.1/24;}}}
fe-1/2/1 {unit 2 {description secondary-B->D;family inet {address 192.168.2.1/24;}}}
lo0 {unit 57 {family inet {address 10.0.0.1/32;address 10.0.0.2/32;}}}
user@B# show routing-options
static {route 192.168.47.0/24 {next-hop 172.16.1.2;qualified-next-hop 192.168.2.2 {preference 25;}}}
user@D# show interfaces
ge-1/2/0 {unit 1 {description D->B;family inet {address 172.16.1.2/24;}}}
fe-1/2/1 {unit 3 {description secondary-D->B;family inet {address 192.168.2.2/24;}}}
lo0 {unit 2 {family inet {address 192.168.47.5/32;address 192.168.47.6/32;}}}
user@D# show routing-options
static {route 0.0.0.0/0 {next-hop 172.16.1.1;qualified-next-hop 192.168.2.1 {preference 25;}}}

If you are done configuring the devices, enter commit from configuration mode on both devices.

Verification

Confirm that the configuration is working properly.

Checking the Routing Tables

Purpose

Make sure that the static routes appear in the routing tables of Device B and Device D.

Action

user@B> show route protocol static
inet.0: 7 destinations, 8 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

192.168.47.0/24    *[Static/5] 02:02:03
                    > to 172.16.1.2 via ge-1/2/0.0
                    [Static/25] 01:58:21
                    > to 192.168.2.2 via fe-1/2/1.2
user@D> show route protocol static
inet.0: 7 destinations, 8 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[Static/5] 02:02:12
                    > to 172.16.1.1 via ge-1/2/0.1
                    [Static/25] 01:58:31
                    > to 192.168.2.1 via fe-1/2/1.3

Meaning

The asterisks (*) in the routing tables show the active routes. The backup routes are listed next.

Pinging the Remote Addresses

Purpose

Verify that the static routes are working.

From Device B, ping one of the loopback interface addresses on Device D.

From Device D, ping one of the loopback interface addresses on Device B.

Action

user@B> ping 192.168.47.5
PING 192.168.47.5 (192.168.47.5): 56 data bytes
64 bytes from 192.168.47.5: icmp_seq=0 ttl=64 time=156.126 ms
64 bytes from 192.168.47.5: icmp_seq=1 ttl=64 time=120.393 ms
64 bytes from 192.168.47.5: icmp_seq=2 ttl=64 time=175.361 ms
user@D> ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=1.315 ms
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=31.819 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=1.268 ms

Making Sure That the Backup Route Becomes the Active Route

Purpose

If the primary route becomes unusable, make sure that the backup secondary route becomes active.

Action

  1. Disable the active route by deactivating the ge-1/2/0.0 interface on Device B.
    user@B# deactivate interfaces ge-1/2/0 unit 0 family inet address 172.16.1.1/24user@B# commit
  2. Check Device B’s routing table.
    user@B> show route protocol static
    inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    192.168.47.0/24    *[Static/25] 02:06:24
                        > to 192.168.2.2 via fe-1/2/1.2
    

Meaning

The backup route has become the active route.

Published: 2013-02-04