Two VRFs ("red" and "green") are defined. In the eBGP configuration, PE1 is defined in Local AS 1.
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").
device(config)# vlan 10 device(config-Vlan-10)# exit device(config)# vlan 20
device(config)# vlan 10 device(config-Vlan-10)# router-interface ve 10
device(config)# vrf green device(config-vrf-green)# exit
device(config)# vrf red device(config-vrf-red)# exit
device(config)# router bgp
device(config-bgp-router)# local-as 1
device(config-bgp-router)# address-family ipv4 unicast vrf green
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)# 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
device(config)# router ospf vrf green
device(config-ospf-router-vrf-green)# area 0
device(config-ospf-router-vrf-green)# redistribute bgp device(config-ospf-router-vrf-green)# exit device(config-ospf-router)# exit
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
device(config)# interface ethernet 0/1 device(conf-if-eth-0/1)# vrf forwarding green
device(conf-if-eth-0/1)# ip ospf area 0
device(conf-if-eth-0/1)# ip address 10.1.1.1/24
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
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
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