Virtual Routing and Forwarding (VRF)
Linux内核的Virtual Routing and Forwarding (VRF) 是由路由表和一组网络设备组成的路由实例。
VRF安装
Ubuntu默认不包括vrf内核模块,需要额外安装:
apt-get install linux-headers-4.10.0-14-generic linux-image-extra-4.10.0-14-generic
reboot
apt-get install linux-image-extra-$(uname -r)
modprobe vrf
VRF示例
# create vrf device
ip link add vrf-blue type vrf table 10
ip link set dev vrf-blue up
# An l3mdev FIB rule directs lookups to the table associated with the device.
# A single l3mdev rule is sufficient for all VRFs.
# Prior to the v4.8 kernel iif and oif rules are needed for each VRF device:
ip ru add oif vrf-blue table 10
ip ru add iif vrf-blue table 10
#Set the default route for the table (and hence default route for the VRF).
ip route add table 10 unreachable default
# Enslave L3 interfa