Example for Configuring OSPF with Different VRFs

Example for Configuring OSPF with Different VRFs


Networking Requirements

As shown in Figure 1, by configuring OSPF routing protocol on switch 1, switch 2 and switch 3, the three devices can exchange routing information with each other. We will implement the VRF function on Switch 1, Switch 2 and Switch 3 to segregate the users' routing spaces of different Tenants. We will create two VRFs on each device and run OSPF in these VRFs.

Figure 1. User Configuration Topology of OSPF with Different VRFs

Basic Deployment

Figure 1 shows the user configuration topology of OSPF with different VRFs. Follow the configuration roadmap below to complete the configuration.

  • Configure IP addresses and VLANs for the VLAN interfaces on switches to establish communication within the network segments.

  • Configure basic OSPF functions on each switch. Configure Switch 1 as the ABR to divide the OSPF network into two areas (Area: 0.0.0.0 and Area: 1.1.1.1), so that the entire OSPF network can be extended using the area where Switch 1 and Switch 2 are located as the backbone area.

  • In order to make different tenants have different routing space, configure two VRFs on each of the three switches.

Networking Address Planning

The networking IP address planning is shown in the following table.

Switch

Physical Interface

VRF and VLAN Interface

OSPF Configurations

Switch1

Te-1/1/1

vrf1

VLANIF11: 11.251.201.2

Area: 1.1.1.1

Router ID: 1.1.1.1

vrf2

VLANIF 21: 21.251.201.2

Area: 1.1.1.1

Router ID: 1.1.1.1

Te-1/1/2

vrf1

VLANIF 10: 10.251.201.2

Area: 0.0.0.0

Router ID: 1.1.1.1

vrf2

VLANIF 20: 20.251.201.2

Area: 0.0.0.0

Router ID: 1.1.1.1

Switch2

Te-1/1/5

vrf1

VLANIF 10: 101.251.201.3

Area: 0.0.0.0

Router ID: 2.2.2.2

vrf2

VLANIF 20: 201.251.201.3

Area: 0.0.0.0

Router ID: 2.2.2.2

Switch3

Te-1/1/5

vrf1

VLANIF 11: 100.251.201.3

Area: 1.1.1.1

Router ID: 3.3.3.3

vrf2

VLANIF 21: 200.251.201.3

Area: 1.1.1.1

Router ID: 3.3.3.3

Procedure

Configure Switch 1, Switch 2 and Switch 3 according to the networking requirements described above.

Switch1

Step1         Configure the VLANs and VLAN interfaces. 

admin@switch1# set interface gigabit-ethernet te-1/1/1 family ethernet-switching port-mode trunk admin@switch1# set interface gigabit-ethernet te-1/1/1 family ethernet-switching vlan members 11 admin@switch1# set interface gigabit-ethernet te-1/1/1 family ethernet-switching vlan members 21 admin@switch1# set interface gigabit-ethernet te-1/1/1 family ethernet-switching vlan members 10 admin@switch1# set interface gigabit-ethernet te-1/1/2 family ethernet-switching port-mode trunk admin@switch1# set interface gigabit-ethernet te-1/1/2 family ethernet-switching vlan members 10 admin@switch1# set interface gigabit-ethernet te-1/1/2 family ethernet-switching vlan members 20 admin@switch1# set l3-interface loopback vrf1 address 1.1.1.1 prefix-length 32 admin@switch1# set l3-interface vlan-interface vlan10 address 10.251.201.2 prefix-length 24 admin@switch1# set l3-interface vlan-interface vlan20 address 20.251.201.2 prefix-length 24 admin@switch1# set l3-interface vlan-interface vlan11 address 11.251.201.2 prefix-length 24 admin@switch1# set l3-interface vlan-interface vlan21 address 21.251.201.2 prefix-length 24 admin@switch1# set vlans vlan-id 10 l3-interface vlan10 admin@switch1# set vlans vlan-id 11 l3-interface vlan11 admin@switch1# set vlans vlan-id 20 l3-interface vlan20 admin@switch1# set vlans vlan-id 21 l3-interface vlan21

Step2         Configure VRF.

    a.       Enable IP routing function before using VRF function and configure the system hostname.

admin@switch1# set ip routing enable true admin@switch1# set system hostname switch1

    b.       Create VRFs.

admin@switch1# set ip vrf vrf1 description orange admin@switch1# set ip vrf vrf2 description purple

    c.       Bind the Layer 3 VLAN interface to the VRF.

admin@switch1# set l3-interface vlan-interface vlan10 vrf vrf1 admin@switch1# set l3-interface vlan-interface vlan20 vrf vrf2 admin@switch1# set l3-interface vlan-interface vlan11 vrf vrf1 admin@switch1# set l3-interface vlan-interface vlan21 vrf vrf2

3         Configure basic OSPF functions.

admin@switch1# set protocols ospf vrf vrf1 router-id 1.1.1.1 admin@switch1# set protocols ospf vrf vrf1 network 10.251.201.0/24 area 0.0.0.0 admin@switch1# set protocols ospf vrf vrf1 network 11.251.201.0/24 area 1.1.1.1 admin@switch1# set protocols ospf vrf vrf2 router-id 1.1.1.1 admin@switch1# set protocols ospf vrf vrf2 network 20.251.201.0/24 area 0.0.0.0 admin@switch1# set protocols ospf vrf vrf2 network 21.251.201.0/24 area 1.1.1.1

Step4         Commit the configuration.

admin@Switch1# commit

Switch2

Step1         Configure the VLANs and VLAN interfaces.

admin@switch2# set interface gigabit-ethernet ge-1/1/5 family ethernet-switching port-mode "trunk" admin@switch2# set interface gigabit-ethernet ge-1/1/5 family ethernet-switching vlan members 10 admin@switch2# set interface gigabit-ethernet ge-1/1/5 family ethernet-switching vlan members 20 admin@switch2# set vlans vlan-id 10 l3-interface "vlan10" admin@switch2# set vlans vlan-id 20 l3-interface "vlan20" admin@switch2# set l3-interface vlan-interface vlan20 address 20.251.201.3 prefix-length 24 admin@switch2# set l3-interface vlan-interface vlan10 address 10.251.201.3 prefix-length 24

Step2         Configure VRF.

  a.       Enable IP routing function before using VRF function and set the system hostname.

admin@switch2# set ip routing enable true admin@switch2# set system hostname "switch2"

    b.       Create VRFs.

admin@switch2# set ip vrf vrf1 description orange admin@switch2# set ip vrf vrf2 description purple

    c.       Bind the Layer 3 VLAN interface to the VRF.

admin@switch2# set l3-interface vlan-interface vlan10 vrf "vrf1" admin@switch2# set l3-interface vlan-interface vlan20 vrf "vrf2"

3         Configure basic OSPF functions.

admin@switch2# set protocols ospf vrf vrf1 router-id 2.2.2.2 admin@switch2# set protocols ospf vrf vrf1 network 10.251.201.0/24 area 0.0.0.0 admin@switch2# set protocols ospf vrf vrf2 router-id 2.2.2.2 admin@switch2# set protocols ospf vrf vrf2 network 20.251.201.0/24 area 0.0.0.0

Step4         Commit the configuration.

admin@switch2# commit

Switch3

Step1         Configure the VLANs and VLAN interfaces.

admin@switch3# set interface gigabit-ethernet ge-1/1/5 family ethernet-switching port-mode "trunk" admin@switch3# set interface gigabit-ethernet ge-1/1/5 family ethernet-switching vlan members 11 admin@switch3# set interface gigabit-ethernet ge-1/1/5 family ethernet-switching vlan members 21 admin@switch3# set vlans vlan-id 11 l3-interface "vlan11" admin@switch3# set vlans vlan-id 21 l3-interface "vlan21" admin@switch3# set l3-interface vlan-interface vlan11 address 11.251.201.4 prefix-length 24 admin@switch3# set l3-interface vlan-interface vlan21 address 21.251.201.4 prefix-length 24

Step2         Configure VRF.

  a.       Enable IP routing function before using VRF function.

admin@switch3# set ip routing enable true admin@switch3# set system hostname "switch3"

    b.       Create VRFs.

admin@Switch3# set ip vrf vrf1 description orange admin@Switch3# set ip vrf vrf2 description purple

    c.       Bind the Layer 3 VLAN interface to the VRF.

admin@switch3# set l3-interface vlan-interface vlan11 vrf "vrf1" admin@switch3# set l3-interface vlan-interface vlan21 vrf "vrf2"

3         Configure basic OSPF functions.

admin@switch3# set protocols ospf vrf vrf1 router-id 3.3.3.3 admin@switch3# set protocols ospf vrf vrf1 network 11.251.201.0/24 area 1.1.1.1 admin@switch3# set protocols ospf vrf vrf2 router-id 3.3.3.3 admin@switch3# set protocols ospf vrf vrf2 network 21.251.201.0/24 area 1.1.1.1

 Step4         Commit the configuration.

admin@switch3# commit

Verify the Configuration

  • You can use the run show vrf command to view the binding information between VRFs and the Layer 3 VLAN interfaces.

admin@switch1# run show vrf Vrf Description Interfaces ---------- --------------- ------------------------- vrf1 orange vlan10,vlan11 vrf2 purple vlan20,vlan21 admin@switch2# run show vrf Vrf Description Interfaces ---------- --------------- ------------------------- vrf1 orange vlan10 vrf2 purple vlan20
  • You can use the run show route vrf command to check the routing table information of the specific VRF.

admin@switch3# run show route vrf vrf1 show ip route vrf vrf1 ======================= Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued route, r - rejected route VRF vrf1: K>* 0.0.0.0/0 [255/8192] unreachable (ICMP unreachable), 05:25:24 O>* 10.251.201.0/24 [110/20] via 11.251.201.2, vlan11, weight 1, 01:34:21 O 11.251.201.0/24 [110/10] is directly connected, vlan11, weight 1, 02:48:16 C>* 11.251.201.0/24 is directly connected, vlan11, 02:48:31 show ipv6 route vrf vrf1 ========================= Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued route, r - rejected route VRF vrf1: C>* fe80::/64 is directly connected, vlan11, 02:48:29
  • To the check OSPF neighbor, run the command run show ospf vrf neighbor.

root@switch1# run show ospf vrf vrf1 neighbor VRF Name: vrf1 Neighbor ID Pri State Dead Time Address Interface RXmtL RqstL DBsmL 2.2.2.2 1 Full/DR 36.055s 10.251.201.3 vlan10:10.251.201.2 0 0 0 3.3.3.3 1 Full/Backup 36.899s 11.251.201.4 vlan11:11.251.201.2 0 0 0



Copyright © 2025 Pica8 Inc. All Rights Reserved.