/
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 communicate with each other normally. Meanwhile we will implement the VRF function on Switch 1, Switch 2 and Switch 3 to segregate the users' routing spaces of different Tenants.

Figure1. 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/3

vrf1

VLANIF 11: 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/4

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/4

vrf1

VLANIF 101: 101.251.201.3

Area: 0.0.0.0

Router ID: 2.2.2.2

vrf2

VLANIF 201: 201.251.201.3

Area: 0.0.0.0

Router ID: 2.2.2.2

Switch3

Te-1/1/3

vrf1

VLANIF 100: 100.251.201.3

Area: 1.1.1.1

Router ID: 3.3.3.3

vrf2

VLANIF 200: 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 vlans vlan-id 10
admin@Switch1# set vlans vlan-id 20
admin@Switch1# set vlans vlan-id 11
admin@Switch1# set vlans vlan-id 21
admin@Switch1# set interface gigabit-ethernet te-1/1/3 family ethernet-switching port-mode trunk
admin@Switch1# set interface gigabit-ethernet te-1/1/3 family ethernet-switching vlan members 11
admin@Switch1# set interface gigabit-ethernet te-1/1/3 family ethernet-switching vlan members 21
admin@Switch1# set interface gigabit-ethernet te-1/1/4 family ethernet-switching port-mode trunk
admin@Switch1# set interface gigabit-ethernet te-1/1/4 family ethernet-switching vlan members 10
admin@Switch1# set interface gigabit-ethernet te-1/1/4 family ethernet-switching vlan members 20
admin@Switch1# set vlans vlan-id 10 l3-interface vlan10
admin@Switch1# set vlans vlan-id 20 l3-interface vlan20
admin@Switch1# set vlans vlan-id 11 l3-interface vlan11
admin@Switch1# set vlans vlan-id 21 l3-interface vlan21
admin@Switch1# set vlan-interface interface vlan10 vif vlan10 address 10.251.201.2 prefix-length 24
admin@Switch1# set vlan-interface interface vlan20 vif vlan20 address 20.251.201.2 prefix-length 24
admin@Switch1# set vlan-interface interface vlan11 vif vlan11 address 11.251.201.2 prefix-length 24
admin@Switch1# set vlan-interface interface vlan21 vif vlan21 address 21.251.201.2 prefix-length 24

Step2         Configure VRF.

    a.       Enable IP routing function before using VRF function.

admin@Switch1# set ip routing enable true

    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 vlan-interface interface vlan10 vrf vrf1
admin@Switch1# set vlan-interface interface vlan11 vrf vrf1
admin@Switch1# set vlan-interface interface vlan20 vrf vrf2
admin@Switch1# set vlan-interface interface valn21 vrf vrf2

Step3         Configure basic OSPF functions.

admin@Switch1# set protocols ospf4 vrf vrf1 router-id 1.1.1.1
admin@Switch1# set protocols ospf4 vrf vrf1 area 0.0.0.0 interface vlan10 vif vlan10 address 10.251.201.2
admin@Switch1# set protocols ospf4 vrf vrf1 area 0.0.0.0 interface vlan11 vif vlan11 address 11.251.201.2
admin@Switch1# set protocols ospf4 vrf vrf2 router-id 1.1.1.1
admin@Switch1# set protocols ospf4 vrf vrf2 area 0.0.0.0 interface vlan20 vif vlan20 address 20.251.201.2
admin@Switch1# set protocols ospf4 vrf vrf2 area 0.0.0.0 interface vlan21 vif vlan21 address 21.251.201.2

Step4         Commit the configuration.

admin@Switch1# commit

Switch2

Step1         Configure the VLANs and VLAN interfaces.

admin@Switch2# set vlans vlan-id 101
admin@Switch2# set vlans vlan-id 201
admin@Switch2# set interface gigabit-ethernet te-1/1/4 family ethernet-switching port-mode trunk
admin@Switch2# set interface gigabit-ethernet te-1/1/4 family ethernet-switching vlan members 101
admin@Switch2# set interface gigabit-ethernet te-1/1/4 family ethernet-switching vlan members 201
admin@Switch2# set vlans vlan-id 101 l3-interface vlan101
admin@Switch2# set vlans vlan-id 201 l3-interface vlan201
admin@Switch2# set vlan-interface interface vlan101 vif vlan101 address 10.251.201.3 prefix-length 24
admin@Switch2# set vlan-interface interface vlan201 vif vlan201 address 20.251.201.3 prefix-length 24

Step2         Configure VRF.

  a.       Enable IP routing function before using VRF function.

admin@Switch2# set ip routing enable true

    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 vlan-interface interface vlan101 vrf vrf1
admin@Switch2# set vlan-interface interface vlan201 vrf vrf2

Step3         Configure basic OSPF functions.

admin@Switch2# set protocols ospf4 vrf vrf1 router-id 2.2.2.2
admin@Switch2# set protocols ospf4 vrf vrf1 area 0.0.0.0 interface vlan101 vif vlan101 address 10.251.201.3
admin@Switch2# set protocols ospf4 vrf vrf2 router-id 2.2.2.2
admin@Switch2# set protocols ospf4 vrf vrf2 area 0.0.0.0 interface vlan201 vif vlan201 address 20.251.201.3

Step4         Commit the configuration.

admin@Switch2# commit

Switch3

Step1         Configure the VLANs and VLAN interfaces.

admin@Switch3# set vlans vlan-id 100
admin@Switch3# set vlans vlan-id 200
admin@Switch3# set interface gigabit-ethernet te-1/1/3 family ethernet-switching port-mode trunk
admin@Switch3# set interface gigabit-ethernet te-1/1/3 family ethernet-switching vlan members 10
admin@Switch3# set interface gigabit-ethernet te-1/1/3 family ethernet-switching vlan members 200
admin@Switch3# set vlans vlan-id 100 l3-interface vlan100
admin@Switch3# set vlans vlan-id 200 l3-interface vlan200
admin@Switch3# set vlan-interface interface vlan100 vif vlan100 address 11.251.201.4 prefix-length 24
admin@Switch3# set vlan-interface interface vlan200 vif vlan200 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

    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 vlan-interface interface vlan100 vrf vrf1
admin@Switch3# set vlan-interface interface vlan200 vrf vrf2

Step3         Configure basic OSPF functions.

admin@Switch3# set protocols ospf4 vrf vrf1 router-id 3.3.3.3
admin@Switch3# set protocols ospf4 vrf vrf1 area 1.1.1.1 interface vlan100 vif vlan100 address 10.251.201.4
admin@Switch3# set protocols ospf4 vrf vrf2 router-id 3.3.3.3
admin@Switch3# set protocols ospf4 vrf vrf2 area 1.1.1.1 interface vlan200 vif vlan200 address 20.251.201.4

   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        Vlan-Interfaces
----------   ---------------   ---------------------
vrf1          orange            vlan10,vlan11
vrf2          purple            vlan20,vlan21

admin@Switch2# run show vrf
Vrf           Description           Vlan-Interfaces
----------   ---------------        ------------------
vrf1          orange                 vlan101 
vrf2          purple                 vlan201 
  • You can use the run show route vrf command to check the routing table information of the specific VRF.
admin@Switch2# run show route vrf vrf1
IPv4 Routing table: 3 routes
10.251.201.3/32    [local(0)/0]
                   > via vlan101/vlan101
10.251.201.0/24    [connected(0)/0]
                   > via vlan101/vlan101
11.251.201.0/24    [ospf(110)/2]
                   > to 10.251.201.2 via vlan101/vlan101
 
IPv6 Routing table: 1 routes
fe80::e6f0:4ff:212:173a/128[local(0)/0]
                   > via vlan101/vlan101
 
admin@Switch2# run show route vrf vrf2
IPv4 Routing table: 3 routes
20.251.201.3/32    [local(0)/0]
                   > via vlan201/vlan201
20.251.201.0/24    [connected(0)/0]
                   > via vlan201/vlan201
21.251.201.0/24    [ospf(110)/2]
                   > to 20.251.201.2 via vlan201/vlan201
 
IPv6 Routing table: 1 routes
fe80::e6f0:4ff:312:173a/128[local(0)/0]
                   > via vlan201/vlan201

Copyright © 2025 Pica8 Inc. All Rights Reserved.