The purpose of VRF-lite is to extend the logical separation of two different networks from a MPLS network down to a single CE router, connected to both these networks. It’s called VRF-lite because it is done without running MPLS (LDP/TDP) or MP-BGP between the PE and CE. Traffic is mapped to the VRF assigned to the ingress interface on the CE router.
But VRF-lite could be used without connecting to a MPLS network entirely! Consider what a VRF is?
A VRF is a mechanism used to provide logical separation between routing tables on the same router. It is locally significant to the router. Each interface on a router can only be assigned to one VRF, but a VRF can have multiple interfaces.
So VRF-lite could be used to separate multiple networks using the same equipment. (Not exactly something you should ever plan in a design, but it could be useful to know)
Once you have the separation you needed, you might need a way to selectively bridge that separation to allow communication between the VRF’s.
Assume the following scenario:
Router1 runs VRF-lite with two interfaces, one connecting to VPN5 and the other to VPN7. The is a CE device connected in VPN5 with an IP address of 150.50.15.5, and another CE device in VPN7 with an IP address of 150.50.17.7.
Originally the intent might have been to keep the two networks entirely separate. But lets assume the need arises to allow routing between VPN5 and VPN7 but only between the ranges 55.5.1.0/24 and 17.1.1.0/24. Not the rest! How can it be done?
As always there are options! Make use of Route-Targets (RTs), or Take the lazy approach with static routes. Direct redistribution between VRF-aware IGP’s on the same router, does not work as you would expect. On most the IOS codes that I have seen, IOS does not allow this.
Option 1 – Using RTs
The technique that might jump to mind is route-target import/export. But what is a route-target and its purpose?
A RD is a 64-bit identifier prepended to a 32-bit IPv4 address which turns a non-unique IPv4 prefix into a unique 96-bit VPNv4 prefix. A RD is the most basic requirement to activate the VRF and create the VRF tables.
A RT or route-target on the other hand is a BGP extended community which gets attached when a prefix is exported from the VRF RIB table into the VRF-aware BGP table to identify VPN membership. The confusing part is that the RT import/export function in Cisco IOS is defined under the VRF configuration section and not under the BGP section. Thus to use RTs BGP is required. This means without BGP enabled on Router1, the RT import/export would yield no result.
So for this option to work the following must be considered: The BGP process is required for the creation of the VRF-aware BGP tables. BGP neighbors are not necessary. From the source VRF the required range must be redistributed into the VRF specific BGP table where the export RT is attached. The destination VRF should then import this exported range, based on the attached RT. And vice versa for bidirectional communication.Lastly since BGP is used the BGP next-hop must be reachable, else the imported routes will not be considered for route-selection. Here is the config to complete the first option:
ip vrf VPN5 rd 100:5 import map V5-MAP route-target export 1:5 route-target import 1:5 route-target import 1:7 ! ip vrf VPN7 rd 100:7 import map V7-MAP route-target export 1:7 route-target import 1:7 route-target import 1:5 ! ip extcommunity-list standard V5 permit rt 1:5 ip extcommunity-list standard V7 permit rt 1:7 ! ip prefix-list IMPORT-5 seq 5 permit 17.1.1.0/24 ip prefix-list IMPORT-5 seq 15 permit 150.50.17.0/24 ip prefix-list IMPORT-7 seq 5 permit 55.5.1.0/24 ip prefix-list IMPORT-7 seq 15 permit 150.50.15.0/24 ! route-map V5-MAP permit 10 match ip address prefix-list IMPORT-5 route-map V5-MAP permit 20 match extcommunity V5 ! route-map V7-MAP permit 10 match ip address prefix-list IMPORT-7 route-map V7-MAP permit 20 match extcommunity V7 ! router eigrp 1 address-family ipv4 vrf VPN7 redistribute bgp 1 metric 1500 10 255 2 1500 network 150.50.17.1 0.0.0.0 autonomous-system 7 address-family ipv4 vrf VPN5 redistribute bgp 1 metric 1500 10 255 2 1500 network 150.50.15.1 0.0.0.0 autonomous-system 5 ! router bgp 1 address-family ipv4 vrf VPN7 redistribute connected redistribute eigrp 7 address-family ipv4 vrf VPN5 redistribute connected redistribute eigrp 5
The output should yield the following:
Option 2 – Static Routes
Another, perhaps easier option would be to use static routes within each VRF and in the global VRF. This method will route traffic out the source VRF to the global table and back in the destination VRF. The obvious other bonus is that this method does not need the BGP process to be enabled.
So to test 17.1.1.0/24 should be allowed to ping 55.5.1.0/24 but no other 55.5 range.
This is done by using the command “ip route vrf NAME x.x.x.x s.s.s.s nh.nh.nh.nh global”.
The global keyword specifies that the next-hop is reachable via the global routing table instead of the VRF table.
The global table would obviously need a route to each required next-hop in each VRF. For this two routes are needed in the global RIB for the next-hop IPs of VPN5 and VPN7:
interface FastEthernet0/0 ip vrf forwarding VPN5 ip address 150.50.15.1 255.255.255.0 ! interface FastEthernet0/1 ip vrf forwarding VPN7 ip address 150.50.17.1 255.255.255.0 ! ip route 150.50.15.5 255.255.255.255 FastEthernet0/0 ip route 150.50.17.7 255.255.255.255 FastEthernet0/1
Then to add the static routes within the respective VRFs are the easy part:
ip route vrf VPN5 17.1.1.0 255.255.255.0 150.50.17.7 global ip route vrf VPN7 55.5.1.0 255.255.255.0 150.50.15.5 global
Let me explain, the first line says: For VPN5 to reach the 17.1.1.0/24 destination (in VPN7) go to the next-hop of 150.50.17.7 which is in the global table. The global table will route traffic to that next-hop into the VPN7 table, as per the first set of static routes.
The second line takes care of the return traffic.
Here is the test to confirm:
Option3 – Multi-VRF Selection Using Policy Based Routing (PBR)
Regards,
Hans
The only problem is VRF Select is supported only in Service Provider (-p-) images.
This might not always be a option on site routers, but very good solution :)
Very useful and concise overview for me coming from an enterprise R&S background. Thank you.
Would you be able to add the VRF select option to satisfy my curiosity :-) ?
Great work, I wanted to implement route leak (static route) on one router. I hope this solution will work.
Thanks,
Bilal Hansrod
which interface/router 150.50.17.7 / 150.50.15.5 is assigned to?
Those would next-hop interface IP on the CE type devices connected downstream .
I.e. 150.50.15.5 would be connected downstream to FastEthernet0/0 etc…
hth :)
The page format has somehow lost half of the post.
I’ll correct that shortly :(
Oh the post is displaying all info now.. :)
I guess there is one or two options more to consider …
1- VRF selection source.
2- Policy routing.
In the RT approach above,
Why are you importing the same RT that you are exporting? Is this needed?
You have the following consecutive lines:
Route-target export 1:5
Route-target import 1:5
…
I would have thought export is enough since all other prefixes must anyway be in the VRF with rd 100:5
Ick,
This is because of an old bug, it is not necessary to do this nowdays.
BR Tommy
Can the same be done with Rip v2 instead of eigrp
Hi,
Shouldn’t you be matching extcommunity list V7 in the below line
route-map V5-MAP permit 20
match extcommunity V5
And V5 in the Below line…
route-map V7-MAP permit 20
match extcommunity V7
I am asking because import-map V5-MAP is importing RT 1:7 and V7-Map is importing RT 1:5
Regarding route leaking via M-BGP configuration…it is almost all wrong. Here is correct configuration of router R1:
ip vrf VPN5
rd 1.1.1.1:5
import map V5-MAP
route-target export 100:5
route-target import 100:7
!
ip vrf VPN7
rd 1.1.1.1:7
import map V7-MAP
route-target export 100:7
route-target import 100:5
!
interface Ethernet0/0
ip vrf forwarding VPN5
ip address 150.50.15.1 255.255.255.0
!
interface Ethernet0/1
ip vrf forwarding VPN7
ip address 150.50.17.1 255.255.255.0
!
router ospf 5 vrf VPN5
router-id 1.1.1.1
redistribute bgp 100 subnets
network 0.0.0.0 255.255.255.255 area 0
!
router ospf 7 vrf VPN7
router-id 2.2.2.2
redistribute bgp 100 subnets
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 100
bgp router-id 3.3.3.3
bgp log-neighbor-changes
!
address-family ipv4 vrf VPN5
redistribute ospf 5
exit-address-family
!
address-family ipv4 vrf VPN7
redistribute ospf 7
exit-address-family
!
ip extcommunity-list standard V5 permit rt 100:7
ip extcommunity-list standard V7 permit rt 100:5
!
ip prefix-list IMPORT-5 seq 5 permit 17.1.1.0/24
!
ip prefix-list IMPORT-7 seq 5 permit 55.5.1.0/24
!
route-map V7-MAP permit 10
match ip address prefix-list IMPORT-7
match extcommunity V7
!
route-map V5-MAP permit 10
match ip address prefix-list IMPORT-5
match extcommunity V5
!
Notice that I’m using OSPF as IGP. If you are simulating networks 17.1.x.0/24 and 55.5.x.0/24 via loopback interfaces, don’t forget add command “ip ospf network point-to-point” to interface configuration. Because OSPF by default advertises these loopback interfaces as /32 routes, hence they will not be matched by prefix-list. Here is example of loopback interface on VPN7 router.
!
interface Loopback1
ip address 17.1.1.1 255.255.255.0
ip ospf network point-to-point
!
According this config only comunication between networks 55.5.1.0/24 and 17.1.1.0/24 will be allowed. So you have to specify source interface when you pinging…
VPN5#ping 17.1.1.1 source loopback 1 repeat 10
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 17.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 55.5.1.1
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
i have a question, considering the configuration you just suggested and the scenario of having more subnets within de vpn 5, would i have any reachability problems between subnets inside vpn 5? because standing at “ip vrf VPN5” we are importing route-map v5-map which is matching a prefix and the rt (100:7) from vpn 7 but we are not importing rt 100:5
The “ip route vrf” is not available on Cisco Nexus 7K switches. Any suggestion?