Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Configure Static Routes

Understand Basic Static Routing

Static routing is often used when the complexity of a dynamic routing protocol is not desired. A route that does not frequently change, and for which there is only one (or very few) paths to the destination, is a good candidate for static routing. The classic use case for static routing is a single-homed customer attaching to an upstream provider. This type of attachments creates a stub network.

Static routes are defined manually. The route consist of a destination prefix and a next-hop forwarding address. The static route is activated in the routing table and inserted into the forwarding table when the next-hop address is reachable. Traffic that matches the static route is forwarded to the specified next-hop address.

You can specify options that define additional information about static routes. These attributes, for example a community tag or a route metric, are included with the route when it’s installed in the routing table. These additional route attributes are not required for basic static routing.

Example: Configure IPv4 Static Routing for a Stub Network

Note:

Our content testing team has validated and updated this example.

This example shows how to configure basic static routing for IPv4.

Requirements

Two devices running Junos OS with a shared network link. No special configuration beyond basic device initialization (management interface, remote access, user login accounts, and so on), is required before you configure this example.

IPv4 Static Routing Overview

There are many practical applications for static routes. Static routing is often used at the network edge to support attachment to stub networks. Stub networks have a single point of entry and egress, making them well suited to the simplicity of a static route. In Junos OS, static routes have a global preference (administrative distance) of 5. This value makes them preferred over routes learned from dynamic protocols like OSPF or BGP.

IPv4 Static Routing Topology

Figure 1 shows the example topology.

In this example, you configure the static route 192.168.47.0/24 on the provider device (R1), using a next-hop address of 172.16.1.2. This route allows the provider device to reach the remote networks at the customer site. You also configure a static default route of 0.0.0.0/0 on the customer device (R2), using a next-hop address of 172.16.1.1. The default route ensures the customer can reach all nonlocal networks by forwarding this traffic to the provider network.

Multiple loopback addresses are configured on both devices. These loopback addresses provide remote destinations to ping, so you can verify the IPv4 static routing works properly.

Figure 1: IPv4 Stub Network Connected to a Service ProviderIPv4 Stub Network Connected to a Service Provider

IPv4 Static Route Configuration

CLI Quick Configuration

To quickly configure basic IPv4 static routing on the R1 and R2 devices, edit the following commands as needed and paste them into the CLI at the [edit] hierarchy level. Be sure to issue a commit from configuration mode to activate the changes.

R1 Device (Provider)

R2 Device (Customer)

Configure the R1 and R2 Devices

Step-by-Step Procedure

This example requires that you navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the Junos OS CLI User Guide.

To configure basic static routes:

  1. Configure the hostname on the R1 (provider) device.

  2. Configure the interfaces on the R1 (provider) device.

  3. Define the static route to the customer’s prefix on the R1 device. Be sure to specify the R2 end of the point-to-point link as the next hop for the static route.

    The static route ensures the provider network can route to all remote destinations in the customer network by forwarding traffic through the R2 device.

  4. Commit your changes on the R1 device.

  5. Configure the hostname on the R2 (customer) device.

  6. Configure the interfaces on the R2 (customer) device.

  7. Define the IPv4 static default route on the R2 device. Be sure to specify the R1 end of the point-to-point link as the next hop for the static route.

    The IPv4 default route ensures the customer can route to all nonlocal destinations by forwarding traffic to the R1 device in the provider network.

  8. Commit your changes on the R2 device.

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.

R1 Device

R2 Device

Verification

Confirm your IPv4 static routing is working properly.

Check the Routing Tables

Purpose

Confirm the IPv4 static routes are listed as active in the routing tables of both devices.

Action
Meaning

The output confirms the static routes are present in the routing tables of both devices. The * symbol indicates the routes are active. The next hop for the static routes correctly point to the IP address assigned to the remote end of the link.

Ping the Remote Loopback Addresses

Purpose

Verify that the IPv4 static routes provide connectivity between the loopback addresses of both devices. It’s a good idea to source your test traffic from a loopback address on the local device using the source option. This approach validates forwarding between the loopback addresses of both devices in a single command.

From the R1 device, ping a loopback interface address on the R2 device.

From the R2 device, ping a loopback interface address on the R1 device.

Action
Meaning

The output confirms the static routes allow traffic to be forwarded between the provider and customer networks.

Example: Configure IPv6 Static Routing for a Stub Network

Note:

Our content testing team has validated and updated this example.

This example shows how to configure basic static routes for IPv6.

Requirements

Two devices running Junos OS with a shared network link. No special configuration beyond basic device initialization (management interface, remote access, user login accounts, and so on), is required before you configure this example.

IPv6 Static Routing 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 when the specified next hop is reachable.

You can specify options that define additional information about static IPv6 routes. These attributes, for example a community tag or route metric, are included with the route when it’s installed in the routing table. These additional route attributes are not required for basic IPv6 static routing.

IPv6 Static Routing Topology

Figure 2 provides the IPv6 static routing topology.

In this example the provider and customer networks have been allocated the IPv6 prefixes 2001:db8:1::/48 and 2001:db8:2::/48, respectively. Both networks are free to allocate longer prefixes (subnetworks) from their assigned prefix block. The point-to-point link is numbered from the provider’s address space using a /126 prefix length. Each device has two loopback addresses allocated from their assigned prefix using a /128 prefix length.

You configure a static route to the customer prefix (2001:db8:2::/48) on the provider (R1) network device, using a next hop of 2001:db8:1:1::2. This route provides reachability from the provider device to the remote networks at the customer site. On the customer device (R2), you configure a static default route of ::/0, using a next-hop address 2001:db8:1:1::1. The default route provides the customer with reachability to all nonlocal prefixes through the provider’s network.

Multiple loopback addresses are configured on both devices. These loopback addresses provide remote destinations to ping, allowing you to verify the IPv6 static routing works properly.

Figure 2: IPv6 Stub Network Connected to a Service ProviderIPv6 Stub Network Connected to a Service Provider

IPv6 Static Route Configuration

CLI Quick Configuration

To quickly configure basic IPv6 static routing on the R1 and R2 devices, edit the following commands as needed and paste them into the CLI at the [edit] hierarchy level. Be sure to issue a commit from configuration mode to activate the changes.

R1 Device (Provider)

R2 Device (Customer)

Configure the R1 and R2 Devices

Step-by-Step Procedure

This example that you navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the Junos OS CLI User Guide.

Follow these steps to configure basic IPv6 static routes:

  1. Configure the hostname on the R1 (provider) device.

  2. Configure the interfaces on the R1 (provider) device.

  3. Define the static route to the customer’s IPv6 prefix on the R1 device. Be sure to set the next-hop address to the customer end of the point-to-point link.

    The use of a /48 bit prefix length ensures that the R1 device can reach all possible remote destinations in the customer network by forwarding through the R2 device.

  4. Commit your changes on the R1 device.

  5. Configure the hostname on the R2 (customer) device.

  6. Configure the interfaces on the R2 (customer) device.

  7. Define the IPv6 static default route on the R2 device. Be sure to set the next-hop address to the provider end of the point-to-point link.

    The IPv6 default route ensures that the R2 device can reach all nonlocal destinations by forwarding traffic through the R1 device in the provider network.

  8. Commit your changes on the R2 device.

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.

R1 Device

R2 Device

Verification

Confirm IPv6 static routing works properly.

Checking the Routing Tables

Purpose

Verify the IPv6 static routes are active in the routing tables of both devices.

Action
Meaning

The output confirms the IPv6 static routes are present in the routing tables of both devices. The * symbol indicates the routes are active. Both the static routes correctly point to the remote end of the point-to-point link as the next hop for matching traffic.

Ping the Remote Loopback Addresses

Purpose

Verify that the IPv6 static routes provide connectivity between the loopback addresses of both devices. It’s a good idea to source your test traffic from a loopback address on the local device using the source option. This approach validates forwarding between the loopback addresses of both devices in a single command.

From the R1 device, ping a loopback address on the R2 device.

From the R2 device, ping q loopback address on the R1 device.

Action
Meaning

The output confirms the IPv6 static routes allow traffic to be forwarded between the provider and customer networks.