IP-VRF(8)
โจ IP-VRF(8) โ ip-vrf ๐
Okay bestie, this is the manual page for ip-vrf, the little helper that runs a command against a specific VRF ๐ฆ Let's get into it.
๐ NAME
ip-vrf - run a command against a vrf ๐
๐ธ SYNOPSIS
ip vrf { COMMAND | help }
ip vrf show [ NAME ]
ip vrf identify [ PID ]
ip vrf pids NAME
ip vrf exec [ NAME ] command...
๐ง DESCRIPTION
okay so a VRF gives you traffic isolation at layer 3 for routing, kind of like how a VLAN isolates traffic at layer 2 ๐ซถ Fundamentally? A VRF is just a separate routing table. You associate a network device with a VRF by enslaving the device to it. From that point on, the addresses on that device are local to the VRF, and the host and connected routes get moved into the table tied to the VRF โจ
A process can pick its VRF in a few ways: binding the socket to the VRF device with SO_BINDTODEVICE, setting the association with IP_UNICAST_IF or IPV6_UNICAST_IF, or specifying the VRF for one specific message using IP_PKTINFO or IPV6_PKTINFO ๐
By default a process is not bound to any VRF ๐ It can get an association explicitly (the program uses one of those APIs) or implicitly, through a helper that sets SO_BINDTODEVICE on every IPv4 and IPv6 socket (AF_INET and AF_INET6) when it gets created. This ip-vrf command is that helper: it runs a command against a specific VRF, and the VRF association gets inherited from parent to child ๐
โจ ip vrf show [ NAME ] - Show all configured VRF
This command lists every VRF along with its corresponding table ids ๐
If you give it a NAME, only that VRF and its table id show up. This one is super useful for scripting, when you need the table id for a VRF ๐
๐ฆ ip vrf exec [ NAME ] cmd ... - Run cmd against the named VRF
This command lets apps that are VRF unaware run against a VRF other than the default one (main table) ๐ You can run a command against the default VRF by passing "default" as the VRF name. This is handy if your current shell is already tied to another VRF (e.g, Management VRF) ๐ซถ
โ ๏ธ This command requires the system to be booted with cgroup v2 (e.g. with systemd, add systemd.unified_cgroup_hierarchy=1 to the kernel command line).
โ ๏ธ This command also has to be run as root. Alternatively, an unprivileged user can run it if the following capabilities(7) are given ๐ฅ
CAP_BPFโ to load the BPF program.CAP_NET_ADMINโ to set the socket into the cgroup.CAP_DAC_OVERRIDEโ to create the cgroup subdir in/sys.
If you have these capabilities and ip(8) is built with libcap(3), they get dropped before cmd runs under ip vrf exec. For every other unprivileged invocation of ip(8), all capabilities are dropped ๐
NOTE: capabilities will NOT be dropped if CAP_NET_ADMIN is set to INHERITABLE. This avoids breaking programs with ambient capabilities that call ip ๐
๐ท ip vrf identify [PID] - Report VRF association for process
This command shows the VRF association of the process you specify ๐ง If you don't give a PID, the id of the current process is used โจ
๐ ip vrf pids NAME - Report processes associated with the named VRF
This command shows every process id associated with the VRF you name ๐ฆ
๐ CAVEATS
This command needs a kernel compiled with CGROUPS and CGROUP_BPF enabled ๐
โ ๏ธ The VRF helper only affects network layer sockets. Not everything, bestie ๐ญ
๐ EXAMPLES
ip vrf exec red ssh 10.100.1.254
This runs ssh to 10.100.1.254 against the VRF red table ๐
๐ SEE ALSO
ip(8), ip-link(8), ip-address(8), ip-route(8), ip-neighbor(8) ๐ซถ
๐ AUTHOR
Original Manpage by David Ahern ๐
Bye bestie, go slay the routing tables ๐ฆ๐ โจ (iproute2, 7 Dec 2016 ๐ธ)
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute 7.0.0-2.el10 ยท GPL-2.0-or-later AND NIST-PD
- centos-stream 9: iproute 6.17.0-3.el9 ยท GPL-2.0-or-later AND NIST-PD
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute 6.14.0-2.fc43 ยท GPL-2.0-or-later AND NIST-PD
- fedora 44: iproute 6.17.0-2.fc44 ยท GPL-2.0-or-later AND NIST-PD
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms