
正文共:1141 字 9 图,预估阅读时间:3 分钟
当前SRv6已经具备商用条件了**(** SRv6之SRH:IPv6 段路由报文头) ,但是还不具备实验条件,所以目前实验最多能做到SR**(** Segment Routing之static-sr-mpls:静态配置Segment配置) ,还是基于MPLS的,那就先温习一下MPLS,应该能够帮助理解SR**(** SR?段路由?源路由?Segment Routing Architecture)。
与MPLS相关的协议主要是RFC3031**(** MPLS:多协议标签交换架构) 和RFC3032**(** MPLS 标签栈编码) 。从文档中我们了解到,静态**LSP (Label Switched Path,标签交换路径)**不依靠标签分发协议,而是在报文经过的每一跳设备上(包括Ingress、Transit和Egress)分别手工指定入标签、出标签等信息,建立标签转发表项,采用这种方式建立LSP。
LSP是一条单向路径,在数据传输的两个方向上需要分别配置一条静态LSP。在配置静态LSP时,需要确定静态LSP的Ingress节点、Transit节点和Egress节点。而且相邻的两个**LSR(Label Switching Router,标签交换路由器)**之间,上游LSR的出标签值和下游LSR的入标签值必须相同。
Ingress节点 :根据报文的目的IP地址划分FEC(Forwarding Equivalence Class,转发等价类),为报文添加该FEC对应的出标签,并将报文转发给指定的下一跳,或通过出接口转发该报文。因此,在Ingress上需要指定目的网段对应的出标签、LSP的下一跳或到达下一跳的出接口。
Transit节点:接收到带有标签的报文后,根据报文中携带的标签值,查找标签转发表项,将报文中的标签替换为该标签对应的出标签,并将报文转发给指定的下一跳,或通过出接口转发该报文。因此,Transit上需要指定入标签对应的出标签、LSP的下一跳或到达下一跳的出接口。
Egress节点:如果没有在倒数第二跳弹出标签,则Egress节点上需要指定入标签值。Egress节点接收到带有指定入标签值的报文后,弹出该标签,并对报文进行下一层转发处理。

组网需求

RT1-4均支持MPLS,在RT1到RT4之间建立静态LSP,使11.1.1.0/24和44.1.1.0/24这两个网段中互访的报文能够通过MPLS进行传输。

组网图

静态建立LSP组网图。


实验环境

Windows 10专业版(1909-18363.1556,16 GB内存)
HCL 3.0.1
MSR 36-20(Version 7.1.064, Release 0821P11)

配置步骤

首先按照组网图所示配置各接口的IP地址和掩码。

RT1
当流量是从RT1到RT4时,RT1作为Ingress节点,需要配置到达44.1.1.0/24网段的静态路由。
css
#
ip route-static 44.1.1.0 24 12.1.1.2
在互联接口上开启MPLS功能。
nginx
#
interface GigabitEthernet0/1
ip address 12.1.1.1 255.255.255.0
mpls enable
当流量是从RT1到RT4时,RT1作为Ingress节点,需要配置RT1到RT4的静态LSP。当流量是从RT4到RT1时,RT1作为Egress节点,需要弹出标签,并对报文进行转发。
css
#
static-lsp ingress 1234 destination 44.1.1.0 24 nexthop 12.1.1.2 out-label 120
static-lsp egress 4321 in-label 210

RT2
RT2作为transit节点,和RT1相比,无需配置静态路由,仅需要在互联接口上开启MPLS功能,并配置转发RT1到RT4双向流量的静态LSP即可。直接上配置。
nginx
#
sysname RT2
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
interface GigabitEthernet0/0
ip address 12.1.1.2 255.255.255.0
mpls enable
#
interface GigabitEthernet0/1
ip address 23.1.1.2 255.255.255.0
mpls enable
#
static-lsp transit 1234 in-label 120 nexthop 23.1.1.3 out-label 230
static-lsp transit 4321 in-label 320 nexthop 12.1.1.1 out-label 210

RT3
RT3和RT2的角色是一样的,同为transit节点,配置也相近,直接上配置。
nginx
#
sysname RT3
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
interface GigabitEthernet0/0
ip address 23.1.1.3 255.255.255.0
mpls enable
#
interface GigabitEthernet0/1
ip address 34.1.1.3 255.255.255.0
mpls enable
#
static-lsp transit 1234 in-label 230 nexthop 34.1.1.4 out-label 340
static-lsp transit 4321 in-label 430 nexthop 23.1.1.2 out-label 320

RT4
RT4和RT1的角色相对应,同为双向流量的Ingress节点或Egress节点,直接上配置。
nginx
#
sysname RT4
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
interface GigabitEthernet0/0
ip address 34.1.1.4 255.255.255.0
mpls enable
#
interface GigabitEthernet0/1
ip address 44.1.1.1 255.255.255.0
#
ip route-static 11.1.1.0 24 34.1.1.3
#
static-lsp egress 1234 in-label 340
static-lsp ingress 4321 destination 11.1.1.0 24 nexthop 34.1.1.3 out-label 430

验证配置

配置完成之后,从PCA向PCB发起访问,可以看到能够正常访问。TTL值为251,说明中间经过了4台设备,和实际情况相符合。

抓包查看,从RT1发出的报文如下。

结合RFC3032来看一下报文结构,标签为120,一共是20位,所以允许配置的最大值为1048575。

但是最小却不一定是0,因为有几个保留的标签值。

所以以H3C设备为例,Ingress节点能配置的出标签的取值范围为0,3,16-1048575,Egress节点能配置的入标签的取值范围为16-1023。对应的,Transit节点能配置的入标签的取值范围为16-1023,出标签的取值范围为0,3,16-1048575。
有没有发现一个问题,如果两个Transit节点对接,前者的出标签设置为1024,那后者怎么接收呢?
RT2发出的报文如下,标签值为230,TTL为253。

RT3发出的报文如下,标签值为340,TTL为252。

查看RT1-RT4各台设备上的静态LSP信息。
properties
<RT1>dis mpls static-lsp
Total: 2
Name FEC In/Out Label Nexthop/Out Interface State
1234 44.1.1.0/24 NULL/120 12.1.1.2 Up
4321 -/- 210/NULL - Up
properties
<RT2>dis mpls static-lsp
Total: 2
Name FEC In/Out Label Nexthop/Out Interface State
1234 -/- 120/230 23.1.1.3 Up
4321 -/- 320/210 12.1.1.1 Up
properties
<RT3>dis mpls static-lsp
Total: 2
Name FEC In/Out Label Nexthop/Out Interface State
1234 -/- 230/340 34.1.1.4 Up
4321 -/- 430/320 23.1.1.2 Up
properties
<RT4>dis mpls static-lsp
Total: 2
Name FEC In/Out Label Nexthop/Out Interface State
4321 11.1.1.0/24 NULL/430 34.1.1.3 Up
1234 -/- 340/NULL - Up
从Ingress设备上还可以通过ping mpls ipv4命令用来检测IPv4地址前缀类型MPLS LSP的连通性。

从Transit节点则不可行,因为他没有路由。

怎么样,是不是很简单,你学会了吗?

长按二维码
关注我们吧

<>
TCL + 自动配置功能 = 设备自动上线
<> <>
NAT穿越场景下怎么实现从总部到分支的访问?
<> <>
多分支NAT穿越场景下通过POP节点实现分支间的IPsec加密互联
<> <>
SD-WAN网络中的IPsec流量是怎么转发的?我给你简单演示一下
<> <>
SRv6之SRH:IPv6 段路由报文头
<> <>
MPLS 流量工程要求
<>