Configuring interVRF route redistribution for OSPF

Use route redistribution so that a VRF interface can announce routes learned by other protocols, for example, OSPF or BGP. The switch supports interVRF route redistribution. Use a route policy to control the redistribution of routes.

You can also redistribute inter-VRF DvR routes to OSPF.

Before you begin

  • Enable OSPF globally.

  • Ensure that a route policy exists.

  • Ensure that the VRFs exist.

Note

Note

The route policies treat permit and deny rules differently for inbound and outbound traffic.

  • For an in-policy (RIP, BGP) or an accept policy (OSPF) using a route-map, if a particular route is not explicitly denied in the accept policy or in-policy with the route-map, then the route is implicitly allowed.

  • For an out-policy (RIP, BGP) or a redistribute policy (RIP, OSPF, BGP) using a route-map, even if a particular route is not explicitly allowed in the redistribution policy or out-policy with the route-map, then the route is implicitly denied.

  • In order to permit or deny only explicit routes, configure a policy with additional sequences, where, the last sequence permits all routes that are not explicitly permitted or denied.

Procedure

  1. Enter VRF Router Configuration mode for a specific VRF context:

    enable

    configure terminal

    router vrf WORD<1-16>

  2. Create the redistribution instance:

    ip ospf redistribute <bgp|direct|isis|ospf|rip|static|dvr>

  3. Apply a route policy if required:

    ip ospf redistribute <bgp|direct|isis|ospf|rip|static|dvr> route-map WORD<0-64> [vrf-src WORD<1-16>]

  4. Configure other parameters, as required.
  5. Enable the redistribution:

    ip ospf redistribute <bgp|direct|isis|ospf|rip|static|dvr> enable [vrf-src WORD<1-16>]

  6. Ensure that the configuration is correct:

    show ip ospf redistribute [vrf WORD<1-16>] [vrfids WORD<0-512>]

  7. Exit to Global Configuration mode:

    exit

  8. Apply the redistribution:

    ip ospf apply redistribute <bgp|direct|isis|ospf|rip|static|dvr> [vrf WORD<1-16>] [vrf-src WORD<1-16>]

Example

Example 1:

Create the redistribution instance, apply a route policy, enable the redistribution, and apply the redistribution.

Switch:1>enable
Switch:1#configure terminal
Switch:1(config)#router vrf red
Switch:1(router-vrf)#ip ospf redistribute isis
Switch:1(router-vrf)#ip ospf redistribute isis route-map test2
Switch:1(router-vrf)#ip ospf redistribute isis enable
Switch:1(router-vrf)#exit
Switch:1(config)#ip ospf apply redistribute isis

Example 2:

This example demonstrates redistribution of inter-VRF routes (both direct and DvR routes) to OSPF, with a route policy configured.

Redistribute inter-VRF DvR routes between VRFs (with VRF IDs 10 and 30), to OSPF.

Switch:1>enable
Switch:1#configure terminal
Switch:1(config)#router vrf 10
Switch:1(router-vrf)#ip prefix-list "test10" 192.0.2.0/24  ge 25 le 32
Switch:1(router-vrf)#route-map "test10" 1
Switch:1(router-vrf)#permit
Switch:1(router-vrf)#enable
Switch:1(router-vrf)#match network "test10"
Switch:1(router-vrf)#set metric 99
Switch:1(router-vrf)#exit


Switch:1(config)#router vrf 30
Switch:1(router-vrf)#ip ospf redistribute direct vrf-src 10
Switch:1(router-vrf)#ip ospf redistribute direct enable vrf-src 10
Switch:1(router-vrf)#ip ospf redistribute dvr vrf-src 10
Switch:1(router-vrf)#ip ospf redistribute dvr route-map "test10" vrf-src 10
Switch:1(router-vrf)#ip ospf redistribute dvr enable vrf-src 10
Switch:1(router-vrf)#exit


Switch:1(config)#ip ospf apply redistribute direct vrf 30 vrf-src 10
Switch:1(config)#ip ospf apply redistribute dvr vrf 30 vrf-src 10

Variable definitions

The following table defines parameters for the ip ospf redistribute command.

Variable

Value

enable

Enables the OSPF route redistribution instance.

metric <0–65535>

Configures the metric to apply to redistributed routes.

metric-type <type1|type2>

Specifies a metric. For metric type 1, the cost of the external routes is equal to the sum of all internal costs and the external cost. For metric type 2, the cost of the external routes is equal to the external cost alone.

route-map WORD<0-64>

Configures the route policy to apply to redistributed routes.

subnets <allow|suppress>

Allows or suppresses external subnet route advertisements when routes are redistributed into an OSPF domain.

vrf-src WORD<1-16>

Specifies the optional source VRF instance. You can use this variable with the other command variables.

<bgp|direct|isis|ospf|rip|static|dvr>

Specifies the type of routes to redistribute (the protocol source). Valid options are bgp, isis, direct, rip, ospf, static or dvr.

The following table defines parameters for the ip ospf apply redistribute command.

Variable

Value

vrf WORD<1-16>

Specifies the VRF instance.

vrf-src WORD<1-16>

Specifies the source VRF instance. You do not need to configure this parameter for redistribution within the same VRF.

WORD<0–32>

Specifies the type of routes to redistribute (the protocol source). Valid options are bgp, isis, direct, rip, ospf, or static.