Supported Platforms
Example: Importing Direct and Static Routes Into a Routing Instance
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-name.inet.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
Device B
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:
- Configure the routing instance.[edit routing-instances]user@A# set vpna instance-type virtual-router
- Configure the interfaces.[edit interfaces]user@A# set fe-1/2/0 unit 4 description A->Buser@A# set fe-1/2/0 unit 4 family inet address 10.0.2.2/30user@A# set lo0 unit 1 family inet address 1.1.1.1/32
- Configure one or more static routes.[edit routing-options]user@A# set static route 192.168.1.0/24 discard
- Include the direct and local routes in a routing table
group called group1.
The interface-routes statement specifies the direct and local routes to match against.
[edit routing-options]user@A# set interface-routes rib-group inet group1 - Include all static routes in the group1 routing table
group.
The static statement specifies the protocol (static) to match against.
[edit routing-options]user@A# set static rib-group group1 - 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.
[edit routing-options]user@A# set rib-groups group1 import-rib inet.0 - Configure the secondary routing table for group1.[edit routing-options]user@A# set rib-groups group1 import-rib vpna.inet.0
- If you are done configuring the device, commit the configuration.[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:
- Configure the interfaces.[edit interfaces]user@B# set fe-1/2/0 unit 3 description B->Auser@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 - If you are done configuring the device, commit the configuration.[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.
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
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
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.