cRPD 中的第 3 层叠加支持
概述
cRPD 支持虚拟路由和转发 (VRF) 实例,同时支持 MPLS 和多协议 BGP,以提供叠加功能。
路由实例是路由表、接口和路由协议参数的集合。要实施第 3 层 VPN,请为每个 VPN 配置一个路由实例。VRF 是 Linux 内核中的网络设备,设备与 table-id相关联。只能在 PE 路由器上配置路由实例。您可以在 Linux 网络中创建 VRF。VRF 设备实施仅影响第 3 层及以上层。每个 VPN 路由实例都由以下组件组成:
VRF 表 — 在每个 PE 路由器上,您可为每个 VPN 配置一个 VRF 表。
策略规则 — 这些规则控制将路由导入到 VRF 表中以及从 VRF 表导出路由。
将 CE 路由器路由安装到 VRF 表中的一个或多个路由协议 — 您可以使用 BGP、OSPF 和 RIP 路由协议,也可以使用静态路由。
创建 VRF 设备时,它与路由表相关联。在与 VRF 设备关联的路由表中查找通过从属设备进入 VRF 的数据包。同样,出口路由规则用于先将数据包发送到 VRF 驱动程序,然后再在实际接口上将其发送出去。
VRF 用于根据 VRF 中的独立转发表管理路由和转发流量。RPD 为每个类型的 vrf路由实例创建多个路由表。每个家庭住址各有一个表。您需要为参与 VPN 的每台 PE 路由器上的每个 VPN 配置路由实例。您可以使用 [edit routing-instances] 层次结构配置路由实例。类型的 vrf 路由实例仅在 cRPD 上受支持。
您可以使用 [edit routing-instances routing-instance-name protocols] 层次结构在 VRF 下创建 BFD、BGP、IS-IS、OSPF 版本 2(称为 OSPF)、OSPF 版本 3 (OSPFv3) 和 ICMP 路由器发现的多个实例。您可以使用 edit routing-instances instance-name routing-options 层次结构配置与协议无关的协议无关路由。
第 3 层叠加在 cRPD 中支持以下隧道协议:
inet.3 中的静态路由
BGP 标签单播
GRE 隧道
MPLS 静态 LSP
使用可编程 RPD API 编程的路由
在启用 MPLS 的接口上建立直接 EBGP 对等互连
在 VRF 下配置接口
设备的奴役由 RPD 完成,即在路由实例下配置的接口通过 RPD 使用发送到内核的 netlink 消息迁移(从属)到 vrf 设备。
当在 类型的 vrf路由实例下配置接口时,如果已从内核中学习了此类链路,并且该链路未关联到正确的表,则 RPD 会发送网络链路通知以从属链路。如果链路不存在或 RPD 未了解链路,则每当创建链路或 RPD 了解链路时,都将根据配置正确控制链路。
示例:在 cRPD 实例上配置第 3 层 VPN (VRF)
此示例显示了 PE 路由器和路由反射器上的 VPNv4 路由解析,方法是使用特定策略配置 PE 路由器,以控制路由导入和从 VRF 表导出路由,并使用 BGP 标记的单播获知下一跃点。在本示例中,流量从 CE1 流向 CE2。
要求
此示例使用以下硬件和软件组件:
-
Ubuntu 软件版本 18.04
-
Linux 内核版本 4.5 或更高版本
-
cRPD 软件版本 19.4R1 或更高版本
配置第 3 层 VPN (VRF) 之前,必须安装以下基本组件:
-
创建 cRPD 实例的主机作系统上的 MPLS 模块。有关详细信息,请参阅 在主机作系统上配置设置。
-
提供商 边缘路由器 (PE1)、提供商路由器 (P) 和提供商边缘路由器 (PE2)。有关安装的信息,请参阅 在 Docker 上安装 cRPD。
概述
要配置 VPNv4 路由解析,您需要为参与 VPN 的每台 PE 路由器上的每个 VPN 配置一个 VRF 类型的路由实例,并向其添加静态路由。该 static 语句配置安装在路由表中的 vrfblue.inet.0 静态路由。在 Linux 内核中创建的每个 VRF 设备都没有环路接口或设备。但环路主机地址会直接添加到 VRF 设备中,RPD 可以学习该地址。
配置
使用 BGP LU 配置 PE1 路由器
分步过程
下面的示例要求您在各个配置层级中进行导航。
-
创建表 mpls.0。
user@crpd1# set routing-options rib mpls.0 -
配置接受路由的策略。
[edit policy-options policy-statement] user@crpd1# set EXPORT_LO term 10 from route-filter 10.2.2.2/32 exact user@crpd1# set EXPORT_LO term 10 then accept user@crpd1# set NH_SELF term 10 then next-hop self -
在 PE1 和其他路由实例参数上配置 VRF 路由实例。
[edit routing-instances vrfblue] user@crpd1# set routing-options static route 10.1.1.1/32 next-hop 10.10.10.1 user@crpd1# set instance-type vrf user@crpd1# set route-distinguisher 100:100 user@crpd1# set vrf-target target:100:100 -
配置路由器 ID。
user@crpd1# set routing-options router-id 10.2.2.2 -
配置 BGP 会话。
[edit protocols bgp group] user@crpd1# set underlay type external family inet unicast user@crpd1# set underlay type external export EXPORT_LO neighbor 10.20.20.3 family inet labeled-unicast resolve-vpn user@crpd1# set underlay type external export EXPORT_LO neighbor 10.20.20.3 peer-as 65002 local-as 65001 user@crpd1# set VPN type internal local-address 10.2.2.2 family inet-vpn unicast user@crpd1# set VPN local-as 65005 user@crpd1# set VPN neighbor 10.4.4.4 family inet-vpn unicast -
在 MPLS 上配置接口。
user@crpd1# set protocols mpls interface all
结果
在配置模式下,输入 show protocols bgp 和 show routing-instances 命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明,以便进行更正。
user@crpd1# show routing-instances
vrfblue {
routing-options {
static {
route 10.1.1.1/32 next-hop 10.10.10.1;
}
}
instance-type vrf;
route-distinguisher 100:100;
vrf-target target:100:100;
}
user@crpd1# show protocols bgp
group underlay {
type external;
family inet {
unicast;
}
export EXPORT_LO;
neighbor 10.20.20.3 {
family inet {
labeled-unicast {
resolve-vpn;
}
}
peer-as 65002;
local-as 65001;
}
neighbor 10.20.20.2 {
family inet {
labeled-unicast {
resolve-vpn;
}
}
peer-as 65001;
local-as 65002;
}
neighbor 10.30.30.4 {
family inet {
labeled-unicast {
resolve-vpn;
}
}
peer-as 65003;
local-as 65004;
}
}
group VPN {
type internal;
local-address 10.2.2.2;
family inet-vpn {
unicast;
}
local-as 65005;
neighbor 10.4.4.4 {
family inet-vpn {
unicast;
}
}
}
如果完成设备配置,请从配置模式进入提交。
使用 BGP LU 配置 P 路由器
分步过程
下面的示例要求您在各个配置层级中进行导航。
-
创建表 mpls.0。
user@crpd2# set routing-options rib mpls.0 -
配置接受路由的策略。
[edit policy-options policy-statement] user@crpd2# set EXPORT_LO term 10 from route-filter 10.3.3.3/32 exact user@crpd2# set EXPORT_LO term 10 then accept user@crpd2# set NH_SELF term 10 then next-hop self -
配置 BGP 会话。
[edit protocols bgp group] user@crpd2# set underlay type external export EXPORT_LO neighbor 10.20.20.2 family inet labeled-unicast resolve-vpn user@crpd2# set underlay type external export EXPORT_LO neighbor 10.20.20.2 peer-as 65001 user@crpd2# set underlay type external export EXPORT_LO neighbor 10.20.20.2 local-as 65002 user@crpd2# set underlay type external export EXPORT_LO neighbor 10.30.30.4 family inet labeled-unicast resolve-vpn user@crpd2# set underlay type external export EXPORT_LO neighbor 10.30.30.4 peer-as 65003 user@crpd2# set underlay type external export EXPORT_LO neighbor 10.30.30.4 local-as 65004 -
配置路由器 ID。
user@crpd2# set routing-options router-id 10.3.3.3 -
在 MPLS 上配置接口。
user@crpd2# set protocols mpls interface all
结果
在配置模式下,输入 show protocols bgp 和 show policy-options 命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明以更正配置。
user@crpd2# show protocols bgp
group underlay {
type external;
export EXPORT_LO;
neighbor 10.20.20.2 {
family inet {
labeled-unicast {
resolve-vpn;
}
}
peer-as 65001;
local-as 65002;
}
neighbor 10.30.30.4 {
family inet {
labeled-unicast {
resolve-vpn;
}
}
peer-as 65003;
local-as 65004;
}
}
user@crpd2# show policy-options
policy-statement EXPORT_LO {
term 10 {
from {
route-filter 10.3.3.3/32 exact;
}
then accept;
}
}
policy-statement NH_SELF {
term 10 {
then {
next-hop self;
}
}
}
使用 BGP LU 配置 PE2 路由器
分步过程
下面的示例要求您在各个配置层级中进行导航。
-
创建表 mpls.0。
user@crpd3# set routing-options rib mpls.0 -
配置接受路由的策略。
[edit policy-options policy-statement] user@crpd3# set EXPORT_LO term 10 from route-filter 10.4.4.4/32 exact user@crpd3# set EXPORT_LO term 10 then accept user@crpd3# set NH_SELF term 10 then next-hop self -
在 PE2 和其他路由实例参数上配置 VRF 路由实例。
[edit routing-instances vrfblue] user@crpd3# set routing-options static route 10.5.5.5/32 next-hop 10.40.40.5 user@crpd3# set instance-type vrf user@crpd3# set route-distinguisher 100:100 user@crpd3# set vrf-target target:100:100 user@crpd3# set interface all -
配置 BGP 会话。
[edit protocols bgp group] user@crpd3# set underlay type external export EXPORT_LO neighbor 10.30.30.3 family inet labeled-unicast resolve-vpn user@crpd3# set underlay type external export EXPORT_LO neighbor 10.30.30.3 peer-as 65004 user@crpd3# set underlay type external export EXPORT_LO neighbor 10.30.30.3 local-as 65003 user@crpd3# set VPN type internal local-address 10.4.4.4 family inet-vpn unicast user@crpd3# set VPN local-as 65005 user@crpd3# set VPN neighbor 10.2.2.2 family inet-vpn unicast -
配置路由器 ID。
user@crpd3# set routing-options router-id 10.4.4.4 -
在 MPLS 上配置接口。
user@crpd3# set protocols mpls interface all
结果
在配置模式下,输入 show protocols bgp 和 show routing-instances 命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明以更正配置。
user@crpd3# show protocols bgp
group underlay {
export EXPORT_LO;
neighbor 10.30.30.3 {
family inet {
labeled-unicast {
resolve-vpn;
}
}
peer-as 65004;
local-as 65003;
}
}
group VPN {
type internal;
local-address 10.4.4.4;
family inet-vpn {
unicast;
}
local-as 65005;
neighbor 10.2.2.2 {
family inet-vpn {
unicast;
}
}
}
user@crpd3# show routing-instances
vrfblue {
routing-options {
static {
route 10.5.5.5/32 next-hop 10.40.40.5;
}
}
interface all;
instance-type vrf;
route-distinguisher 100:100;
vrf-target target:100:100;
}
验证
验证 PE1 上的 VPNv4 解析
目的
要验证 PE1 上的 VPNv4 路由,请执行以下作:
行动
在作模式下,输入 show route table vrfblue.inet.0 10.5.5.5 命令:
user@crpd1> show route table vrfblue.inet.0 10.5.5.5
vrfblue.inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
10.5.5.5/32 *[BGP/170] 00:00:14, localpref 100, from 10.4.4.4
AS path: I, validation-state: unverified
> to 10.20.20.3 via pe1-p, Push 299808, Push 299792(top)
在作模式下,输入 show route table mpls.0 命令:
user@crpd1> show route table mpls.0
mpls.0: 3 destinations, 3 routes (3 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
299808 *[VPN/170] 00:01:45
> to 10.10.10.1 via pe1-ce1, Pop
299808(S=0) *[VPN/170] 00:01:45
> to 10.10.10.1 via pe1-ce1, Pop
299824 *[VPN/170] 00:01:45
receive table vrfblue.inet.0, Pop
在 bash 模式下,输入 ip route list table 5 5.5.5.5 命令:
user@crpd1> ip route list table 5 10.5.5.5
10.5.5.5 encap mpls 299792/299808 via 10.20.20.3 dev pe1-p proto 22
在 bash 模式下,输入 ip -f mpls route 命令:
user@crpd1> ip -f mpls route
299808 via inet 10.10.10.1 dev pe1-ce1 proto 22
意义
您可以查看 PE1 在 CE2 下 vrfblue.inet.0 有一个到 CE2 的路由,该路由是通过下一跃点 10.4.4.4 从 PE2 获知的,该路由使用 P 路由器的 BGP LU 进行解析。
验证 P 上的 BGP LU
目的
要验证 P 上的 VPNv4 路由,请执行以下作:
行动
在 bash 模式下,输入 ip -f mpls route show 命令:
user@crpd2> ip -f mpls route show
299776 via inet 10.20.20.2 dev p-pe1 proto 22 299792 via inet 10.30.30.4 dev p-pe2 proto 22
在作模式下,输入 show route table mpls.0 命令:
user@crpd2> show route table mpls.0
mpls.0: 8 destinations, 8 routes (8 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
0 *[MPLS/0] 01:40:42, metric 1
Receive
1 *[MPLS/0] 01:40:42, metric 1
Receive
2 *[MPLS/0] 01:40:42, metric 1
Receive
13 *[MPLS/0] 01:40:42, metric 1
Receive
299776 *[VPN/170] 01:19:24
> to 10.20.20.2 via p-pe1, Pop
299776(S=0) *[ VPN/170] 01:19:24
> to 10.20.20.2 via p-pe1, Pop
299792 *[VPN/170] 01:19:20
> to 10.30.30.4 via p-pe2, Pop
299792(S=0) *[VPN/170] 01:19:20
> to 10.30.30.4 via p-pe2, Pop
意义
您可以查看从 P 到 PE1 和 P 到 PE2 的 MPLS 和 VPN 路由。
验证 PE2 上的 VPNv4 解析
目的
要验证 PE2 上的 VPNv4 路由,请执行以下作:
行动
在作模式下,输入 show route table vrfblue.inet.0 10.1.1.1 命令:
user@crpd3> show route table vrfblue.inet.0 10.1.1.1
vrfblue.inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
10.1.1.1/32 *[BGP/170] 00:00:26, localpref 100, from 10.2.2.2
AS path: I, validation-state: unverified
> to 10.30.30.3 via pe2-p, Push 299808, Push 299776(top)
在作模式下,输入 show route table mpls.0 命令:
user@crpd3> show route table mpls.0
mpls.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
0 *[MPLS/0] 01:34:39, metric 1
Receive
1 *[MPLS/0] 01:34:39, metric 1
Receive
2 *[MPLS/0] 01:34:39, metric 1
Receive
13 *[MPLS/0] 01:34:39, metric 1
Receive
299808 *[VPN/170] 00:00:43
> to 10.40.40.5 via pe2-ce2, Pop
299808(S=0) *[VPN/170] 00:00:43
> to 10.40.40.5 via pe2-ce2, Pop
299824 *[VPN/170] 00:00:43
receive table vrfblue.inet.0, Pop
在 bash 模式下,输入 ip route list table 5 10.1.1.1 命令:
user@crpd3> ip route list table 5 10.1.1.1
10.1.1.1 encap mpls 299776/299808 via 10.30.30.3 dev pe2-p proto 22
在 bash 模式下,输入 ip -f mpls route 命令:
user@crpd3> ip -f mpls route
299808 via inet 10.40.40.5 dev pe2-ce2 proto 22
意义
在 PE2 路由器上,PE1 使用 BGP LU(大约 10.1.1.1)作为 VPNv4 前缀,下一跃点为 10.2.2.2,显示 VRF 表 vrfblue.inet.0 的路由。
