Configuring OSPF Routing Instances
Understanding OSPF Routing Instances
A routing instance is a collection of routing tables, interfaces, and routing protocol parameters. The set of interfaces belongs to the routing tables, and the OSPF routing protocol parameters control the information in the routing tables. You can further install routes learned from OSPF routing instances into routing tables in the OSPF routing table group.
The default routing instance, primary, refers to the main inet.0 routing table. The primary routing instance is reserved and cannot be specified as a routing instance.
You can configure the following types of routing instances:
OSPFv2—Forwarding, Layer 2 virtual private network (VPN), nonforwarding, VPN routing and forwarding (VRF), virtual router, and virtual private LAN service (VPLS).
OSPFv3—Nonforwarding, VRF, and virtual router.
Each routing instance has a unique name and a corresponding IP unicast table. For example, if you configure a routing instance with the name my-instance, the corresponding IP unicast table is my-instance.inet.0. All routes for my-instance are installed into my-instance.inet.0.
You can also configure multiple routing instances of OSPF.
- Minimum Routing-Instance Configuration for OSPFv2
- Minimum Routing-Instance Configuration for OSPFv3
- Multiple Routing Instances of OSPF
Minimum Routing-Instance Configuration for OSPFv2
To configure a routing instance for OSPFv2, you must include at least the following statements in the configuration:
[edit] routing-instances { routing-instance-name { interface interface-name; instance-type (forwarding | l2vpn | no-forwarding | virtual-router | vpls | vrf); route-distinguisher (as-number:number | ip-address:number); vrf-import [ policy-names ]; vrf-export [ policy-names ]; protocols { ospf { ... ospf-configuration ... } } } }
You can configure a logical interface under only one routing instance.
Minimum Routing-Instance Configuration for OSPFv3
To configure a routing instance for OSPFv3, you must include at least the following statements in the configuration:
[edit] routing-instances { routing-instance-name { interface interface-name; instance-type (no-forwarding | virtual-router | vrf); vrf-import [ policy-names ]; vrf-export [ policy-names ]; protocols { ospf3 { ... ospf3-configuration ... } } } }
You can configure a logical interface under only one routing instance.
Multiple Routing Instances of OSPF
Multiple instances of OSPF are used for Layer 3 VPN implementations. The multiple instances of OSPF keep routing information for different VPNs separate. The VRF instance advertises routes from the customer edge (CE) router to the provider edge (PE) router and advertises routes from the PE router to the CE router. Each VPN receives only routing information belonging to that VPN.
You can create multiple instances of OSPF by including statements at the following hierarchy levels:
[edit routing-instances routing-instance-name (ospf | ospf3)]
[edit logical-systems logical-system-name routing-instances routing-instance-name (ospf | ospf3)]
Installing Routes from OSPF Routing Instances into the OSPF Routing Table Group
To install routes learned from OSPF routing instances into routing
tables in the OSPF routing table group, include the rib-group
statement:
rib-group group-name;
For a list of hierarchy levels at which you can include this statement, see the statement summary section for this statement.
Example: Configuring Multiple Routing Instances of OSPF
This example shows how to configure multiple routing instances of OSPF.
Requirements
Before you begin:
Configure the device interfaces. See the Junos OS Network Interfaces Library for Routing Devices.
Configure the router identifiers for the devices in your OSPF network. See Example: Configuring an OSPF Router Identifier.
Control OSPF designated router election. See Example: Controlling OSPF Designated Router Election
Overview
When you configure multiple routing instances of OSPF, we recommend that you perform the following tasks:
Configure the OSPFv2 or OSPFv3 default instance at the
[edit protocols (ospf | ospf3)]
and[edit logical-systems logical-system-name protocols (ospf | ospf3)]
hierarchy levels with the statements needed for your network so that routes are installed in inet.0 and in the forwarding table. Make sure to include the routing table group.Configure an OSPFv2 or OSPFv3 routing instance for each additional OSPFv2 or OSPFv3 routing entity, configuring the following:
Interfaces
Routing options
OSPF protocol statements belonging to that entity
Routing table group
Configure a routing table group to install routes from the default route table, inet.0, into a routing instance’s route table.
Configure a routing table group to install routes from a routing instance into the default route table, inet.0.
Note:Nonforwarding routing instances do not have forwarding tables that correspond to their routing tables.
Create an export policy to export routes with a specific tag, and use that tag to export routes back into the instances. For more information, see the Routing Policies, Firewall Filters, and Traffic Policers User Guide.
Figure 1 shows how you can use multiple routing instances of OSPFv2 or OSPFv3 to segregate prefixes within a large network. The network consists of three administrative entities: voice-policy, other-policy, and the default routing instance. Each entity is composed of several geographically separate sites that are connected by the backbone and managed by the backbone entity.
Topology
Sites A and D belong to the voice-policy routing instance. Sites B and C belong to the other-policy instance. Device 1 and Device 3 at the edge of the backbone connect the routing instances. Each runs a separate OSPF or OSPFv3 instance (one per entity).
Device 1 runs three OSPFv2 or OSPFv3 instances: one each for Site A (voice-policy), Site C (other-policy), and the backbone, otherwise known as the default instance. Device 3 also runs three OSPFv2 or OSPFv3 instances: one each for Site B (other-policy), Site D (voice-policy), and the backbone (default instance).
When Device 1 runs the OSPFv2 or OSPFv3 instances, the following occur:
Routes from the default instance routing table are placed in the voice-policy and other-policy instance routing tables.
Routes from the voice-policy routing instance are placed in the default instance routing table.
Routes from the other-policy routing instance are placed in the default instance routing table.
Routes from the voice-policy routing instance do not enter the other-policy instance routing table.
Routes from the other-policy routing instance do not enter the voice-policy instance routing table.
Configuration
Procedure
CLI Quick Configuration
To quickly configure multiple routing instances
of OSPF, copy the following commands, paste them into a text file,
remove any line breaks, change any details necessary to match your
network configuration, copy and paste the commands into the CLI at
the [edit] hierarchy level, and then enter commit
from
configuration mode.
Configuration on Device 1:
[edit] set routing-instances voice-policy interface so-2/2/2 set routing-instances voice-policy protocols ospf rib-group voice-to-inet area 0.0.0.0 interface so-2/2/2 set routing-instances other-policy interface so-4/2/2 set routing-instances other-policy protocols ospf rib-group other-to-inet area 0.0.0.0 interface so-4/2/2 set routing-options rib-groups inet-to-voice-and-other import-rib [ inet.0 voice-policy.inet.0 other-policy.inet.0 ] set routing-options rib-groups voice-to-inet import-rib [ voice-policy.inet.0 inet.0 ] set routing-options rib-groups other-to-inet import-rib [ other-policy.inet.0 inet.0 ] set protocols ospf rib-group inet-to-voice-and-other area 0.0.0.0 interface so-2/2/2 set protocols ospf rib-group inet-to-voice-and-other area 0.0.0.0 interface so-4/2/2
Configuration on Device 3:
[edit] set routing-instances voice-policy interface so-3/2/2 set routing-instances voice-policy protocols ospf rib-group voice-to-inet area 0.0.0.0 interface so-3/2/2 set routing-instances other-policy interface so-5/2/2 set routing-instances other-policy protocols ospf rib-group other-to-inet area 0.0.0.0 interface so-5/2/2 set routing-options rib-groups inet-to-voice-and-other import-rib [ inet.0 voice-policy.inet.0 other-policy.inet.0 ] set routing-options rib-groups voice-to-inet import-rib [ voice-policy.inet.0 inet.0 ] set routing-options rib-groups other-to-inet import-rib [ other-policy.inet.0 inet.0 ] set protocols ospf rib-group inet-to-voice-and-other area 0.0.0.0 interface so-3/2/2 set protocols ospf rib-group inet-to-voice-and-other area 0.0.0.0 interface so-5/2/2
Step-by-Step Procedure
To configure multiple routing instances of OSPF:
Configure the routing instances for voice-policy and other-policy.
Note:To specify OSPFv3, include the
ospf3
statement at the[edit routing-instances protocols]
hierarchy level.[edit] user@D1# set routing-instances voice-policy interface so-2/2/2 user@D1# set routing-instances voice-policy protocols ospf rib-group voice-to-inet area 0.0.0.0 interface so-2/2/2 user@D1# set routing-instances other-policy interface so-4/2/2 user@D1# set routing-instances other-policy protocols ospf rib-group other-to-inet area 0.0.0.0 interface so-4/2/2
[edit] user@D3# set routing-instances voice-policy interface so-3/2/2 user@D3# set routing-instances voice-policy protocols ospf rib-group voice-to-inet area 0.0.0.0 interface so-3/2/2 user@D3#set routing-instances other-policy interface so-5/2/2 user@D3# set routing-instances other-policy protocols ospf rib-group other-to-inet area 0.0.0.0 interface so-5/2/2
Configure the routing table group inet-to-voice-and-other to take routes from inet.0 (default routing table) and place them in the voice-policy.inet.0 and other-policy.inet.0 routing tables.
[edit] user@D1# set routing-options rib-groups inet-to-voice-and-other import-rib [ inet.0 voice-policy.inet.0 other-policy.inet.0 ]
[edit] user@D3# set routing-options rib-groups inet-to-voice-and-other import-rib [ inet.0 voice-policy.inet.0 other-policy.inet.0 ]
Configure the routing table group voice-to-inet to take routes from voice-policy.inet.0 and place them in the inet.0 default routing table.
[edit] user@D1# set routing-options rib-groups voice-to-inet import-rib [ voice-policy.inet.0 inet.0 ]
[edit] user@D3# set routing-options rib-groups voice-to-inet import-rib [ voice-policy.inet.0 inet.0 ]
Configure the routing table group other-to-inet to take routes from other-policy.inet.0 and place them in the inet.0 default routing table.
[edit] user@D1# set routing-options rib-groups other-to-inet import-rib [ other-policy.inet.0 inet.0 ]
[edit] user@D3# set routing-options rib-groups other-to-inet import-rib [ other-policy.inet.0 inet.0 ]
Configure the default OSPF instance.
Note:To specify OSPFv3, include the
ospf3
statement at the[edit routing-instances protocols]
hierarchy level.[edit] user@D1# set protocols ospf rib-group inet-to-voice-and-other area 0.0.0.0 interface so-2/2/2 user@D1# set protocols ospf rib-group inet-to-voice-and-other area 0.0.0.0 interface so-4/2/2
[edit] user@D3# set protocols ospf rib-group inet-to-voice-and-other area 0.0.0.0 interface so-3/2/2 user@D3# set protocols ospf rib-group inet-to-voice-and-other area 0.0.0.0 interface so-5/2/2
If you are done configuring the device, commit the configuration.
[edit] user@host# commit
Results
Confirm your configuration by entering the show
routing-instances
, show routing-options
, and show protocols ospf
commands. If the output does not display
the intended configuration, repeat the instructions in this example
to correct the configuration.
Configuration on Device 1:
user@D1# show routing-instances voice-policy { interface so-2/2/2.0; protocols { ospf { rib-group voice-to-inet; area 0.0.0.0 { interface so-2/2/2.0; } } } } other-policy { interface so-4/2/2.0; protocols { ospf { rib-group other-to-inet; area 0.0.0.0 { interface so-4/2/2.0; } } } }
user@D1# show routing-options rib-groups { inet-to-voice-and-other { import-rib [ inet.0 voice-policy.inet.0 other-policy.inet.0 ]; } voice-to-inet { import-rib [ voice-policy.inet.0 inet.0 ]; } other-to-inet { import-rib [ other-policy.inet.0 inet.0 ]; } }
user@D1# show protocols ospf rib-group inet-to-voice-and-other; area 0.0.0.0 { interface so-2/2/2.0; interface so-4/2/2.0; }
Configuration on Device 3:
user@D3# show routing-instances voice-policy { interface so-3/2/2.0; protocols { ospf { rib-group voice-to-inet; area 0.0.0.0 { interface so-3/2/2.0; } } } } other-policy { interface so-5/2/2.0; protocols { ospf { rib-group other-to-inet; area 0.0.0.0 { interface so-5/2/2.0; } } } }
user@D3# show routing-options rib-groups { inet-to-voice-and-other { import-rib [ inet.0 voice-policy.inet.0 other-policy.inet.0 ]; } voice-to-inet { import-rib [ voice-policy.inet.0 inet.0 ]; } other-to-inet { import-rib [ other-policy.inet.0 inet.0 ]; } }
user@D3# show protocols ospf rib-group inet-to-voice-and-other; area 0.0.0.0 { interface so-3/2/2.0; interface so-5/2/2.0; }
To confirm your OSPFv3 configuration, enter the show routing-instances
, show routing-options
, and show protocols ospf3
commands.