Multi-VRF with eBGP and OSPF: Configuring PE1

Two VRFs ("red" and "green") are defined. In the eBGP configuration, PE1 is defined in Local AS 1.

About this task

VRFs "green" and "red" are configured, and both have the same IP network address assigned (10.3.1.2/24). This is possible because each of the BGP VRF instances has its own BGP tables. This is also the same IP network address that will be assigned to VRFs "green" and "red" on PE2 within Local AS 2. Redistribution of OSPF routes from PE1‘s CE peers is enabled to all for their advertisement to PE2.

Both VRFs are configured in Area 0 and are directed to redistribute their routes to BGP. The physical interfaces to the CEs are assigned to the appropriate VRF and are configured with the same network address (10.1.1.1/24) and OSPF Area 0.

The virtual Interfaces (Ve 10 and Ve 20) are configured with the same network address (10.3.1.1/24) and for VRF forwarding in the appropriate VRF ("green" or "red").

Procedure

  1. In global configuration mode, create VLANs 10 and 20.
    device(config)# vlan 10
    device(config-Vlan-10)# exit
    device(config)# vlan 20
    
    
  2. From global configuration mode, enter interface subtype configuration mode, and then create a virtual Ethernet routing interface for the VLAN.
    device(config)# vlan 10
    device(config-Vlan-10)# router-interface ve 10
    
    
  3. Repeat the above steps as appropriate for remaining physical, VLAN, and virtual Ethernet interfaces.
  4. Create VRF "green".
    device(config)# vrf green
    device(config-vrf-green)# exit
     
    
    Repeat for every VRF instance. Use the address-family ipv6 unicast command for IPv6 addresses. Also, you can use the max-route command, which helps restrict the maximum number of routes per VRF.
  5. Configure VRF "red" and exit the VRF configuration.
    device(config)# vrf red 
    device(config-vrf-red)# exit 
    
  6. In global configuration mode, enable BGP routing and configure the following in this IPv4 example.
    1. Enable BGP routing.
      device(config)# router bgp 
      
    2. Assign a Local AS number.
      device(config-bgp-router)# local-as 1
      
    3. Enable IPv4 unicast address-family mode for VRF "green."
      device(config-bgp-router)# address-family ipv4 unicast vrf green
      
    4. Assign Remote AS 2 as a neighbor with the specified address.
      device(config-bgp-ipv4u-vrf)# neighbor 10.3.1.2 remote-as 2
      
    5. Assign the appropriate network.
      device(config-bgp-ipv4u-vrf)# network 10.3.1.0/24
      
    6. Redistribute the OSPF routes into BGP4, specifying the types of routes to be distributed, then exit the address family configuration.
      device(config-bgp-ipv4u-vrf)# redistribute ospf match internal
      device(config-bgp-ipv4u-vrf)# redistribute ospf match external1
      device(config-bgp-ipv4u-vrf)# redistribute ospf match external2
      device(config-bgp-ipv4u-vrf)# exit
      
  7. Repeat as above for VRF "red."
    device(config)# router bgp 
    device(config-bgp-router)# address-family ipv4 unicast vrf red
    device(config-bgp-ipv4u-vrf)# neighbor 10.3.1.2 remote-as 2
    device(config-bgp-ipv4u-vrf)# network 10.3.1.0/24
    device(config-bgp-ipv4u-vrf)# redistribute ospf match internal
    device(config-bgp-ipv4u-vrf)# redistribute ospf match external1
    device(config-bgp-ipv4u-vrf)# redistribute ospf match external2
    device(config-bgp-ipv4u-vrf)# exit
    device(config-bgp-router)# exit
  8. Enable OSPF routing for VRF "green" and configure the following.
    1. Enable OSPF.
      device(config)# router ospf vrf green
      
    2. Assign Area 0.
      device(config-ospf-router-vrf-green)# area 0
    3. Redistribute the OSPF routes into BGP4 and exit the VRF configuration.
      device(config-ospf-router-vrf-green)# redistribute bgp 
      device(config-ospf-router-vrf-green)# exit
      device(config-ospf-router)# exit 
  9. Repeat as above for VRF "red".
    device(config)# router ospf vrf red
    device(config-ospf-router-vrf-red)# area 0
    device(config-ospf-router-vrf-red)# redistribute bgp 
    device(config-ospf-router-vrf-red)# exit
  10. Configure the Ethernet interfaces as appropriate, as in the following example.
    1. Assign an interface to VRF instance "green" and enable forwarding.
      device(config)# interface ethernet 0/1
      device(conf-if-eth-0/1)# vrf forwarding green
      
    2. Assign Area 0.
      device(conf-if-eth-0/1)# ip ospf area 0
      
    3. Assign an IPv4 network.
      device(conf-if-eth-0/1)# ip address 10.1.1.1/24
      
    4. Repeat as above for another Ethernet interface and VRF "red" and exit the interface configuration.
      device(conf-if-eth-0/2)# interface ethernet 0/2 
      device(conf-if-eth-0/2)# vrf forwarding red
      device(conf-if-eth-0/2)# ip ospf area 0
      device(conf-if-eth-0/2)# ip address 10.1.1.1/24
      device(conf-if-eth-0/2)# exit
      
  11. Configure the VE interfaces for the appropriate VRF and network.
    1. Configure VE 10, corresponding to VLAN 10.
      device(config)# interface ve 10
      device(config-if-Ve-10)# vrf forwarding green
      device(config-if-Ve-10)# ip address 10.3.1.1/24
      device(config-if-Ve-10)# no shutdown
    2. Repeat the above for VE 20, corresponding to VLAN 20.
      device(config-ve-10)# interface ve 20
      device(config-if-Ve-20)# vrf forwarding red
      device(config-if-Ve-20)# ip address 10.3.1.1/24
      device(config-if-Ve-20)# no shutdown
      device(config-if-Ve-20# exit