Examples: Configuring Static Routes

 

Understanding Basic Static Routing

Routes that are permanent fixtures in the routing and forwarding tables are often configured as static routes. These routes generally do not change, and often include only one or very few paths to the destination.

To create a static route in the routing table, you must, at minimum, define the route as static and associate a next-hop address with it. The static route in the routing table is inserted into the forwarding table when the next-hop address is reachable. All traffic destined for the static route is transmitted to the next-hop address for transit.

You can specify options that define additional information about static routes that is included with the route when it is installed in the routing table. All static options are optional.

Example: Configuring a Basic Set of Static Routes for Connecting to Stub Networks

This example shows how to configure a basic set of static routes.

Requirements

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

Overview

There are many practical applications for static routes. Static routing is often used at the network edge to support attachment to stub networks, which, given their single point of entry and egress, are well suited to the simplicity of a static route. In Junos OS, static routes have a global preference of 5. Static routes are activated if the specified next hop is reachable.

In this example, you configure the static route 192.168.47.0/24 from the provider network to the customer network, using the next-hop address of 172.16.1.2. You also configure a static default route of 0.0.0.0/0 from the customer network to the provider network, using a next-hop address of 172.16.1.1.

For demonstration purposes, some loopback interfaces are configured on Device B and Device D. These loopback interfaces provide addresses to ping and thus verify that the static routes are working.

Figure 1 shows the sample network.

Figure 1: Customer Routes Connected to a Service Provider
Customer Routes
Connected to a Service Provider

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

Device D

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

To configure basic static routes:

  1. On Device B, configure the interfaces.
  2. On Device B, create a static route and set the next-hop address.
  3. If you are done configuring Device B, commit the configuration.
  4. On Device D, configure the interfaces.
  5. On Device D, create a static route and set the next-hop address.
  6. If you are done configuring Device D, commit the configuration.

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.

Device B

Device D

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
user@D> show route

Meaning

The static routes are in the routing tables.

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
user@D> ping 10.0.0.1

Example: Configuring IPv6 Static Routes

This example shows how to configure static routes when the interfaces have IPv6 addresses.

Requirements

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

Overview

There are many practical applications for static routes. Static routing is often used at the network edge to support attachment to stub networks, which, given their single point of entry and egress, are well suited to the simplicity of a static route. In Junos OS, static routes have a global preference of 5. Static routes are activated if the specified next hop is reachable.

In this example, you configure a static default route of ::/0, using a next-hop address 2001:db8:0:1:2a0:a502:0:1da.

For demonstration purposes, some loopback interfaces are configured on Device A and Device E. These loopback interfaces provide addresses to ping and thus verify that the static routes are working.

Figure 2 shows the sample network.

Figure 2: Customer Routes Connected to a Service Provider
Customer Routes
Connected to a Service Provider

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 A

Device E

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

To configure basic static routes:

  1. On Device A, configure the interfaces.
  2. On Device A, create a static route to Device E’s loopback address and set the next-hop address.

    This ensures that Device A has a route back to Device E.

  3. If you are done configuring Device A, commit the configuration.
  4. On Device E, configure the interfaces.
  5. On Device E, create a static default route and set the next-hop address.
  6. If you are done configuring Device E, commit the configuration.

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.

Device A

Device E

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 A and Device E.

Action

user@A> show route protocol static
user@E> show route protocol static

Meaning

The static routes are in the routing tables.

Pinging the Remote Addresses

Purpose

Verify that the static routes are working.

From Device A, ping one of the loopback interface addresses on Device E.

From Device E, ping one of the loopback interface addresses on Device A.

Action

user@A> ping 2001:db8::5
user@E> ping 2001:db8::3