cRPD 中的 3 层叠加支持
了解 cRPD 中的第 3 层叠加 VRF 支持
从 Junos OS 19.4R1 版开始,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 上受支持。
您可以使用层次结构在 VRF [edit routing-instances routing-instance-name protocols]
下创建 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 迁移(奴役)到 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 设备中,而 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 routing-instances
命令以确认show protocols bgp
您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明,以便进行更正。
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 policy-options
命令以确认show protocols bgp
您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以更正配置。
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 routing-instances
命令以确认show protocols bgp
您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以更正配置。
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 下 vrfblue.inet.0
到 CE2 的路由,该路由是从 PE2 与下一跳 10.4.4.4.4 学习的,该路由使用来自 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
的路由。