VRF Configuration
Overview
Virtual routing and forwarding (VRF) is a technology that allows multiple instances of a routing table to co-exist within the same router at the same time. Because the routing instances are independent, the same or overlapping IP addresses can be used without conflicting with each other. VRF may be implemented in a network device by distinct routing tables known as forwarding information bases – one per routing instance.
Topology
Device topology
Default VRF
#con t | Enter the router configuration mode |
(config)#interface eth1 | Switch to interface eth1 |
(config-if)#ip address 3.3.3.2/24 | Configure the ip address 3.3.3.2 to eth1 |
(config-if)#exit | Exit interface mode. |
Adding a Static Route
#con t | Enter the router configuration mode |
(config)#ip route 20.20.20.0/24 eth1 | Add static route with eth1 as exit interface |
User-Defined VRF
#con t | Enter configuration mode. |
(config)#ip vrf vrf1 | Create vrf1 |
(config)#exit | Exit configure mode. |
(config)#interface eth1 | Enter interface mode |
(config-if)#ip vrf forwarding vrf1 | Associate eth1 to vrf1. |
(config-if)#ip address 3.3.3.2/24 | Configure the IP address 3.3.3.2 to eth1 |
(config-if)#exit | Exit interface mode. |
Adding a Static Route
#con t | Enter the router configuration mode |
(config)# ip route vrf vrf1 20.20.20.0/24 eth1 | Add static route in vrf1 with eth1 as exit interface |
Validation
#show ip route vrf all
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
* - candidate default
IP Route Table for VRF "default"
C 127.0.0.0/8 is directly connected, lo, 00:14:59
C 192.168.52.0/24 is directly connected, eth0, 00:14:55
IP Route Table for VRF "management"
IP Route Table for VRF "vrf1"
C 3.3.3.0/24 is directly connected, eth1, 00:00:44
S 20.20.20.0/24 [1/0] is directly connected, eth1, 00:00:08
Gateway of last resort is not set