[Contents] [Prev] [Next] [Index] [Report an Error]

# OSPF and BGP/MPLS VPNs

Before reading this section, we recommend you be thoroughly familiar with OSPF. For detailed information about that protocol, see JUNOSe IP, IPv6, and IGP Configuration Guide.

You can use BGP/MPLS VPNs to connect OSPF domains without creating OSPF adjacencies between the domains. The BGP/MPLS VPN backbone acts as either an OSPF backbone (area 0) or an OSPF area above the backbone.

In this topology, OSPF is the routing protocol between the CE router and the PE router. This OSPF link can be configured in area 0 or any other OSPF area. However, if the customer site has any connections to area 0, then at least one OSPF router configured on a CE router must have an area 0 link to a PE site. In this case, the BGP/MPLS VPN acts as if it is in an area above the OSPF backbone area. When the PE-CE link is in a nonbackbone area, the BGP/MPLS VPN acts as an OSPF backbone.

In either case, the OSPF router configured as a PE router in the BGP/MPLS VPN is always treated as an area border router (ABR) and functions as an area 0 router so that it can distribute interarea routes to the CE router. The BGP/MPLS VPN distributes both interarea and intra-area routes between PE routers as interarea, type 3 summary routes.

## Distributing OSPF Routes from CE Router to PE Router

You configure OSPF in the VRF associated with the VPN and associate the interface connected to the CE router with the VRF. OSPF routes can then propagate from a CE router to a PE router when an OSPF adjacency has formed between the two routers. OSPF adds routes to the VRF’s forwarding table at the PE router side with routes learned from the CE router.

## Distributing Routes Between PE Routers

The OSPF routes in the VRF forwarding table are OSPF IPv4 routes, but BGP/MPLS VPNs distribute VPN-IPv4 routes by means of MP-BGP. You must configure the VRF to redistribute the OSPF routes into MP-BGP. MP-BGP converts each imported OSPF route to a VPN-IPv4 route, applies export policy to the route, and then propagates the route to a remote PE site by means of the MPLS/VPN backbone. At the destination PE router, MP-BGP places each route in the appropriate VRF forwarding table based on the import policy for each VRF and the route target associated with the route.

## Preserving OSPF Routing Information Across the MPLS/VPN Backbone

MP-BGP attaches two new extended community attributes to the routes redistributed from OSPF:

- OSPF domain identifier extended community attribute
- OSPF route type extended community attribute

MP-BGP uses these attributes and the MED to preserve OSPF routing information across the BGP/MPLS VPN backbone.

### OSPF Domain Identifier Attribute

The OSPF domain identifier attribute uniquely identifies the OSPF domain from which a route was redistributed into MP-BGP.

You must configure an OSPF domain ID for the VRFs on the PE router with the domain-id command. All VRFs that belong to a given OSPF domain must be configured with the same domain ID. If not configured, the domain ID defaults to zero. If you configure a value of zero, MP-BGP does not attach an OSPF domain identifier attribute.

If the OSPF domain ID for the destination PE router differs from the originating PE router, MP-BGP redistributes the route into OSPF as an OSPF type 5 external route.

### OSPF Route Type Attribute

The route type attribute carries the OSPF area ID and LSA type, as indicated in Table 65:

Table 65: Route Types and Route Origins

Type of Route | Origin of Route
--- | ---
1 – intra-area route | Type 1 LSA
2 – intra-area route | Type 2 LSA
3 – interarea summary route | Type 3 LSA
5 – external route (area ID = 0) | Type 5 LSA
7 – external route (area ID = 0) | Type 7 LSA

MP-BGP uses the route type conveyed by this extended community attribute to determine the best OSPF route when it installs the routes in the VRF forwarding table on the destination PE router.

## Distributing OSPF Routes from PE Router to CE Router

At the remote PE site, MP-BGP converts the OSPF routes to BGP VPN-IPv4 routes and sends them across the BGP/MPLS VPN backbone. At the destination PE router, MP-BGP must redistribute the BGP VPN-IPv4 routes back into OSPF IPv4 routes. The PE OSPF router becomes the originator of the routes, which are either type 5 external routes or type 3 internal routes. The PE router can announce the OSPF routes to the appropriate CE router through its directly connected PE-CE OSPF link.

If the route has a route type of inter or intra, it is redistributed as a type 3 summary interarea route and the destination PE router generates a type 3 LSA for it.

A route is redistributed as an external route if the route:

- Originates in an OSPF domain that is different from that of the destination PE router.
- Has a route type of 5 or 7, both of which indicate an external route.

In the first case, the PE router advertises the route as an external type 2 route. In the second case, the PE router advertises the route as an external type 2 route if the least-significant bit is set in the option byte in the route type extended community attribute; otherwise the PE router advertises the route as external type 1 route.

## Preventing Routing Loops

PE routes disregard OSPF routes received from a CE router if the routes are advertised by:

- A type 3 LSA with the most-significant bit set in the LSA options field.
- A type 5 LSA that has a tag value equal to the VPN route tag associated with the OSPF VRF on that PE router.

When the destination PE router originates a type 3 LSA learned from BGP to a CE router, the PE router sets the most-significant bit in the LSA options field to identify the LSA as being generated from a PE router. Doing this prevents the LSA from being passed back to the BGP/MPLS VPN through a different PE router.

When the destination PE router originates a type 5 LSA learned from BGP to a CE router, the PE router replaces the external route tag in the LSA with the VPN route tag. You configure the VPN route tag for the OPSF VRF on the PE router with the domain-tag command. The value of a VPN route tag must be unique within an OSPF domain, so that the same external route is not propagated back to the BGP/MPLS VPN backbone through another PE-CE link.

## Using Remote Neighbors to Configure OSPF Sham Links

When you employ OSPF as the PE-CE routing protocol in a BGP/MPLS VPN and also configure OSPF backdoor links between VPN sites outside the backbone, the backdoor links are always preferred over the backbone paths between the VPN links. OSPF sham links prevent this problem, and you can implement them with OSPF remote neighbors. Consider the topology shown in Figure 112.

Figure 112: OSPF Topology with Backdoor Link

The PE routers are each running a separate logical OSPF instance for each VRF. Each of these OSPF instances has adjacencies with their directly connected CE routers and exchanges LSAs with those CE routers. The OSPF routes that are learned from a directly connected CE router are installed into the IP routing table of the VRF associated with that CE router.

The OSPF routes in the VRF’s IP routing table are then redistributed into MP-BGP and advertised as VPNv4 routes to other PE routers. MP-BGP attaches extended communities to the advertised routes to carry OSPF-specific attributes such as the route type and the domain ID across the backbone.

At the remote PE router, the BGP routes are installed in the IP routing table of the VRF and then redistributed back into the logical OSPF instance for that VRF. The remote PE router uses the BGP extended communities to determine the type of LSA to send to CE routers.

As a result the intra-area OSPF routes in one VPN site appear as interarea OSPF routes at the remote VPN sites.

### OSPF Backdoor Links

OSPF backdoor links typically serve as backup paths, providing a way for traffic to flow from one VPN site to the other only if the path over the backbone is broken.

However, when the OSPF backdoor link connects two sites that are in the same OSPF area, the undesired result is that the path over the OSPF backdoor link is always preferred over the path over the backbone.

In Figure 112, the OSPF backdoor link connects customer site 4 to customer site 5 directly, without going through the backbone. OSPF uses the backdoor path for traffic flow between these two sites for the following reasons:

- At CE 4 and CE 5, the path over the OSPF backdoor link is an intra-area path, whereas the path over the backbone is an interarea path. OSPF always uses intra-area paths before interarea paths.
- At PE 2 and PE 3, the OSPF routes received from the respective directly connected CE routers have a better administrative distance than the IBGP routes received from the remote PE router. OSPF uses routes with better administrative distances.

### OSPF Sham Links

Figure 113 shows how you can use OSPF sham links to avoid the problem created by the intra-area backdoor link. The sham link is a logical intra-area link between VRF B on PE 2 and PE 3. OSPF creates an adjacency and exchanges LSAs across the sham link. As a result, OSPF sees both the path over the backdoor link and the path over the backbone as intra-area paths. OSPF then selects the best path based on the metrics of the links and selects the sham link path, ensuring that the backdoor link is not used.

| Note: If the VPN sites are not connected by an OSPF backdoor link or if the VPN sites are in different OSPF areas, the problem does not exist and you do not need to configure an OSPF sham link.

Figure 113: OSPF Sham Link

Use the remote-neighbor command to configure the OSPF sham link on both VRFs joined by the link. If a BGP route and an OSPF route to the same destination are both installed in the IP routing table, OSPF uses the OSPF route because it has a better administrative distance by definition.

If you redistribute OSPF routes into BGP in each VRF, you do not want the OSPF routes that point to sham links to be redistributed into BGP. If they were redistributed, multiple BGP routes for a single OSPF route would exist: one BGP route at each endpoint of a sham link.

Use the dont-install-routes command to prevent OSPF routes pointing to the sham link from being installed in the IP routing table of the VRF, and thus to prevent them from being redistributed into BGP. Forwarding still works using the MP-IBGP routes received from the remote PE router.

Use the ttl command to configure a TTL for the remote neighbor because the neighbor might be more than a single hop away. Use the update-source command to specify the loopback address used as the source address for the OSPF connection to the remote neighbor.

If you do not configure a sham link between each pair of PE routers for which a backdoor link exists, then you need to redistribute BGP routes back into OSPF.

For more information about OSPF remote neighbors, see Remote Neighbors in the JUNOSe IP, IPv6, and IGP Configuration Guide.

dont-install-routes

- Use to prevent any OSPF routes that point directly to the OSPF remote neighbor from being installed in the IP routing table of the VR or VRF in which OSPF is running.
- Using this command avoids having many BGP routes to the same prefix by preventing OSPF routes learned over the sham link from being redistributed back into BGP even when you have configured redistribution of OSPF routes into BGP.
- Example
  `
  host1:pe1(config-router-rn)#dont-install-routes
  `
- Use the no version to restore the default behavior, which installs these routes in the relevant IP routing table.
- See dont-install-routes.

remote-neighbor

- Use to configure an OSPF remote neighbor.
- Example
  `
  host1:pe1(config-router)#remote-neighbor 10.25.100.14 area 35672
  `
- Use the no version to remove the remote neighbor and any attributes configured for the remote neighbor.
- See remote-neighbor.

ttl

- Use to configure a hop count by setting the value of the time-to-live field used by packets sent to an OSPF remote neighbor.
- Specify a value in the range 1–255 seconds; the default value is 1 second.
- Example
  `
  host1:pe1(config-router-rn)#ttl 35
  `
- Use the no version to restore the default value, 1 second.
- See ttl.

update-source

- Use to specify the loopback interface whose local IP address is used as the source address for the OSPF connection to a remote neighbor.
- Example
  `
  host1:pe1(config-router-rn)#update-source loopback 1
  `
- Use the no version to delete the source address from the connection to the remote neighbor.
- See update-source.

## Configuration Tasks

At a minimum, perform the following tasks on each PE router to configure them for OSPF. For other OSPF configuration tasks, see OSPF Configuration Tasks in the JUNOSe IP, IPv6, and IGP Configuration Guide.

1. Create the VRF.
   `
   host1(config)#ip vrf ospf2
   Proceed with new VRF creation? [confirm]
   host1(config-vrf)#rd 100:85
   host1(config-vrf)#exit
   `
2. Start OSPF on the VRF, either from the parent VR or directly from the VRF.

   From the parent VR:

   `
   host1(config)#router ospf 5 vrf ospf2
   `

   From the VRF:

   `
   host1(config)#virtual-router :ospf2
   host1:default:ospf2(config)#router ospf 5
   `

   The command prompts in the remaining steps reflect using the latter method for starting OSPF.

3. Configure the OSPF domain ID.
   `
   host1:default:ospf2(config-router)#domain-id 45
   `
4. Configure the VPN route tag.
   `
   host1:default:ospf2(config-router)#domain-tag 1200
   `
5. Redistribute routes learned from other PE routers back into OSPF.
   `
   host1:default:ospf2(config-router)#redistribute bgp
   `
6. Create an address family in BGP.
   `
   host1:default(config)#router bgp 100
   host1:default(config-router)#address-family ipv4 unicast vrf ospf2
   `
7. Redistribute OSPF routes into BGP.
   `
   host1:default(config-router)#redistribute ospf
   `

domain-id

- Use to set the OSPF domain ID for an OSPF VRF on a PE router; the default value is zero.
- Use the same domain ID for all OSPF VRFs in a given OSPF domain.
- When the value is zero, MP-BGP does not attach an OSPF domain identifier attribute when it converts an OSPF route to an MP-BGP route to cross the BGP/MPLS VPN.
- Example
  `
  host1:default:ospf2(config-router)#domain-id 45
  `
- Use the no version to restore the default value.
- See domain-id.

domain-tag

- Use to set the VPN route tag for an OSPF VRF on a PE router.
- The default value is a 32-bit number based on the AS number of the BGP/MPLS VPN backbone, with the first 16 bits set to 1110 0000 0000 0000, followed by the 16 bits representing the AS number.
- Example
  `
  host1:default:ospf2(config-router)#domain-tag 1200
  `
- Use the no version to restore the default value.
- See domain-tag.

[Contents] [Prev] [Next] [Index] [Report an Error]