Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Announcement: Try the Ask AI chatbot for answers to your technical questions about Juniper products and solutions.

close
header-navigation
keyboard_arrow_up
{ "lCode": "en_US", "lName": "English", "folder": "en_US" }
English

Example: Populating a Routing Table Created by Virtual Router Configuration

date_range 07-Feb-18

This example shows how to populate the routing table that is created when you configure a virtual router.

Requirements

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

Overview

You can install routes into more than one routing table. For example, you might want a simple configuration that allows you to install a static route into the default routing table inet.0, as well as a second routing table vpna.inet.0. Instead of configuring the same static route for each routing table, you can use routing table groups to insert the route into multiple tables. To create a routing table group, include the rib-groups statement.

This example shows how to export static routes, direct routes, and local routes from the default IPv4 unicast routing table (inet.0) and import them into the IPv4 unicast routing table of a virtual router called vpna (vpna.inet.0).

Note

To explicitly create a routing table, include the rib statement. In this case, you do not need to use the rib statement because when you configure a routing instance, Junos OS automatically creates the routing table instance-nameinet.0.

In this example, Device A and Device B are directly connected to each other. Device A also has a virtual router configured called vpna. Device A’s inet.0 routing table has direct and local routes (also known as interface routes). These routes are imported into vpna’s inet.0 routing table (vpna.inet.0). Device A also has a static route configured. This static route is also imported into vpna.inet.0.

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

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 4 description A->B
set interfaces fe-1/2/0 unit 4 family inet address 10.0.2.2/30
set interfaces lo0 unit 1 family inet address 1.1.1.1/32
set routing-instances vpna instance-type virtual-router
set routing-options interface-routes rib-group inet group1
set routing-options static rib-group group1
set routing-options static route 192.168.1.0/24 discard
set routing-options rib-groups group1 import-rib inet.0
set routing-options rib-groups group1 import-rib vpna.inet.0

Device B

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 3 description B->A
set interfaces fe-1/2/0 unit 3 family inet address 10.0.2.1/30
set interfaces lo0 unit 2 family inet address 2.2.2.2/32

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 this example:

  1. Configure the routing instance.
    content_copy zoom_out_map
    [edit routing-instances]
    user@A# set vpna instance-type virtual-router
  2. Configure the interfaces.
    content_copy zoom_out_map
    [edit interfaces]
    user@A# set fe-1/2/0 unit 4 description A->B
    user@A# set fe-1/2/0 unit 4 family inet address 10.0.2.2/30
    user@A# set lo0 unit 1 family inet address 1.1.1.1/32
  3. Configure one or more static routes.
    content_copy zoom_out_map
    [edit routing-options]
    user@A# set static route 192.168.1.0/24 discard
  4. Include the direct and local routes in a routing table group called group1.

    The interface-routes statement specifies direct and local routes to match against. For an example of how to configure and apply a routing policy that specifies particular routes for import and export, see Example: Exporting Specific Routes from One Routing Table Into Another Routing Table.

    content_copy zoom_out_map
    [edit routing-options]
    user@A# set interface-routes rib-group inet group1
  5. Include all static routes in the group1 routing table group.

    The static statement specifies the protocol (static) to match against.

    content_copy zoom_out_map
    [edit routing-options]
    user@A# set static rib-group group1
  6. Configure the primary routing table for group1.

    The primary routing table determines the address family of the routing table group. To configure an IPv4 group, specify inet.0 as the primary table. To configure an IPv6 group, specify inet6.0 as the primary routing table.

    content_copy zoom_out_map
    [edit routing-options]
    user@A# set rib-groups group1 import-rib inet.0
  7. Configure the secondary routing table for group1.
    content_copy zoom_out_map
    [edit routing-options]
    user@A# set rib-groups group1 import-rib vpna.inet.0
  8. If you are done configuring the device, commit the configuration.
    content_copy zoom_out_map
    [edit routing-options]
    user@A# commit

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 Device B:

  1. Configure the interfaces.
    content_copy zoom_out_map
    [edit interfaces]
    user@B# set fe-1/2/0 unit 3 description B->A
    user@B# set fe-1/2/0 unit 3 family inet address 10.0.2.1/30

    user@B# set lo0 unit 2 family inet address 2.2.2.2/32
  2. If you are done configuring the device, commit the configuration.
    content_copy zoom_out_map
    [edit]
    user@B# commit

Results

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

content_copy zoom_out_map
user@A# show interfaces
fe-1/2/0 {
unit 4 {
description A->B;
family inet {
address 10.0.2.2/30;
}
}
}
lo0 {
unit 1 {
family inet {
address 1.1.1.1/32;
}
}
}
content_copy zoom_out_map
user@A# show routing-instances
vpna {
instance-type virtual-router;
}
content_copy zoom_out_map
user@A# show routing-options
interface-routes {
rib-group inet group1;
}
static {
rib-group group1;
route 192.168.1.0/24 discard;
}
rib-groups {
group1 {
import-rib [ inet.0 vpna.inet.0 ];
}
}
content_copy zoom_out_map
user@B# show interfaces
fe-1/2/0 {
unit 3 {
description B->A;
family inet {
address 10.0.2.1/30;
}
}
}
lo0 {
unit 2 {
family inet {
address 2.2.2.2/32;
}
}
}

Verification

Confirm that the configuration is working properly.

Checking the Routing Tables

Purpose

Make sure that the expected routes appear in the routing tables.

Action

user@A> show route table inet.0
content_copy zoom_out_map
inet.0: 4 destinations, 4 routes (4 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

1.1.1.1/32         *[Direct/0] 02:51:24
                    > via lo0.1
10.0.2.0/30        *[Direct/0] 03:19:06
                    > via fe-1/2/0.4
10.0.2.2/32        *[Local/0] 03:19:07
                      Local via fe-1/2/0.4
192.168.1.0/24     *[Static/5] 00:44:21
                      Discard
user@A> show route table vpna.inet.0
content_copy zoom_out_map
vpna.inet.0: 4 destinations, 4 routes (4 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

1.1.1.1/32         *[Direct/0] 02:35:39
                    > via lo0.1
10.0.2.0/30        *[Direct/0] 02:35:39
                    > via fe-1/2/0.4
10.0.2.2/32        *[Local/0] 02:35:39
                      Local via fe-1/2/0.4
192.168.1.0/24     *[Static/5] 00:44:28
                      Discard

Meaning

The static route and the interface routes appear in both routing tables.

footer-navigation