Context & Why: Multi-Tenant Isolation with MPLS L3VPN on Linux
Run a shared infrastructure or small ISP backbone for long enough, and plain IP routing hits a wall. Two customers will inevitably pick the same private subnet—like 10.10.1.0/24—for their offices. Suddenly, your core routers have no idea whose packets belong to whom.
VLANs solve this at Layer 2, but stretching broadcast domains across a routed backbone gets messy fast. MPLS Layer 3 VPN (L3VPN) handles it cleanly at Layer 3. You don’t need a $20,000 hardware router to run it, either. Standard Linux—with kernel VRF devices and FRRouting (FRR)—gives you a full MPLS data and control plane.
Three components do the heavy lifting on a Linux Provider Edge (PE) router:
- Linux VRF: Creates isolated kernel routing tables per tenant so overlapping IP ranges never collide.
- OSPF & LDP (Label Distribution Protocol): Builds loopback reachability and distributes outer transport labels across the core.
- MP-BGP (VPNv4): Exchanges tenant prefixes along with Route Distinguishers (RD), Route Targets (RT), and inner VPN service labels between PE routers.
Installation: Preparing the Linux Kernel and FRRouting
Most modern distributions—including Ubuntu 22.04/24.04 and Debian 12 (kernel 5.15 and 6.x)—ship with MPLS kernel modules, but leave them unloaded. On each router in your lab (PE1, P, and PE2), load the modules and persist them across reboots.
sudo modprobe mpls_router
sudo modprobe mpls_iptunnel
sudo modprobe mpls_gso
cat <<EOF | sudo tee /etc/modules-load.d/mpls.conf
mpls_router
mpls_iptunnel
mpls_gso
EOF
Next, tune the kernel sysctl parameters. You need IP forwarding on, a 20-bit MPLS label table (up to 1,048,575 labels), and MPLS input enabled on every core-facing NIC. On the P router, remember to enable MPLS input on both core interfaces (eth0 and eth1).
cat <<EOF | sudo tee /etc/sysctl.d/99-mpls.conf
net.ipv4.ip_forward = 1
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.mpls.platform_labels = 1048575
net.mpls.conf.lo.input = 1
net.mpls.conf.eth0.input = 1
EOF
sudo sysctl --system
Why set rp_filter = 0? Asymmetric paths and VRF-encapsulated traffic often trigger strict reverse-path filtering, causing the kernel to drop valid packets silently. Turning it off avoids hours of head-scratching.
Also keep MTU in mind. Each MPLS label adds 4 bytes, so a standard two-label L3VPN stack adds 8 bytes of overhead. Bump your core interfaces to at least MTU 1508 (or 9000 for jumbo frames) if you want full 1500-byte customer packets to pass without fragmentation.
With the kernel ready, install FRRouting on Debian or Ubuntu:
sudo apt update
sudo apt install -y frr frr-pythontools
FRR ships with most routing daemons turned off. Enable ospfd, ldpd, and bgpd in /etc/frr/daemons, then restart the service:
sudo sed -i 's/ospfd=no/ospfd=yes/' /etc/frr/daemons
sudo sed -i 's/ldpd=no/ldpd=yes/' /etc/frr/daemons
sudo sed -i 's/bgpd=no/bgpd=yes/' /etc/frr/daemons
sudo systemctl restart frr
Configuration: Building VRF, LDP, and MP-BGP VPNv4
Let’s wire up a three-router core: PE1 (1.1.1.1/32) — P (2.2.2.2/32) — PE2 (3.3.3.3/32). Link PE1 to P over 172.16.12.0/30 and P to PE2 over 172.16.23.0/30. Both Customer A and Customer B use identical overlapping subnets: 10.10.1.0/24 behind PE1 and 10.10.2.0/24 behind PE2.
1. Creating Linux VRFs and Binding Tenant Interfaces
Create a VRF device per tenant on PE1 and PE2, assign each a unique kernel routing table ID (10 and 20), and bring them up. Then bind the customer NICs—eth1 for Customer A and eth2 for Customer B.
# Create VRFs on PE1
sudo ip link add vrf-cust-a type vrf table 10
sudo ip link set dev vrf-cust-a up
sudo ip link add vrf-cust-b type vrf table 20
sudo ip link set dev vrf-cust-b up
# Attach customer interfaces to their respective VRFs
sudo ip link set dev eth1 master vrf-cust-a
sudo ip addr add 10.10.1.1/24 dev eth1
sudo ip link set dev eth1 up
sudo ip link set dev eth2 master vrf-cust-b
sudo ip addr add 10.10.1.1/24 dev eth2
sudo ip link set dev eth2 up
On PE1, both eth1 and eth2 hold the exact same IP (10.10.1.1/24) without colliding. Separate kernel routing tables keep them completely blind to each other. On PE2, repeat the same VRF setup using 10.10.2.1/24 on both customer interfaces.
2. Configuring Core OSPF and LDP for Label Switching
Drop into the FRR shell with sudo vtysh. On PE1, bring up OSPF in Area 0 for loopback reachability and enable LDP on eth0. Keep the LDP router-id and transport address identical to your loopback IP.
configure terminal
!
interface lo
ip address 1.1.1.1/32
ip ospf area 0
!
interface eth0
ip address 172.16.12.1/30
ip ospf area 0
!
router ospf
ospf router-id 1.1.1.1
!
mpls ldp
router-id 1.1.1.1
address-family ipv4
discovery transport-address 1.1.1.1
interface eth0
!
!
end
write memory
Apply the same pattern on P (2.2.2.2/32, with eth0 at 172.16.12.2/30 and eth1 at 172.16.23.1/30) and PE2 (3.3.3.3/32, with eth0 at 172.16.23.2/30). Notice what the P router does not need: no BGP, and no VRFs. That separation is what keeps an MPLS core fast and simple.
3. Setting Up MP-BGP VPNv4 and VRF Route Targets
Edge routers handle the tenant state. Configure an iBGP session under AS 65000 between PE1 and PE2 for the ipv4 vpn address family, then map each VRF with its own Route Distinguisher (RD) and Route Target (RT).
configure terminal
!
router bgp 65000
bgp router-id 1.1.1.1
no bgp default ipv4-unicast
neighbor 3.3.3.3 remote-as 65000
neighbor 3.3.3.3 update-source lo
!
address-family ipv4 vpn
neighbor 3.3.3.3 activate
exit-address-family
!
router bgp 65000 vrf vrf-cust-a
address-family ipv4 unicast
redistribute connected
label vpn export auto
rd vpn export 65000:10
rt vpn both 65000:10
export vpn
import vpn
exit-address-family
!
router bgp 65000 vrf vrf-cust-b
address-family ipv4 unicast
redistribute connected
label vpn export auto
rd vpn export 65000:20
rt vpn both 65000:20
export vpn
import vpn
exit-address-family
!
end
write memory
Mirror this configuration on PE2, pointing neighbor 1.1.1.1 back to PE1. Setting label vpn export auto tells FRR to allocate a unique MPLS service label per VRF and install it straight into the Linux kernel.
Verification & Monitoring: Checking Labels, VRFs, and Traffic
Once all three routers are configured, verify the stack from the control plane down to the wire.
Start inside vtysh by checking that LDP neighbors are up and labels are bound:
sudo vtysh -c "show mpls ldp neighbor"
sudo vtysh -c "show mpls ldp binding"
Look for an OPERATIONAL LDP session between PE1 and P, plus a remote label bound to 3.3.3.3/32. Next, verify that MP-BGP is exchanging VPNv4 routes with their RDs and service labels:
sudo vtysh -c "show bgp ipv4 vpn"
Now check what FRR actually programmed into the Linux kernel:
# Check kernel MPLS forwarding table
ip -M route show
# Check Customer A's isolated routing table
ip route show vrf vrf-cust-a
In Customer A’s table, the remote 10.10.2.0/24 prefix should show an encap mpls action pushing two labels—for example, outer LDP label 16 and inner VPN label 80—toward PE2.
Finish with an end-to-end ping from inside Customer A’s VRF while sniffing eth0 with tcpdump:
# Ping PE2's Customer A interface from PE1's VRF
sudo ip vrf exec vrf-cust-a ping -c 4 10.10.2.1
# Capture MPLS-tagged packets on the core link in another terminal
sudo tcpdump -i eth0 -n mpls
In the capture, you will see two stacked MPLS headers on every ICMP packet leaving eth0. Customer A reaches 10.10.2.1 across the core, Customer B stays isolated on the exact same IP space, and your Linux MPLS L3VPN fabric is live.

