Virtual Routing and Forwarding (VRF) enables multiple independent routing tables to coexist on a single Linux system, effectively creating isolated network namespaces for different tenants, services, or applications. VRF is the Linux equivalent of Cisco’s VRF-lite, allowing a single server to act as multiple virtual routers.
In this guide, we compare three approaches to self-hosted VRF management: FRRouting (VRF-aware routing), Linux VRF (kernel-native), and Netavark (container-focused VRF) — covering architecture, configuration, Docker deployment, and production use cases.
What Is VRF and Why Does It Matter?
VRF (Virtual Routing and Forwarding) creates isolated routing domains on a single system. Each VRF has its own routing table, ARP cache, and network interfaces. Traffic in one VRF cannot reach another VRF without explicit policy-based routing or a gateway.
Key use cases for VRF:
- Multi-tenant isolation: Separate routing for different customers on shared infrastructure
- Service separation: Isolate management, production, and backup traffic
- Container networking: Per-container or per-pod routing tables
- Testing environments: Run conflicting network configurations on the same host
- Network function virtualization: Deploy multiple virtual routers on commodity hardware
Without VRF, you need separate physical machines or full network namespaces for routing isolation. VRF provides isolation at the routing layer while sharing the same kernel, reducing resource overhead.
Comparison: FRRouting vs Linux VRF vs Netavark
| Feature | FRRouting VRF | Linux Kernel VRF | Netavark VRF |
|---|---|---|---|
| Type | Routing daemon VRF | Kernel-level VRF device | Container network VRF |
| Isolation Level | Routing table + protocol | Full routing + interface | Container network namespace |
| BGP per VRF | Yes (native) | Via FRR/iproute2 | Via container runtime |
| OSPF per VRF | Yes (native) | Via FRR/iproute2 | No |
| Interface Binding | Yes | Yes (vrf device) | Via CNI |
| Policy-Based Routing | Via zebra | Via iproute2 rules | Via iptables/nftables |
| Management Tool | vtysh | iproute2 (ip vrf) | netavark CLI |
| Docker Integration | Via host network | Via host network | Native (Podman) |
| Container Runtime | Any | Any | Podman (native) |
| VLAN Integration | Yes | Yes | Via CNI plugins |
| VXLAN Integration | Yes | Yes | Via CNI plugins |
| Performance | Kernel-speed | Kernel-speed | Kernel-speed |
| GitHub Stars (OVS) | FRR: 4,132+ | Linux kernel | Netavark: 680+ |
| License | GPL-2.0 | GPL-2.0 | Apache-2.0 |
| Primary Language | C | C | Rust |
FRRouting VRF — Full Protocol Support per VRF
FRRouting provides the most comprehensive VRF implementation among open-source routing daemons. Each VRF gets its own instance of every routing protocol (BGP, OSPF, IS-IS, RIP, PIM), with full configuration isolation.
Key Features
- Per-VRF routing protocols: Independent BGP, OSPF, IS-IS instances per VRF
- VRF-aware RIB: Separate Routing Information Base per VRF
- Route leaking: Controlled route exchange between VRFs
- VRF-aware BGP: Per-VRF BGP sessions, route maps, and policies
- Integration with kernel VRF: Uses Linux kernel VRF devices as the underlying mechanism
- Multi-tenant BGP: Run separate BGP AS numbers per VRF
Docker Compose Deployment
| |
frr.conf (multi-VRF BGP + OSPF):
| |
daemons file:
| |
Native Configuration
| |
Linux Kernel VRF — Lightweight and Native
The Linux kernel includes native VRF support through the vrf device type (available since kernel 4.3). It provides routing table isolation at the kernel level, which can be used with or without a routing daemon.
Key Features
- Kernel-native: No userspace daemon required for basic VRF operation
- Lightweight: Minimal resource overhead — just a virtual device
- iproute2 integration: Standard
ip vrfcommands for management - Policy routing: Use
ip ruleto direct traffic into specific VRFs - Works with any routing daemon: Compatible with FRR, BIRD, or static routes
- Socket binding: Applications can bind sockets to specific VRFs
Native Configuration
| |
Persistent configuration (/etc/network/interfaces):
| |
Running Services in a VRF
| |
Netavark — Container-Focused VRF Management
Netavark is the default network stack for Podman (and an alternative for Docker via plugins). It manages container networking with built-in VRF-like isolation through network namespaces and custom CNI plugins.
Key Features
- Podman native: Default networking backend for Podman 4.0+
- Rust-based: Fast, memory-safe implementation
- Bridge and macvlan drivers: Multiple network topologies
- DNS integration: Built-in DNS resolver for container names
- Firewall support: iptables and nftables backends
- Aardvark DNS: Companion DNS server for container name resolution
Docker/Podman Deployment
| |
Create isolated networks with Netavark:
| |
Netavark configuration (/etc/containers/networks/red-net.json):
| |
Netavark with Custom Routing
| |
Choosing the Right VRF Approach
Choose FRRouting VRF when:
- You need per-VRF routing protocols (BGP, OSPF, IS-IS)
- You’re building a multi-tenant routing platform
- You need route leaking between VRFs with policy control
- You want full BGP per VRF with independent AS numbers
- You’re replacing physical routers with a software solution
- You need VRF-aware BFD for fast failure detection per VRF
Choose Linux Kernel VRF when:
- You need lightweight VRF isolation without routing daemons
- You want static routing per VRF with
ip route vrf - You need application-level VRF binding (
ip vrf exec) - You’re building server multi-homing with separate management/production VRFs
- You want minimal resource overhead (no userspace daemon)
- You need policy-based routing with
ip rule
Choose Netavark when:
- You’re running containerized workloads with Podman
- You need automatic DNS resolution between containers
- You want built-in firewall integration (iptables/nftables)
- You prefer Rust-based tooling for reliability
- You need CNI-compatible network plugins
- You’re deploying microservices with isolated networking
VRF Best Practices
- Plan VRF naming carefully: Use descriptive names (mgmt, production, backup) for maintainability
- Document route leaking: Any route exchange between VRFs should be documented and reviewed
- Use VRF-aware monitoring: Standard tools like
pingandtracerouteneedip vrf execprefix - Test failover per VRF: Each VRF may have different failure characteristics — test independently
- Monitor VRF routing tables: Use
ip route show vrf <name>orvtysh -c "show ip route vrf <name>" - Combine with BFD: Use BFD (see our BFD guide) for fast failure detection per VRF
- Use policy-based routing carefully:
ip ruleentries are processed in order — misconfigured rules can break connectivity
Why Self-Host VRF Infrastructure?
VRF technology lets you consolidate multiple virtual routers onto a single physical server, reducing hardware costs while maintaining network isolation. With open-source VRF implementations, you can:
- Replace expensive hardware routers with commodity servers running FRR
- Isolate tenant networks on shared infrastructure without VM overhead
- Build multi-tenant cloud platforms with per-tenant routing
- Test network configurations in isolated VRFs before production deployment
- Run conflicting services (overlapping IP ranges) on the same host
For GRE tunneling between VRF endpoints, see our GRE tunnel management guide. If you need BFD failure detection per VRF, check our BFD protocol daemons article. For VXLAN overlay networks with VRF integration, our VXLAN tunneling guide covers the setup.
FAQ
What is VRF and how does it differ from network namespaces?
VRF (Virtual Routing and Forwarding) creates isolated routing tables within the same network namespace. Network namespaces create completely isolated network stacks (interfaces, routing, iptables). VRF is lighter weight — interfaces in different VRFs share the same namespace but have separate routing tables. Use VRF for routing isolation; use network namespaces for complete network stack isolation.
Can I run BGP in multiple VRFs simultaneously?
Yes, FRRouting supports per-VRF BGP instances. Each VRF can have its own BGP process with independent AS numbers, neighbors, and routing policies. Configure with router bgp <AS> vrf <name> in FRR. This is commonly used in multi-tenant environments where each tenant needs their own BGP peering.
How do I run a command inside a VRF context?
Use ip vrf exec <vrf-name> <command>. For example: ip vrf exec mgmt ping 10.0.0.1 or ip vrf exec production curl http://10.0.0.100. For systemd services, use BindToVRF=<name> in the service unit file.
What is route leaking between VRFs?
Route leaking is the controlled exchange of routes between VRFs. It allows selective traffic flow between isolated routing domains. In FRRouting, configure route leaking with route-maps and redistribution between VRF instances. In Linux kernel VRF, use policy-based routing (ip rule) to forward traffic between VRF tables.
Does VRF work with Docker containers?
Docker uses network namespaces, not VRFs. Each Docker container gets its own network namespace with separate interfaces and routing. Netavark (Podman’s network stack) provides similar isolation with additional features like built-in DNS. For VRF-like isolation in Docker, use macvlan or ipvlan drivers with separate subnets.
How many VRFs can Linux support?
Linux can support thousands of VRFs. Each VRF is a lightweight virtual device with its own routing table. The practical limit depends on available memory and the routing daemon’s capacity. FRRouting routinely supports 100+ VRFs with full BGP/OSPF per VRF on standard server hardware.
Can I combine VRF with VXLAN?
Yes, VRF and VXLAN are commonly used together. VXLAN provides Layer 2 overlay tunneling, while VRF provides Layer 3 routing isolation. In FRRouting, configure VXLAN interfaces inside VRF contexts for per-tenant overlay networks. This is the standard architecture for multi-tenant cloud platforms.