VRF - open-switch/opx-docs GitHub Wiki
OPX currently uses the Linux kernel’s network namespace to create VRFs. As a result of this approach, isolation extends beyond Layer 3 (L3). Using namespace also isolates interfaces to a particular namespace — separate processes may need to be created for monitoring services so they monitor their own individual namespace.
Usage
There are two ways to setup VRFs in OPX. The recommended way is to use the opx_config_vrf command, but there is also a way to do it via CPS commands.
VRF configuration script
Setup VRFs using cps_config_vrf.py
root@OPX:~# opx-config-vrf --create --vrf blue
Configuration Successful...
Query VRF info
root@OPX:~# opx-config-vrf --show
Key: 1.292.44.2883617.2883612.2883613.
ni/network-instances/network-instance/name = blue
Key: 1.292.44.2883617.2883612.2883613.
ni/network-instances/network-instance/name = default
Create additional VRF
root@OPX:~# opx-config-vrf --create --vrf red
Configuration Successful...
Query VRF info
root@OPX:~# opx-config-vrf --show
Key: 1.292.44.2883617.2883612.2883613.
ni/network-instances/network-instance/name = red
Key: 1.292.44.2883617.2883612.2883613.
ni/network-instances/network-instance/name = blue
Key: 1.292.44.2883617.2883612.2883613.
ni/network-instances/network-instance/name = default
CPS commands
These example show how to setup VRF using CPS commands.
Create a Management VRF with one interface and separate blue VRF
root@OPX:~# cps_set_oid.py -oper create ni/if/interfaces/interface ni/if/interfaces/interface/bind-ni-name="blue"
root@OPX:~#
root@OPX:~# cps_set_oid.py -oper create ni/if/interfaces/interface ni/if/interfaces/interface/bind-ni-name="management" if/interfaces/interface/name="e101-002-0"
Success
Key: 1.292.44.2883617.2883612.2883613.
vrf-mgmt/ni/if/interfaces/interface/ifname = e101-002-0
vrf-mgmt/ni/if/interfaces/interface/mac-addr = 00:0c:29:df:84:a5
if/interfaces/interface/name = e101-002-0
vrf-mgmt/ni/if/interfaces/interface/ifindex = 14
cps/object-group/return-code = 0
ni/if/interfaces/interface/bind-ni-name = management
Add additional interface to the Management VRF and setup IP address
root@OPX:~# cps_set_oid.py -oper create base-ip/ipv4/address base-ip/ipv4/vrf-name="management" base-ip/ipv4/name="e101-001-0" base-ip/ipv4/address/prefix-length=16 base-ip/ipv4/address/ip=0a0b4618
Query the Management VRF
root@OPX:~# cps_get_oid.py -qua target ni/network-instances ni/network-instances/network-instance/name="management"
============ni/network-instances==========
ni/network-instances/network-instance/name = management
Query all VRFs
root@OPX:~# cps_get_oid.py -qua target ni/network-instances
============ni/network-instances==========
ni/network-instances/network-instance/name = management
------------------------------------------------
ni/network-instances/network-instance/name = blue
------------------------------------------------
ni/network-instances/network-instance/name = default
------------------------------------------------
View VRF info with Linux tools
You can use Linux tools to view VRF information since they are just network namespaces. Do not use Linux tools to manipulate the VRF — use the VRF configuration script.
View list of namespaces (VRFs)
root@OPX:~# ip netns list
blue (id: 1)
default
management (id: 1024)
vportnetns