Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Examples: Creating a Routing Table and Populating It with Routes

Understanding Junos OS Routing Tables

Junos OS automatically creates and maintains several routing tables. Each routing table is used for a specific purpose. In addition to these automatically created routing tables, you can create your own routing tables.

Each routing table populates a portion of the forwarding table. Thus, the forwarding table is partitioned based on routing tables. This allows for specific forwarding behavior for each routing table. For example, for VPNs, each VPN-based routing table has its own VPN-specific partition in the forwarding table.

It is common for the routing software to maintain unicast routes and multicast routes in different routing tables. You also might have policy considerations that would lead you to create separate routing tables to manage the propagation of routing information.

Creating routing tables is optional. If you do not create any, Junos OS uses its default routing tables, which are as follows:

  • inet.0—For IP version 4 (IPv4) unicast routes. This table stores interface local and direct routes, static routes, and dynamically learned routes.
  • inet.1—For the IPv4 multicast forwarding cache. This table stores the IPv4 (S,G) group entries that are dynamically created as a result of join state information.
  • inet.2—For subsequent address family indicator (SAFI) 2 routes, when multiprotocol BGP (MBGP) is enabled. This table stores unicast routes that are used for multicast reverse-path-forwarding (RPF) lookup. The routes in this table can be used by the Distance Vector Multicast Routing Protocol (DVMRP), which requires a specific RPF table. In contrast, Protocol Independent Multicast (PIM) does not need this table because it can perform RPF checks against the inet.0 table. You can import routes from inet.0 into inet.2 using routing information base (RIB) groups, or install routes directly into inet.2 from a multicast routing protocol.
  • inet.3—For IPv4 MPLS. This table stores the egress address of an MPLS label-swiched path (LSP), the LSP name, and the outgoing interface name. This routing table is used only when the local device is the ingress node to an LSP.
  • inet6.0—For IP version 6 (IPv6) unicast routes. This table stores interface local and direct routes, static routes, and dynamically learned routes.
  • instance-name.inet.0—If you configure a routing instance, Junos OS creates the default unicast routing table instance-name.inet.0.
  • instance-name.inet.2—If you configure routing-instances instance-name protocols bgp family inet multicast in a routing instance of type VRF, Junos OS creates the instance-name.inet.2 table.

    Another way to create the instance-name.inet.2 table is to use the rib-group statement. See Example: Exporting Specific Routes from One Routing Table Into Another Routing Table.

    Note: Importing inet-vpn multicast routes from the bgp.l3vpn.2 table into the instance-name.inet.2 table does not create the instance-name.inet.2 table. The import operation works only if the instance-name.inet.2 table already exists.

  • instance-name.inetflow.0—If you configure a flow route, Junos OS creates the flow routing table instance-name.inetflow.0.
  • bgp.l2vpn.0—For Layer 2 VPN routes learned from BGP. This table stores routes learned from other provider edge (PE) routers. The Layer 2 routing information is copied into Layer 2 VPN routing and forwarding instances (VRFs) based on target communities.
  • bgp.l3vpn.0—For Layer 3 VPN routes learned from BGP. This table stores routes learned from other PE routers. Routes in this table are copied into a Layer 3 VRF when there is a matching route table.
  • mpls.0—For MPLS label switching operations. This table is used when the local device is a transit router.
  • iso.0—For IS-IS routes. When you are using IS-IS to support IP routing, this table contains only the local device’s network entity title (NET).
  • juniper_private—For Junos OS to communicate internally between the Routing Engine and PIC hardware.

Example: Creating Routing Tables

This example shows how to create a custom routing table.

Requirements

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

Overview

Creating routing tables is optional. You might have policy considerations that would lead you to create separate routing tables to manage the propagation of routing information. This capability is rarely used, but it is demonstrated here for completeness.

If you do not create any routing tables, Junos OS uses its default routing tables.

Note: If you want to add static, aggregate, generated, or martian routes only to the default IPv4 unicast routing table (inet.0), you do not have to create any routing tables because, by default, these routes are added to inet.0. You can add these routes by including the static, aggregate, generate, and martians statements.

To explicitly create a routing table, include the rib statement and child statements under the rib statement.

The routing table name, routing-table-name, includes the protocol family, optionally followed by a period and a number. The protocol family can be inet for the IPv4 family, inet6 for the IPv6 family, or iso for the International Standards Organization (ISO) protocol family. The number represents the routing instance. The first instance is 0.

This example shows how to configure a custom IPv4 routing table called inet.14. The example also shows how to populate the routing table with a single static route.

Note: On EX Series switches, only dynamically learned routes can be imported from one routing table group to another.

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.

set routing-options rib inet.14 static route 10.2.0.0/16 discard

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 create a routing table:

  1. Configure the routing table.
    [edit routing-options]user@host# set rib inet.14 static route 10.2.0.0/16 discard
  2. If you are done configuring the device, commit the configuration.
    [edit]user@host# commit

Results

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

user@host# show routing-options
rib inet.14 {static {route 10.2.0.0/16 discard;}}

Verification

Confirm that the configuration is working properly.

Checking the Routing Table

Purpose

Make sure that the static route appears in the custom routing table.

Action

user@host> show route table inet.14
inet.14: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden)
Restart Complete
+ = Active Route, - = Last Active, * = Both

10.2.0.0/16        *[Static/5] 00:00:09
                      Discard

Meaning

The static route is in the custom routing table.

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

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

Device B

set interfaces fe-1/2/0 unit 3 description B->Aset interfaces fe-1/2/0 unit 3 family inet address 10.0.2.1/30set 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.
    [edit routing-instances]user@A# set vpna instance-type virtual-router
  2. 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
  3. Configure one or more static routes.
    [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 the direct and local routes to match against.

    [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.

    [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.

    [edit routing-options]user@A# set rib-groups group1 import-rib inet.0
  7. Configure the secondary routing table for group1.
    [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.
    [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.
    [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
  2. 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.

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;}}}
user@A# show routing-instances
vpna {instance-type virtual-router;}
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 ];}}
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
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.

Example: Exporting Specific Routes from One Routing Table Into Another Routing Table

This example shows how to duplicate specific routes from one routing table into another routing table within the same routing instance.

Requirements

No special configuration beyond device initialization is required before configuring this example.

Overview

This example uses the auto-export statement and the rib-group statement to accomplish the goal of exporting specific routes from one routing table to another.

Consider the following points:

  • When auto-export is configured in a routing instance, the vrf-import and vrf-export policies are examined. Based on the route target and community information in the policies, the auto-export function performs route leaking among the local routing instance inet.0 tables.
  • You can use the rib-group statement if it is necessary to import routes into tables other than instance.inet.0. If a RIB group is used, the RIB group's export-rib and import-policy statements are not used. Only the import-rib statement is used. To use a RIB group with auto-export, the routing instance should specify explicit vrf-import and vrf-export policies. The vrf-import and vrf-export policies can be extended to contain additional terms to filter routes as needed for the RIB group.

In this example, access-internal routes are added into the vpna.inet.0 routing table. The access-internal routes are also duplicated into the vpna.inet.2 routing table.

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.

set interfaces fe-1/3/1 vlan-taggingset interfaces fe-1/3/1 unit 0 vlan-id 512set interfaces fe-1/3/1 unit 0 family inet address 10.168.100.3/24set interfaces lo0 unit 0 family inet address 192.168.3.3/32set routing-options rib-groups rib-group-vpna-access-internal import-rib vpna.inet.2set routing-options autonomous-system 63000set policy-options policy-statement vpna-export term a from protocol bgpset policy-options policy-statement vpna-export term a then community add vpna-commset policy-options policy-statement vpna-export term a then acceptset policy-options policy-statement vpna-export term b from protocol access-internalset policy-options policy-statement vpna-export term b then acceptset policy-options policy-statement vpna-export term c then rejectset policy-options policy-statement vpna-import term a from protocol bgpset policy-options policy-statement vpna-import term a from community vpna-commset policy-options policy-statement vpna-import term a then acceptset policy-options policy-statement vpna-import term b from instance vpnaset policy-options policy-statement vpna-import term b from protocol access-internalset policy-options policy-statement vpna-import term b then acceptset policy-options policy-statement vpna-import term c then rejectset policy-options community vpna-comm members target:63000:100set routing-instances vpna instance-type vrfset routing-instances vpna interface fe-1/3/1.1set routing-instances vpna route-distinguisher 100:1set routing-instances vpna vrf-import vpna-importset routing-instances vpna vrf-export vpna-exportset routing-instances vpna routing-options auto-export family inet unicast rib-group rib-group-vpna-access-internalset routing-instances vpna protocols bgp group bgp-vpna type externalset routing-instances vpna protocols bgp group bgp-vpna family inet multicastset routing-instances vpna protocols bgp group bgp-vpna peer-as 100set routing-instances vpna protocols bgp group bgp-vpna neighbor 10.0.0.10

Configuring Specific Route Export Between Routing Tables

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 configure the device:

  1. Configure the interfaces.
    [edit interfaces fe-1/3/1]user@host# set vlan-tagginguser@host# set unit 0 vlan-id 512user@host# set unit 0 family inet address 10.168.100.3/24[edit interfaces lo0 unit 0]user@host# set family inet address 192.168.3.3/32
  2. Configure the routing policy that specifies particular routes for import into vpna.inet.0 and export from vpna.inet.0.
    [edit policy-options policy-statement vpna-export]user@host# set term a from protocol bgpuser@host# set term a then community add vpna-commuser@host# set term a then acceptuser@host# set term b from protocol access-internaluser@host# set term b then acceptuser@host# set term c then reject[edit policy-options policy-statement vpna-import]user@host# set term a from protocol bgpuser@host# set term a from community vpna-commuser@host# set term a then acceptuser@host# set term b from instance vpnauser@host# set term b from protocol access-internaluser@host# set term b then acceptuser@host# set term c then reject[edit policy-options]user@host# set community vpna-comm members target:63000:100
  3. Configure the routing instance.
    [edit routing-instances vpna]user@host# set instance-type vrfuser@host# set interface fe-1/3/1.1user@host# set route-distinguisher 100:1user@host# set vrf-import vpna-importuser@host# set vrf-export vpna-export

    The vrf-import and vrf-export statements are used to apply the vpna-import and vpna-export routing policies configured in 2.

  4. Configure the RIB group, and import routes into the vpna.inet.2 routing table.
    [edit routing-options]user@host# set rib-groups rib-group-vpna-access-internal import-rib vpna.inet.2
  5. Configure the auto-export statement to enable the routes to be exported from one routing table into another.
    [edit routing-options]user@host# set auto-export family inet unicast rib-group rib-group-vpna-access-internal
  6. Configure BGP.
    [edit routing-instances vpna protocols bgp group bgp-vpna]user@host# set type externaluser@host# set family inet multicastuser@host# set peer-as 100user@host# set neighbor 100.0.0.10
  7. Configure the autonomous system (AS) number.
    [edit routing-options]user@host# set autonomous-system 63000

Results

From configuration mode, confirm your configuration by entering the show interfaces, show policy-options, show routing-options, and show routing-instances commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

user@host# show interfaces
fe-1/3/1 {vlan-tagging;unit 0 {vlan-id 512;family inet {address 10.168.100.3/24;}}}
lo0 {unit 0 {family inet {address 192.168.3.3/32;}}}
user@host# show policy-options
policy-statement vpna-export {term a {from {protocol bgp;}then {community add vpna-comm;accept;}}term b {from protocol access-internal;then accept;}term c {then reject;}}
policy-statement vpna-import {term a {from {protocol bgp;community vpna-comm;}then accept;}term b {from {instance vpna;protocol access-internal;}then accept;}term c {then reject;}}
community vpna-comm members target:63000:100;
user@host# show routing-options
rib-groups {rib-group-vpna-access-internal {import-rib vpna.inet.2;}}
autonomous-system 63000;
user@host# show routing-instances
vpna {instance-type vrf;interface fe-1/3/1.1;route-distinguisher 100:1;vrf-import vpna-import;vrf-export vpna-export;routing-options {auto-export {family inet {unicast {rib-group rib-group-vpna-access-internal;}}}}protocols {bgp {group bgp-vpna {type external;family inet {multicast;}peer-as 100;neighbor 100.0.0.10;}}}}

If you are done configuring the device, enter commit from configuration mode.

Verification

Confirm that the configuration is working properly by running the show table route vpna.inet.0 and show route table vpna.inet.2 commands.

Published: 2013-02-04