VRF-lite lets one router keep several customers’ routing tables completely separate, with nothing more than a few lines of config. In this lab I built two PE routers that carry two customers over a single LACP trunk, with OSPF in each VRF. The approach is the same one you would use on a real network: a minimal day-0 config to make the devices reachable, and to prepare to automate the whole configs from data.
VRF-lite over an EtherChannel
You will find all the labs in the Bitsize series on my Github, link to repo: CML-bitsize-labs.
Learning Objectives
- Separate customer traffic with VRF-lite using 802.1Q subinterfaces
- Build a Layer 3 EtherChannel (LACP) between two routers and carry several VRFs over it
- Run OSPF inside a VRF and use
ip ospf network point-to-pointon a /30 link - Use a management VRF so automation never loses access to the device
- Split a config into day-0 (bootstrap) and intended state
Learn more about VRF-lite in my CCNP notebook on github: CCNP Study Notes
Lab Overview
The topology has two PE routers (Cat8000v), four switches and four Alpine clients. The PEs are connected by two links bundled into Port-channel1, and each PE connects to a local switch with a dot1Q trunk. Every device has a management interface connected to an external connector in bridge mode.
C001 ─ SW001 ─ PE001 ═(Po1: VLAN 10 / 20)═ PE002 ─ SW002 ─ C002
192.168.1.0/24 192.168.2.0/24
| Item | Value |
|---|---|
| Management network | 10.10.10.0/24 (MGMT VRF), PE001 = .101, PE002 = .102 |
| VRF A PE-to-PE link | 172.16.10.0/30 (VLAN 10) |
| VRF B PE-to-PE link | 172.16.20.0/30 (VLAN 20) |
| Customer A site 1 / site 2 | 192.168.1.0/24 / 192.168.2.0/24 |
| OSPF | process 10 in VRF A, area 0 |
The goal is for the client on VLAN 10 at site 1 to reach its peer at site 2 through VRF A, while VRF B stays isolated.
Lab Instructions
- Setup: Clone the lab repository and navigate to the
vrf/folder. Review the provided day-0 configurations for the routers in the lab topology. - Configuration: Import the cml_import.yaml file into the CML environment. Follow the instructions in the Lab Tasks to configure VRF-lite on the appropriate routers. Use the CLI to apply the necessary commands and verify your configuration, then repeat the build with the automation scripts.
- Testing: After configuring the VRFs and OSPF, check the port-channel, the OSPF neighbour and the VRF routing tables, then test connectivity between the clients in VRF A and confirm that VRF A cannot reach VRF B.
Lab Tasks
-
Identify the Networks: Review the network topology and identify the management network, the PE-to-PE links per VRF and the customer subnets at each site. Decide which interfaces belong to the port-channel and which face the switches.
-
Configure VRF-lite: Create VRF A and VRF B on both PEs, build Port-channel1 with two LACP members, add one subinterface per VRF (VLAN 10 and 20), add the customer-facing subinterface and run OSPF inside VRF A.
-
Verify Configuration: Check the EtherChannel, the OSPF adjacency and the per-VRF routing tables.
-
Test Connectivity: Ping between the clients at both sites, confirm that traffic follows VRF A, and run an isolation test between VRF A and VRF B.
Walkthrough
This is a walkthrough of the lab, where you can find the commands and steps to complete the lab tasks. It is recommended to attempt the lab on your own before referring to the walkthrough.
Identify the Networks:
Each PE needs two kinds of links. The management interface (GigabitEthernet1) sits in its own VRF and is configured in the day-0 config. The data-plane links are the two port-channel members (GigabitEthernet2 and 3) and the link to the local switch (GigabitEthernet4). Interface names differ between platforms, so I keep them in the data file instead of the template.
Day-0 config (the bootstrap):
The day-0 config only needs to make the device reachable over SSH. Everything else is possible to automatate.
hostname PE001
no ip domain lookup
ip domain name lab.local
!
vrf definition MGMT
address-family ipv4
exit-address-family
!
interface GigabitEthernet1
vrf forwarding MGMT
ip address 10.10.10.101 255.255.255.0
no shutdown
!
username netops privilege 15 secret <password>
crypto key generate rsa modulus 2048
ip ssh version 2
line vty 0 4
login local
transport input ssh
Why a management VRF? It keeps the management path in its own routing table. Customers with overlapping address space cannot clash with it, customer routing mistakes cannot cut off SSH, and the global table stays free for the real design. It also means that a push from automation can never remove the connection it is using, as long as the template does not touch the management VRF or its interface.
Configure VRF-lite:
Define the VRFs and build the port-channel. The physical port-channel carries no IP address. Each VRF gets its own subinterface, with its own VLAN tag, VRF and /30.
vrf definition A
address-family ipv4
exit-address-family
vrf definition B
address-family ipv4
exit-address-family
!
interface Port-channel1
description LACP trunk to PE002
no ip address
no shutdown
!
interface GigabitEthernet2
channel-group 1 mode active
no shutdown
interface GigabitEthernet3
channel-group 1 mode active
no shutdown
!
interface Port-channel1.10
encapsulation dot1Q 10
vrf forwarding A
ip address 172.16.10.1 255.255.255.252
ip ospf network point-to-point
interface Port-channel1.20
encapsulation dot1Q 20
vrf forwarding B
ip address 172.16.20.1 255.255.255.252
Apply vrf forwarding before the IP address, because IOS removes an existing address when a VRF is applied. PE002 gets the same config with .2 addresses.
Then add the customer-facing subinterface and OSPF in VRF A:
interface GigabitEthernet4
no ip address
no shutdown
interface GigabitEthernet4.10
encapsulation dot1Q 10
vrf forwarding A
ip address 192.168.1.1 255.255.255.0
!
router ospf 10 vrf A
router-id 1.1.1.1
passive-interface GigabitEthernet4.10
network 172.16.10.0 0.0.0.3 area 0
network 192.168.1.0 0.0.0.255 area 0
ip ospf network point-to-point tells OSPF that exactly two routers share the /30, so no DR/BDR election is needed. Use it on both ends of the link. Each VRF needs its own OSPF process, and the router ID must be unique per router (1.1.1.1 and 2.2.2.2).
On the switches, configure VLAN 10, a trunk toward the PE and an access port for the client. On the Alpine clients, give C001 192.168.1.10/24 and C002 192.168.2.10/24, each with its PE as the default gateway.
One note on platforms: the lightweight IOL router image did not accept channel-group on a routed interface in my lab, so I used the Cat8000v for the PEs. Check channel-group ? on your image first.
Verify Configuration:
show etherchannel summary ! Po1 flagged RU, both members P
show ip ospf neighbor ! neighbour on Po1.10 in FULL state
show ip route vrf A ! 192.168.2.0/24 learned via OSPF
show vrf
Test Connectivity:
Always add the vrf keyword to pings from a router, otherwise the test runs in the global table and proves nothing.
ping vrf A 172.16.10.2
ping 192.168.2.10 ! from C001
traceroute 192.168.2.10 ! 192.168.1.1, 172.16.10.2, destination
To prove isolation, ping an address that exists only in VRF B from VRF A. It must fail. A good extra test is to use the same subnet in both VRFs and check that both work at the same time. To test redundancy, shut one port-channel member and check that the ping keeps working. A single flow always uses one member, so the bundle gives resilience, not more speed for one stream.
Resources
Comming soon :)
