Networking-Blog

My WordPress Blog

F-VRF IPsec

VRF’s essentially provide path isolation functions. They provide separate routing tables,
forwarding tables, associated policies and in some cases management. This is network
virtualisation “lite”. Also, VRF’s do not rely on MPLS (which is a massive misconception).
It’s just a container. Not a protocol . MPLS can be used to provide transport in and out of said
container, but the two are not interdependent.

 Did you know you can configure a Cisco IOS based router to perform highly available
(active/standby) IPSec terminating within a VRF.
 IPSec terminating within a VRF.
It can save your company money and can reduce device
count. The concept is called
“FVRF IPsec”, or in English, Front door VRF IPSec.

 

Figure 1.0 shows a typical scenario (below)

 

 

This scenario is common amongst service-providers and geographic separation is normally
sold as part of the solution. Under the geographic separation scenario, EoMPLS would
normally be used to link the two IP networks together which would be now be apart.
L2 connectivity is a requirement for HSRP to function and EoMPLS satisfies this.
Specific routes can be added on to each ‘edge x’ device within the VRF to reach the
remote IPSec  endpoint .I feel I need to clarify what the IP transit situation would be
under geographic separation and my answer to that is it depends. As long as the
L2 pseudolink or LAN connection linked the two edge routers together,  it doesn’t matter
which ingress path is taken via packets.  This is termed ‘hot potato’ routing for those
who are uninitiated.

Presuming each node has IP transit to and from the internet, once HSRP has converged
and each node now is aware of its responsibilities, IKE and IPSec can now go through
their phases and agree terms.  Presuming again that all other configuration is correct,
which includes filters for identifying traffic to be encrypted etc, at this point we should
have a working topology.

It’s wise to lock down each FVRF ‘edge x’ interface using access-lists. In some environments
I’ve worked on, internet breakout ingresses and egresses a different part of the topology
and the ‘edge x’ devices have been shared between multiple customers. In these scenarios,
you can lock the FVRF interfaces down to the remote peer for IKE , IPSec and ICMP.

It will take time for IPSec to renegotiate and depending on the exact
failure scenario, routing may take time to converge.

Please find a config snippet below for one of the ‘edge x’ devices. 

Please note the interface on the 10.10.10.0/24 LAN is the interface I refer to below
called <FVRF_INTERFACE>.

 

ip sla 1
icmp-echo <IP Address of IPSec Endpoint> source-interface <FVRF Interface>
vrf <CustomerX>
timeout 15000
frequency 15
ip sla schedule 1 life forever start-time now
!
track 1 ip sla 1
!
crypto keyring CUST_X vrf custx
pre-shared-key address <IP Address of IPSec Endpoint> key <KEYSTRING>
!
crypto isakmp policy 1
encr aes
hash md5
authentication pre-share
group 2
lifetime 3600
!
crypto isakmp policy 10
encr 3des
hash md5
authentication pre-share
!
crypto isakmp profile CUST_X
vrf custx
keyring CUST_X
match identity address <IP Address and Mask for IPSec Endpoint> custx
!
!
crypto ipsec transform-set CUST_X esp-aes esp-md5-hmac
mode transport
!
crypto map CUST_X 10 ipsec-isakmp
set peer <IP Address for IPSec Endpoint>
set transform-set CUST_X
set isakmp-profile CUST_X
match address CUST_X
!
interface <FVRF_INTERFACE>
description **<INSERT_DESCRIPTION_HERE>**
encapsulation dot1Q xxx
ip vrf forwarding custx
ip address <FVRF_ADDRESS> <FVRF_MASK>
ip access-group CUST_X_FILTER_IN in
ip access-group CUST_X_FILTER_OUT out
no ip redirects
no ip unreachables
ip mtu 1500
standby 1 ip <HSRP_ADDRESS>
standby 1 priority 120
standby 1 preempt
standby 1 name HSRPCUSTX
standby 1 track 1 decrement 30
crypto map CUST_X redundancy HSRPCUSTX
!
!
ip route vrf custx <REMOTE_DEST> <MASK> 10.10.10.254 track 1
!
!
ip access-list extended CUST_X_FILTER_IN
permit ip <FVRF_ADDRESS><FVRF_MASK> host 224.0.0.2 !(HSRP)
permit esp host <REMOTE_IPSEC><FVRF_ADDRESS>
permit udp host <REMOTE_IPSEC><FVRF_ADDRESS> eq 500
deny   ip any any log
!
ip access-list extended CUST_X_FILTER_OUT
permit ip <FVRF_ADDRESS> host 224.0.0.2
permit esp <FVRF_ADDRESS> host <REMOTE_IPSEC>
permit udp <FVRF_ADDRESS> host <REMOTE_IPSEC> eq 500
deny   ip any any log

Understanding MPLS IPVPN

Core Issue

A Virtual Private Network (VPN) is as a network in which connectivity a customer’s
multiple sites is deployed on a shared infrastructure with the same access or security
policies as in a private network. VPNs allow multiple customers to share a common

public infrastructure similar to the Internet, with the same level of security as in a
private network. This results in cost savings and flexibility in connectivity options for
the customer. VPNs can be implemented by using either an overlay or a peer-to-peer
model. Each model has its own advantages and disadvantages.

The Multiprotocol Label Switching (MPLS) VPN architecture provides the service
providers with a peer-to-peer model which combines the best features of overlay and
peer-to-peer models. The MPLS VPN terminology divides the overall network into a
customer controlled part (C-network) and a provider controlled part (P network). The
contiguous portions of the C-network are called sites and are linked with the P
network
through Customer Edge (CE) routers. The CE routers are connected to the
Provider Edge (PE) routers, which serve as the edge device of the P network. The core
devices, or the P-routers, in the P network provide the transit transport across the
service provider backbone. In MPLS VPN, PE routers participate in customer routing,
providing optimum routing between sites and easy provisioning of sites. It also allows
customers to use overlapping addresses. The PE routers contains separate set of routes
for each customer, which results in perfect isolation between them.

 

Resolution

The MPLS VPN architecture is designed to address these requirements:

The customer routers need not be MPLS-VPN aware.
The P routers should not carry customer routes (otherwise called as VPN routes) to
make the solution more scalable.

The PE routers should support MPLS VPN services.

 

These requirements are addressed in these ways:

The CE routers use static routing or run any standard IP routing protocol, such as Routing Information Protocol version 2 (RIPv2), Open Shortest Path First (OSPF) or Border Gateway Protocol (BGP) with the PE devices to exchange routing information.

The P routers do not carry VPN routes. They run Interior Gateway Protocol (IGP) with other P and PE devices to learn about the subnets within the P network and use MPLS for forwarding packets.

The PE routers learn about the VPN routes from CE routers through any of the above routing protocols. They provide isolation between different customers by installing these routes in separate routing tables called Virtual Routing and Forwarding (VRF) instances. The PE routers exchange these VPN routes with other PE devices using Multiprotocol BGP (MBGP) as the routing protocol. The PE routers also run an IGP with other P and PE devices in the P network and use MPLS for forwarding packets across the P network. The PE router still has a global routing table for forwarding packets to destinations in the P network.

Configuring MPLS VPN can be broken down into these sub-tasks:

 Configure an IGP and enable MPLS in the P network. Enable Cisco Express Forwarding (CEF) and MPLS on all the devices in the P network, and configure an IGP to exchange routes for networks available in the P network. These routes are stored in the global routing table on the PE devices and have a label associated with them. They are distributed using Label Distribution Protocol (LDP) or Tag Distribution Protocol (TDP).

Configure VRF on the PE devices. A VRF consists of an IP routing table, a derived CEF table, and a set of interfaces that use the forwarding table. There can be multiple VRFs on the same PE device. Sites that have identical routing requirements and are connected to the same PE router can use the same VRF. Each VRF should be configured with the Route Distinguisher (RD) and Route Target (RT) parameters.

Since the MPLS VPN architecture allows the customers to use overlapping IP addresses, the addresses from different customers must be distinguished when they are advertised across the P network using MBGP. RD is a 64-bit value, which is prefixed to the 32-bit Information Protocol version 4 (IPv4) routes. These are learned from the customer to make them a unique 96-bit address called a VPNv4 address, which is then advertised to other PE devices. Each VRF on the PE device must be assigned a unique value as an RD, and a VRF can have only one RD assigned.

The RT parameter indicates the VPN membership of a route. There can be complex VPN requirements where some customer sites could be part of a single VPN, but other sites of the same customer could be part of multiple or overlapping VPNs. Since the RD only makes the addresses unique and does not indicate VPN membership, the RT parameter is used for this purpose. RTs are represented using Extended BGP Community Attributes which are 64 bits long. Any number of RTs can be attached to a route to indicate membership in more than one VPN. RTs are attached to a route when they are converted from an IPv4 address to a VPNv4 address by the PE router. These RTs are called export RTs, and they are configured for each VRF on the PE device. When the VPNv4 routes are propagated to other PE devices, those routers should select the routes to be inserted into the appropriate VRF. This selection is based on import RTs, and it is configured for each VRF.

Configure MBGP between PE devices. While the VRFs provide the isolation between different customers, the routes in these routing tables need to be exchanged with other PE devices to enable data transfer between sites attached to different PE routers. A routing protocol which transports all the customer routes across the P network is needed. The P-routers should not know about the VPN routes to make it more scalable. This is one of the requirements to be addressed by the MPLS VPN architecture. Since the number of VPN routes can be large, BGP is the only protocol which provides the required scalability.

BGP is required in MPLS VPN setup to transport customer routes directly between PE routers and to use MPLS labels to exchange packets between PE routers. Since BGP was capable of carrying only traditional IPv4 prefixes, it has been enhanced to carry the 96-bit VPNv4 prefixes, along with extended community attributes like RTs. This enhanced version is called MBGP. Since the PE routers have multiple routing tables associated with different VRFs, the MPLS label called VPN label (carried in the MBGP update along with the prefix) is used for identifying the VRF that must be used while receiving packets to forward to the destination.

Configure the PE-CE routing protocol on PE and CE devices. Cisco devices support using either static routes or RIPv2, OSPF and BGP to exchange IPv4 routes between the PE and CE devices. These protocols are VRF aware which allow to run separate instances of the same protocol for each VRF on the PE device. The routes that are learned via the interface belonging to a particular VRF are populated in the routing table for that particular VRF and provide isolation.

Configure redistribution between PE-CE routing protocol and MBGP on the PE devices. The PE devices learn about the VPN routes as IPv4 prefixes from the attached CE devices using a PE-CE routing protocol or through static routing. They are stored in the routing table of the corresponding VRF. These routes are then advertised to other PE devices as VPNv4 routes through MBGP. This is done by redistributing the static routes (or the PE-CE routing protocol) into MBGP. While redistributing from the PE-CE routing protocol to MBGP, the RD corresponding to the VRF is prefixed to the IPv4 routes and converted into VPNv4 routes. The RT value configured as export RT for the VRF is attached to the VPNv4 routes. These VPNv4 routes are then advertised to other PE routers through MBGP.

When a PE router receives VPNv4 routes from another PE router, it imports routes that have an RT value that matches at least one import RT configured for a VRF, into the routing table of that VRF as IPv4 routes learned through BGP. These routes are then advertised to the attached CE devices using the PE-CE routing protocol. This is achieved by redistributing MBGP into the PE-CE routing protocol. The VPN routes are propagated between different sites of the customers.

 

Since the P routers are not running BGP and do not learn about the VPN routes belonging to customers, they drop any packets that are received without any label or with just the VPN label. The packet forwarding from one site to another site still must be done through the PE devices, which are connected across the P network through the P routers. Label the packets with a second label, which is assigned by Tag Distribution Protocol (TDP) or Label Distribution Protocol (LDP) for reaching the BGP next-hop, which is the other PE to which the destination site is connected. The BGP next-hop reachability is known to all the routers in the P network through the IGP.

There are labels for that address through TDP and LDP. The outer label learned through TDP or LDP is used for forwarding packets across the P network to the other PE device. The P routers forward the packets from one PE to the other, based on this outer label. They do not know about the inner VPN label or the VPN destination address. When the packet reaches the other PE device, the inner VPN label advertised through MBGP is used for finding the outgoing interface or the VRF routing table to be used for forwarding the packets.

 

When a CE device of a site needs to send a packet to another site, it sends a normal, unlabeled packet to the attached PE device. The PE device acting as the ingress Label Switch Router (LSR), which receives this unlabeled packet, adds a label stack of two labels by looking at its Forwarding Information Base (FIB) table, and forwards it inside the P network. The inner label is the VPN label learned through MBGP from the egress PE device. It is used for tagging the data packets for that particular VPN destination. The outer label is the one learned through TDP or LDP, and it is learned from the next-hop P router used for reaching the egress PE device.

The P-router receives labeled packets, performs a lookup in the Incoming FIB (IFIB) table, swaps the incoming label in the outer label with the Outgoing label, and forward the packets towards the next-hop router. The P router, which is one hop before the egress PE device, removes the outer label due to Penultimate Hop Popping (PHP) and forwards the packet with just the VPN label to the egress PE device. The egress PE device uses the Label Forwarding Information Base (LFIB) table to perform the label lookup, removes the VPN label in the incoming packets, and forwards the unlabeled packets towards the destination site.

 

 

MBGP_OSPF VRF LAB 1

hostname CE1

interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface Loopback1
ip address 10.0.0.1 255.255.255.0
!
interface FastEthernet0/0
ip address 172.16.0.1 255.255.255.252
speed 100
full-duplex
!
router bgp 64518
bgp log-neighbor-changes
neighbor 172.16.0.2 remote-as 34790
!
address-family ipv4
redistribute connected
neighbor 172.16.0.2 activate
no auto-summary
no synchronization
exit-address-family
!

 

hostname CE2

interface Loopback0
ip address 5.5.5.5 255.255.255.255
!
interface Loopback1
ip address 10.1.0.1 255.255.255.0
!
interface FastEthernet0/0
ip address 172.16.0.5 255.255.255.252
speed 100
full-duplex
!
router bgp 64518
bgp log-neighbor-changes
neighbor 172.16.0.6 remote-as 34790
!
address-family ipv4
redistribute connected
neighbor 172.16.0.6 activate
no auto-summary
no synchronization
exit-address-family

 

!

hostname PE1

ip vrf CE1
rd 100:1
route-target export 100:1
route-target import 100:1

interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface Loopback1
ip vrf forwarding CE1
ip address 10.10.10.254 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.252
speed 100
full-duplex
mpls ip
!
interface FastEthernet0/1
ip vrf forwarding CE1
ip address 172.16.0.2 255.255.255.252
speed 100
full-duplex
!
router ospf 10
router-id 1.1.1.1
log-adjacency-changes
redistribute connected subnets
passive-interface default
no passive-interface FastEthernet0/0
no passive-interface Loopback0
network 10.10.10.10 0.0.0.0 area 0
network 192.168.1.0 0.0.0.255 area 0
!
router bgp 34790
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 34790
neighbor 2.2.2.2 update-source Loopback0
! |
address-family ipv4
neighbor 2.2.2.2 activate
neighbor 2.2.2.2 send-community both
neighbor 2.2.2.2 soft-reconfiguration inbound
no auto-summary
no synchronization
exit-address-family

!
address-family ipv4 vrf CE1
redistribute connected
neighbor 172.16.0.1 remote-as 64518
neighbor 172.16.0.1 activate
neighbor 172.16.0.1 next-hop-self
no synchronization
exit-address-family

!

hostname PE2

ip vrf CE1
rd 100:1
route-target export 100:1
route-target import 100:1

interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.5 255.255.255.252
speed 100
full-duplex
mpls ip
!
interface FastEthernet0/1
ip vrf forwarding CE1
ip address 172.16.0.6 255.255.255.252
speed 100
full-duplex
!
router ospf 10
router-id 3.3.3.3
log-adjacency-changes
redistribute connected subnets
passive-interface default
no passive-interface FastEthernet0/0
no passive-interface Loopback0
network 11.11.11.11 0.0.0.0 area 0
network 192.168.1.0 0.0.0.255 area 0
!
router bgp 34790
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 34790
neighbor 2.2.2.2 update-source Loopback0

address-family ipv4
neighbor 2.2.2.2 activate
neighbor 2.2.2.2 send-community both
neighbor 2.2.2.2 soft-reconfiguration inbound
no auto-summary
no synchronization
exit-address-family
!
address-family ipv4 vrf CE1
redistribute connected
neighbor 172.16.0.5 remote-as 64518
neighbor 172.16.0.5 activate
neighbor 172.16.0.5 next-hop-self
no synchronization
exit-address-family

 

hostname P

mpls label protocol ldp

interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.252
speed 100
full-duplex
mpls ip
!
interface FastEthernet0/1
ip address 192.168.1.6 255.255.255.252
speed 100
full-duplex
mpls ip
!

router ospf 10
router-id 2.2.2.2
log-adjacency-changes
redistribute connected subnets
passive-interface default
no passive-interface FastEthernet0/0
no passive-interface FastEthernet0/1
no passive-interface Loopback0
network 2.2.2.2 0.0.0.0 area 0
network 192.168.1.0 0.0.0.255 area 0
!
router bgp 34790
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 34790
neighbor 1.1.1.1 update-source Loopback0
neighbor 3.3.3.3 remote-as 34790
neighbor 3.3.3.3 update-source Loopback0
!
address-family ipv4
neighbor 1.1.1.1 activate
neighbor 1.1.1.1 send-community both
neighbor 1.1.1.1 soft-reconfiguration inbound
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community both
neighbor 3.3.3.3 soft-reconfiguration inbound
no auto-summary
no synchronization
exit-address-family

!
address-family vpnv4
neighbor 1.1.1.1 activate
neighbor 1.1.1.1 send-community extended
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community extended
exit-address-family
!

ip bgp-community new-format

 

Cisco VRF Routing

Create VRF :

ip vrf comms
rd 34790:1002
route-target export 34790:1002
route-target import 34790:1002

!
!

interface Loopback0
ip vrf forwarding comms ( Bind to Interface )
ip address ( public ip address )
!
interface GigabitEthernet0/0
description comms hq circuit
ip vrf forwarding comms
ip address 192.168.250.18 255.255.255.252
!
interface GigabitEthernet0/1
description comms hq_sw1
ip vrf forwarding
comms
ip address 172.31.31.62 255.255.255.252   ( primary link )
ip ospf network point-to-point
ip ospf demand-circuit
ip ospf 1 area 1
!
interface FastEthernet0/0/0
description comms hq_sw2
ip vrf forwarding
comms
ip address 172.31.31.66 255.255.255.252   ( backup link )
ip ospf network point-to-point
ip ospf demand-circuit
ip ospf 1 area 1
!
router ospf 1 vrf
comms
redistribute connected subnets
redistribute bgp 64514 subnets
distribute-list prefix cust_routes in
!
router bgp 64514
bgp router-id 1.1.1.1
bgp log-neighbor-changes
no auto-summary
!
address-family ipv4 vrf comms
redistribute connected
redistribute static
redistribute ospf 1 vrf comms match internal external 1 external 2
neighbor 192.168.250.17 remote-as 34790
neighbor 192.168.250.17 activate
neighbor 192.168.250.17 soft-reconfiguration inbound
exit-address-family
!
ip route vrf genesis 10.0.2.240 255.255.255.255 172.31.31.61
ip route vrf genesis 10.0.2.240 255.255.255.255 172.31.31.65 200
!
ip tacacs source-interface Loopback0
!
!
ip prefix-list cust_routes seq 10 permit 10.200.20.0/24 le 32
ip prefix-list cust_routes seq 20 permit 10.200.21.0/24 le 32
ip prefix-list cust_routes seq 30 permit 10.200.22.0/24 le 32
ip prefix-list cust_routes seq 40 permit 10.200.23.0/24 le 32
ip prefix-list cust_routes seq 50 permit 10.194.0.0/22 le 32
!
line vty 0 4
access-class 23 in vrf-also ( Same access list is applied for all VRFs )
privilege level 15
logging synchronous
transport input telnet ssh

VRF Basics

When we hear about VRF, its almost synonymous to MPLS VPN. Virtual Routing and Forwarding is
commonly used by Service Providers to provide services within an MPLS cloud with multiple customers.

The most interesting feature of this is that, VRF allows creation of multiple routing tables within a
single router. This means that overlapping use of IP addresses from different customers is possible
.

Through the network setup below, we will see how to configure VRF and check if its really possible for
duplicate ip addresses
.

We have 3 customers in the figure connected to a Provider Edge router.
We will name the VRF’s Blue, Red and Yellow.

Now let’s configure RD’s on the PE router.

Router(config)#host PE
PE(config)#ip vrf blue
PE(config-vrf)#rd 1:1
PE(config-vrf)#ip vrf red
PE(config-vrf)#rd 2:2
PE(config-vrf)#ip vrf yellow
PE(config-vrf)#rd 3:3

Basically the “rd” command is in the format ASN:nn or IP-address:nn. The VRF names and rd values
are actually locally significant which means that it doesn’t matter what name you create.

What really matters is the “route target” value because this is what you will import or export.

Now we have created VRF’s, lets configure interfaces and apply the VRF’s to the interfaces.

PE(config)#int fa0/0.2
PE(config-subif)#encapsulation dot1q 2
PE(config-subif)#ip vrf forwarding blue
PE(config-subif)#ip address 1.1.1.1 255.255.255.252
PE(config-subif)#int fa0/0.3
PE(config-subif)#encapsulation dot1q 3
PE(config-subif)#ip vrf forwarding red
PE(config-subif)#ip address 1.1.1.1 255.255.255.252
PE(config-subif)#int fa0/0.4
PE(config-subif)#encapsulation dot1q 4
PE(config-subif)#ip vrf forwarding yellow
PE(config-subif)#ip address 1.1.1.1 255.255.255.252

If you notice above all interfaces have the same ip address which is 1.1.1.1.
Normally without VRF, the router will give a warning message that

overlapping ip addresses are not allowed
.

The command “ip vrf forwarding ” will add the vrf to a specific interface.

Blue#ping 1.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/35/80 ms

Red#ping 1.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/48/156 ms

Yellow#ping 1.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/60/136 ms

It’s good! We have ip reachability to PE from the CE routers. Now, from PE point of view,
how will
PE know which one to ping if we use 1.1.1.2 since all Blue, Red and Yellow
routers use the same ip
?

This can be accomplished using the “ping vrf ” command. See below.

PE#ping vrf blue 1.1.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/28/68 ms

PE#ping vrf red 1.1.1.2 

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/28/88 ms

PE#ping vrf yellow 1.1.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/31/68 ms

Now, we have proven that duplicate IP addresses is possible using VRF. Be reminded that VRF’s are
usually
and by standard configured on PE routers. CE routers normally don’t make use of VRF’s but
there are  always exceptions

To make this work you do require a switch between the PE and the CE Routers.
You must set the Switch port mode for the PE Router-to-Switch to dot1q (i.e trunk) and the
Switch port mode for each
CE Router-to-Swith to access with the respective vlan
(i.e blue=2,red=3, yellow=4).

Hope that helps!

GRE Tunnel with VRF Configuration

R3-PE Configuration :

ip vrf blue
 rd 1:1
 route-target export 301:301
 route-target import 401:401
!
ip vrf green
 rd 2:2
 route-target export 302:302
 route-target import 402:402
!
!- If the import and export lists are identical, use the both keyword to define both lists simultaneously.
!- You can add only one route target to a list at a time.

!
ip cef
!
interfave tunnel 0
 ip vrf forwarding green
 ip address 1.1.1.1 255.255.255.0
 tunnel source Ethernet0/0
 tunnel destination 10.10.10.1
 tunnel vrf blue

!-Tunnel 0 is part of VRF GREEN; but it uses the tunnel destination and source addresses from the routing
   table of VRF BLUE, because of this tunnel vrf blue command.

!
interface Ethernet0/0
 ip vrf forwarding blue
 address 20.20.20.3 255.255.255.0

!— Connection to the VRF BLUE network and the VRF GREEN network using the GRE tunnel.
!
interface Ethernet0/1
 ip address 30.30.30.3 255.255.255.0
 tag-switching ip (replaces IP MPLS command)
 !
router bgp 1
 no bgp default ipv4-unicast
 bgp log-neighbor-changes  (allow those routers to log their BGP neighbors resets).
 neighbor 30.30.30.4 remote-as 1
!
 address-family vpnv4 (This command replaces the match nlri and set nlri commands).
                                         (Use to configure the router to exchange IPv4 addresses in VPN mode).
 neighbor 30.30.30.4 activate (Specify peer or peer group with routes of current address family exchanged).
 neighbor 30.30.30.4 send-community extend (Enables BGP speaker to send community attribute to peer).
 exit-address-family (Exit Address Family Configuration mode and access Router Configuration mode).
!
address-family ipv4 vrf green
 redistribute connected
 no auto-summary
 no synchronization ( Tells routers shouldn’t wait for synchronization,  just go ahead use the iBGP routes).
 exit-address-family
!
address-family ipv4 vrf blue 
 redistribute connected
 no auto-summary
 no synchronization
 exit-address-family
!
ip classless
ip route vrf blue 10.10.10.1 255.255.255.255 20.20.20.2
!
end

R4-PE Configuration :

ip vrf blue
 rd 1:1
 route-target export 401:401
 route-target import 301:301
!
ip vrf green
 rd 2:2
 route-target export 402:402
 route-target import 302:302
!
ip cef
!
interface Ethernet0/0
 ip address 30.30.30.4 255.255.255.0
 tag-switching ip (replaces IP MPLS command)
!
interface Ethernet 0/1
 ip vrf forwarding green
 ip address 100.100.100.4 255.255.255.0
!
interface Ethernet0/2
 ip vrf forwarding blue
 ip address 40.40.40.4 255.255.255.0
!
router bgp 1
 no bgp default ipv4-unicast
 bgp log-neighbor-changes
 neighbor 30.30.30.3 remote-as 1
!
address-family vpnv4
 neighbor 30.30.30.3 activate
 neighbor 30.30.30.3 send-community extend
 exit-address-family
!
address-family ipv4 vrf green 
 redistribute connected
 no auto-summary
 no synchronization
 exit-address-family
!
address-family ipv4 vrf blue
 redistribute connected
 no auto-summary
 no synchronization
 exit-address-family
!
ip classless
!
end

R1-PE Configuration :ip cef
!
interface Tunnel 0
 ip address 200.200.200.1 255.255.255.0
 tunnel source Ethernet0/0
 tunnel destination 20.20.20.3

!- Both the tunnel source and destination address are in the VRF BLUE,
    to provide transport for the VRF GREEN network.

!
interface Ethernet0/0
description Connection to R2-CE router
ip address 10.10.10.1 255.255.255.0
ip access-group 100 in
ip access-group 100 out

!- Access-group to allow only GRE packets through theR2-CE network. 
   However, R1-CE networks data is in the GRE packet.

!
ip route 0.0.0.0 0.0.0.0 Tunnel0
ip route 20.20.20.3 255.255.255.255 10.10.10.2
!
access-list 100 permit gre host 10.10.10.1 host 20.20.20.3
access-list 100 permit gre host 20.20.20.3 host 10.10.10.1

!- Permits only GRE packets between the endpoints.
!
end

R2-CE#ip cef
!
interface Ethernet0/0
description Connection to R1-CE router
ip address 10.10.10.2 255.255.255.0
ip access-group 100 in
ip access-group 100 out
!
interface Ethernet1/0
ip address 20.20.20.2 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 20.20.20.3
!
access-list 100 permit gre host 10.10.10.1 host 20.20.20.3
access-list 100 permit gre host 20.20.20.3 host 10.10.10.1

!- Permits only GRE packets between the endpoints.
!
end

R5-CE#

interface Ethernet0/0
 ip address 100.100.100.5 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 100.100.100.4
!
end

R6-CE

!
interface Ethernet0/0
 ip address 40.40.40.6 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 40.40.40.4
!
end