MPLS的基础配置

整体拓扑

image-20230919102958463

首先配置各个路由器及接口ip地址

配置OSPF

R1:
[R1-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 1.1.1.1 
 area 0.0.0.0 
  network 10.1.1.1 0.0.0.0 
  network 10.123.12.1 0.0.0.0 
#
return
R2:
[R2-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 2.2.2.2 
 area 0.0.0.0 
  network 10.123.12.2 0.0.0.0 
  network 10.123.23.2 0.0.0.0 
  network 20.1.1.1 0.0.0.0 
#
return
R3:
[R3-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 3.3.3.3 
 area 0.0.0.0 
  network 10.123.23.3 0.0.0.0 
  network 10.123.34.3 0.0.0.0 
  network 30.1.1.1 0.0.0.0 
#
return
R4:
[R4-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 4.4.4.4 
 area 0.0.0.0 
  network 10.123.34.4 0.0.0.0 
  network 10.123.45.4 0.0.0.0 
  network 40.1.1.1 0.0.0.0 
#
return
R5:
[R5-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 5.5.5.5 
 area 0.0.0.0 
  network 10.123.45.5 0.0.0.0 
#
return

在R9上检查路由表

image-20230919105035307

配置MPLS

在R1上配置MPLS

image-20230919110025677

在R2上配置MPLS

image-20230919110212764

在R3上配置MPLS

image-20230919110314888

在R4上配置MPLS

image-20230919110424501

配置MPLS 静态LSP

在R1上配置静态LSP

R1作为ingress设备在去往40.1.1.1/32和 10.123.45.0/24网络时打上标签,同时作为egress设备,当收到标签为201或者205时弹出标签进行路由转发。

[R1]static-lsp ingress 1to4 destination 40.1.1.1 32 nexthop 10.123.12.2 out-labe
l 104
[R1]static-lsp ingress 1to45 destination 10.123.45.0 24 nexthop 10.123.12.2 out-
label 105
[R1]static-lsp egress 4to1 incoming-interface g0/0/0 in-label 201
[R1]static-lsp egress 45to1 incoming-interface g0/0/0 in-label 205

在R2上配置静态LSP

R2作为Transit设备进行标签的交换。

[R2]static-lsp transit 1to4 incoming-interface GigabitEthernet 0/0/0 in-label 10
4 nexthop 10.123.23.3 out-label 204
[R2]static-lsp transit 1to45 incoming-interface GigabitEthernet 0/0/0 in-label 1
05 nexthop 10.123.23.3 out-label 205
[R2]static-lsp transit 4to1 incoming-interface GigabitEthernet0/0/1 in-label 301
 nexthop 10.123.12.1 out-label 201
[R2]static-lsp transit 45to1 incoming-interface GigabitEthernet0/0/1 in-label 30
5  nexthop 10.123.12.1 out-label 205

在R3上配置静态LSP

R3作为Transit设备进行标签交换。

[R3]static-lsp transit 1to4 incoming-interface GigabitEthernet 0/0/0 in-label 20
4 nexthop 10.123.34.4 out-label 304
[R3]static-lsp transit 4to1 incoming-interface GigabitEthernet0/0/1 in-label 401
 nexthop 10.123.23.2 out-label 301
[R3]static-lsp transit 1to45 incoming-interface GigabitEthernet 0/0/0 in-label 2
05 nexthop 10.123.23.3 out-label 305
[R3]static-lsp transit 45to1 incoming-interface GigabitEthernet0/0/1 in-label 40
5 nexthop 10.123.23.2 out-label 305

在R4上配置静态LSP

R4与R1类似,同样既作为ingress设备又作为egress设备。作为ingress设备在去往40.1.1.1/32和 10.123.45.0/24网络时打上标签,同时作为egress设备,当收到标签为201或者205时弹出标签进行路由转发。

[R4]static-lsp egress 1to4 incoming-interface g0/0/0 in-label 304
[R4]static-lsp egress 1to45 incoming-interface g0/0/0 in-label 305
[R4]static-lsp ingress 4to1 destination 10.1.1.1 32 nexthop 10.123.34.3 out-labe
l 401

在R1上查看标签交换路径:

标签路径中有In/Out Label,在mpls中,Out Label为空时,表示该FEC是由本路由器向上游发布标签,该路由器一般是该FEC的egress设备。In Label是指本路由器为某个FEC分配给对端的Out Label标签,当In Label为空时,表示本路由器是该LSP的最上游路由器,一般是ingress设备。

image-20230919113901613

在R2上查看

image-20230919114005814

在R3上查看

image-20230919114040102

在R4上查看

image-20230919114103033

在R1上Ping测试

image-20230919114154599

右键点击R1设备,选择数据抓包中的G0/0/0接口进行抓包。在R1上带环回口ping测试R4的环回口地址。

进入抓包界面,点击源为10.1.1.1,目的地址为40.1.1.1的数据包查看。我们可以观察到,在数据包中存在MPLS的头部,由此,判断出10.1.1.1访问40.1.1.1走的是MPLS的路径。

image-20230919114844462

最后修改:2023 年 09 月 19 日
如果觉得我的文章对你有用,请随意赞赏