实验拓扑
实验需求
ce1模拟客户a的站点1设备,ce2模拟客户a的站点2设备,ce1及ce2上各有一个loopback接口用来模拟站点内的客户路由。
ce1与pe1之间,ce2与pe2之间运行的pe-ce路由协议是ospf,使用进程号1。
backbone内使用ospf打通骨干内的路由,ospf使用进程号100。
pe1及pe2建立基于loopback的mp-ibgp邻居关系。
完成相关配置,使得客户a的两个站点能够互通。
实验步骤
1.backbone内运行ospf,统一使用进程号100
在pe1、p1、p2、pe2上运行ospf。运行该ospf进程的目的是为了打通backbone内的路由,四台路由器都要通告自己的loopback0网段路由。这个igp打通的路由一方面是为了ldp能够建立起邻接关系,并且能够正常的分发标签,另一方面也是为了pe1及pe2之间能够建立起基于loopback的mp-ibgp邻居关系。
2.backbone内运行ldp
在pe1、p1、p2、pe2上运行mpls及ldp。我的设备上,ldp开始工作后,缺省情况下即会为/32的主机路由捆绑并分发标签。骨干网内四台路由器的loopback路由都会建立lsp。这为后续的客户数据转发做了铺垫。
3.pe1及pe2创建vpn实例,并运行pe-ce路由协议
在pe1及pe2上创建一个vpn实例,命令为abc,将连接到ce的接口添加到这个vpn实例中。同时pe1、pe2均与自己直连的ce路由器运行一个基于vpn实例的ospf进程,统一使用进程号1。务必要注意的是这个ospf进程是基于vpn实例abc(也就是基于虚拟路由器)的,而不是基于全局路由器的。
4.pe1及pe2创建mp-bgp进程,并且建立mp-ibgp邻居关系
pe1及pe2基于loopback建立mp-ibgp邻居关系,激活二者的vpnv4连接。
5.pe1及pe2上配置vpn路由与bgp路由的互重发布
由于pe-ce之间选用的路由协议是ospf,因此为了将路由拉通,需要在两台pe上配置ospf进程1,以及mp-bgp的路由双向重发布。
6.查看及验证
实验配置
1.backbone内运行ospf
本实验中所有设备的接口ip地址的配置这里不再罗列,请自行完成。
backbone内的设备:pe1、pe2、p1、p2运行ospf,统一使用进程号100。运行该ospf进程的目的是为了打通骨干网内的路由,四台设备在互联接口上激活ospf,并且通告自己的loopback0接口路由。
pe1的配置如下:
[pe1] ospf 100 router-id 2.2.2.2[pe1-ospf-100] area 0[pe1-ospf-100-area-0.0.0.0] network 2.2.2.2 0.0.0.0[pe1-ospf-100-area-0.0.0.0] network 10.1.23.2 0.0.0.0
p1的配置如下:
[p1] ospf 100 router-id 3.3.3.3[p1-ospf-100] area 0[p1-ospf-100-area-0.0.0.0] network 3.3.3.3 0.0.0.0[p1-ospf-100-area-0.0.0.0] network 10.1.23.3 0.0.0.0[p1-ospf-100-area-0.0.0.0] network 10.1.34.3 0.0.0.0
p2的配置如下:
[p2] ospf 100 router-id 4.4.4.4[p2-ospf-100] area 0[p2-ospf-100-area-0.0.0.0] network 4.4.4.4 0.0.0.0[p2-ospf-100-area-0.0.0.0] network 10.1.34.3 0.0.0.0[p2-ospf-100-area-0.0.0.0] network 10.1.45.4 0.0.0.0
pe2的配置如下:
[pe2] ospf 100 router-id 5.5.5.5[pe2-ospf-100] area 0[pe2-ospf-100-area-0.0.0.0] network 5.5.5.5 0.0.0.0[pe2-ospf-100-area-0.0.0.0] network 10.1.45.5 0.0.0.0
完成配置后,在各设备上查看路由,确保路由表是正确的,例如r1的路由表:
display ip routing-table protocol ospfdestination/mask proto pre cost flags nexthop interface3.3.3.3/32 ospf 10 1 d 10.1.23.3 gigabitethernet0/0/14.4.4.4/32 ospf 10 2 d 10.1.23.3 gigabitethernet0/0/15.5.5.5/32 ospf 10 3 d 10.1.23.3 gigabitethernet0/0/110.1.34.0/24 ospf 10 2 d 10.1.23.3 gigabitethernet0/0/110.1.45.0/24 ospf 10 3 d 10.1.23.3 gigabitethernet0/0/1
2.backbone内运行mpls及ldp
pe1的配置如下:
[pe1] mpls lsr-id 2.2.2.2 #配置设备的lsr id[pe1] mpls #全局激活mpls[pe1] mpls ldp #全局激活ldp[pe1] interface gigabitethernet 0/0/1[pe1-gigabitethernet0/0/1] mpls #接口激活mpls[pe1-gigabitethernet0/0/1] mpls ldp #接口激活ldp
p1的配置如下:
[p1] mpls lsr-id 3.3.3.3[p1] mpls[p1] mpls ldp[p1] interface gigabitethernet 0/0/0[p1-gigabitethernet0/0/0] mpls[p1-gigabitethernet0/0/0] mpls ldp[p1] interface gigabitethernet 0/0/1[p1-gigabitethernet0/0/1] mpls[p1-gigabitethernet0/0/1] mpls ldp
p2的配置如下:
[p2] mpls lsr-id 4.4.4.4[p2] mpls[p2] mpls ldp[p2] interface gigabitethernet 0/0/0[p2-gigabitethernet0/0/0] mpls[p2-gigabitethernet0/0/0] mpls ldp[p2] interface gigabitethernet 0/0/1[p2-gigabitethernet0/0/1] mpls[p2-gigabitethernet0/0/1] mpls ldp
pe2的配置如下:
[pe2] mpls lsr-id 5.5.5.5[pe2] mpls[pe2] mpls ldp[pe2] interface gigabitethernet 0/0/0[pe2-gigabitethernet0/0/0] mpls[pe2-gigabitethernet0/0/0] mpls ldp
完成配置后,确保所有的ldp邻居关系都正确的建立:
display mpls ldp sessionldp session(s) in public networkcodes: lam(label advertisement mode), ssnage unit(ddddmm)a '*' before a session means the session is being deleted.------------------------------------------------------------------------------peerid status lam ssnrole ssnage kasent/rcv------------------------------------------------------------------------------3.3.3.3:0 operational du passive 000004 20/20------------------------------------------------------------------------------total: 1 session(s) found.
其他设备的查看不再赘述。
display mpls lsp-------------------------------------------------------------------------------lsp information: ldp lsp-------------------------------------------------------------------------------fec in/out label in/out if vrf name2.2.2.2/32 3/null -/-3.3.3.3/32 null/3 -/ge0/0/13.3.3.3/32 1024/3 -/ge0/0/14.4.4.4/32 null/1025 -/ge0/0/14.4.4.4/32 1025/1025 -/ge0/0/15.5.5.5/32 null/1026 -/ge0/0/15.5.5.5/32 1026/1026 -/ge0/0/1
上面输出的是pe1的标签转发表。我们看到关于网络中的/32主机路由都已经收到了标签。
3.pe1及pe2创建vpn实例,并运行pe-ce路由协议
pe1的配置如下:
[pe1] ip vpn-instance abc #创建vpn实例[pe1-vpn-instance-abc] route-distinguisher 2345:1 #配置rd值[pe1-vpn-instance-abc-af-ipv4] vpn-target 2345:11 #配置rt值(导入及导出值均为2345:11)[pe1] interface gigabitethernet 0/0/0[pe1-gigabitethernet0/0/0] ip binding vpn-instance abc #将该接口绑定到vpn实例abc[pe1-gigabitethernet0/0/0] ip address 10.1.12.2 24[pe1] ospf 1 vpn-instance abc #运行基于vpn实例abc的ospf进程[pe1-ospf-1] area 0[pe1-ospf-1-area-0.0.0.0] network 10.1.12.2 0.0.0.0
ce1的配置如下:
[ce1] interface gigabitethernet 0/0/0[ce1-gigabitethernet0/0/0] ip address 10.1.12.1 24[ce1] interface loopback 0[ce1-loopback0] ip address 1.1.1.1 32[ce1] ospf 1 router-id 1.1.1.1[ce1-ospf-1] area 0[ce1-ospf-1-area-0.0.0.0] network 10.1.12.1 0.0.0.0[ce1-ospf-1-area-0.0.0.0] network 1.1.1.1 0.0.0.0
pe2的配置如下:
[pe2] ip vpn-instance abc[pe2-vpn-instance-abc] route-distinguisher 2345:1[pe2-vpn-instance-abc-af-ipv4] vpn-target 2345:11[pe2] interface gigabitethernet 0/0/1[pe2-gigabitethernet0/0/1] ip binding vpn-instance abc[pe2-gigabitethernet0/0/1] ip address 10.1.56.5 24[pe2] ospf 1 vpn-instance abc[pe2-ospf-1] area 0[pe2-ospf-1-area-0.0.0.0] network 10.1.56.5 0.0.0.0
ce2的配置如下:
[ce2] interface gigabitethernet 0/0/0[ce2-gigabitethernet0/0/0] ip address 10.1.56.6 24[ce2] interface loopback 0[ce2-loopback0] ip address 6.6.6.6 32[ce2] ospf 1 router-id 6.6.6.6[ce2-ospf-1] area 0[ce2-ospf-1-area-0.0.0.0] network 10.1.56.6 0.0.0.0[ce2-ospf-1-area-0.0.0.0] network 6.6.6.6 0.0.0.0
完成配置后,确保pe能够学习到直连ce的客户路由:
display ip routing-table vpn-instance abcdestination/mask proto pre cost flags nexthop interface1.1.1.1/32 ospf 10 1 d 10.1.12.1 gigabitethernet0/0/010.1.12.0/24 direct 0 0 d 10.1.12.2 gigabitethernet0/0/010.1.12.2/32 direct 0 0 d 127.0.0.1 gigabitethernet0/0/010.1.12.255/32 direct 0 0 d 127.0.0.1 gigabitethernet0/0/0255.255.255.255/32 direct 0 0 d 127.0.0.1 inloopback0
pe1上vpn实例abc的路由表中已经通过ospf学习到ce1的客户路由1.1.1.1/32。
4.pe1及pe2创建mp-bgp进程,并建立mp-ibgp邻居关系
pe1的配置如下:
[pe1] bgp 2345[pe1-bgp] router-id 2.2.2.2[pe1-bgp] undo default ipv4-unicast #因为本实验中pe1-pe2之间无需交互ipv4路由,因此取消ipv4单播协议的邻居关系自动建立[pe1-bgp] peer 5.5.5.5 as-number 2345[pe1-bgp] peer 5.5.5.5 connect-interface loopback 0[pe1-bgp] ipv4-family vpnv4 unicast #进入ipv4的vpnv4地址族[pe1-bgp-af-vpnv4] peer 5.5.5.5 enable #激活邻居5.5.5.5
pe2的配置如下:
[pe2] bgp 2345[pe2-bgp] router-id 5.5.5.5[pe2-bgp] undo default ipv4-unicast[pe2-bgp] peer 2.2.2.2 as-number 2345[pe2-bgp] peer 2.2.2.2 connect-interface loopback 0[pe2-bgp] ipv4-family vpnv4 unicast[pe2-bgp-af-vpnv4] peer 2.2.2.2 enable[pe2] display bgp vpnv4 all peerbgp local router id : 5.5.5.5local as number : 2345total number of peers : 1 peers in established state : 1peer v as msgrcvd msgsent outq up/down state pref rcv2.2.2.2 4 2345 2 2 0 0036 established 0
pe1及pe2的mp-ibgp邻居(vpnv4)关系已经建立成功。
5.pe1及pe2配置pe-ce路由协议与bgp的相互重发布
pe1的配置如下:
[pe1] bgp 2345[pe1-bgp] ipv4-family vpn-instance abc #将ospf进程1的路由导入到bgp的vpn实例abc对应的ipv4地址族中[pe1-bgp-abc] import-route ospf 1[pe1] ospf 1 vpn-instance abc #将bgp路由导入到ospf进程1[pe1-ospf-1] import-route bgp permit-ibgp
pe2的配置如下:
[pe2] bgp 2345[pe2-bgp] ipv4-family vpn-instance abc[pe2-bgp-abc] import-route ospf 1[pe2] ospf 1 vpn-instance abc[pe2-ospf-1] import-route bgp permit-ibgpdisplay ip routing-table protocol ospfdestination/mask proto pre cost flags nexthop interface6.6.6.6/32 ospf 10 3 d 10.1.12.2 gigabitethernet0/0/010.1.56.0/24 o_ase 150 1 d 10.1.12.2 gigabitethernet0/0/0
ce1已经学习到了ce2所在站点的路由。
display ip routing-table protocol ospfdestination/mask proto pre cost flags nexthop interface1.1.1.1/32 ospf 10 3 d 10.1.56.5 gigabitethernet0/0/010.1.12.0/24 o_ase 150 1 d 10.1.56.5 gigabitethernet0/0/0
ce2也已经学习到了ce1所在站点的路由。
6.查看及验证
[pe1] display bgp vpnv4 all routing-table 6.6.6.6bgp local router id : 2.2.2.2local as number : 2345total routes of route distinguisher(2345 1bgp routing table entry information of 6.6.6.6/32:label information (received/applied): 1027/nullfrom: 5.5.5.5 (5.5.5.5)route duration: 00h11m23srelay ip nexthop: 10.1.23.3relay ip out-interface: gigabitethernet0/0/1relay tunnel out-interface: gigabitethernet0/0/1relay token: 0x5original nexthop: 5.5.5.5qos information : 0x0ext-community:rt , ospf domain id ,ospf rt , ospf router id as-path nil, origin incomplete, med 2, localpref 100, pref-val 0, valid, internal, best, select, pre 255, igp cost 3not advertised to any peer yetvpn-instance abc, router id 2.2.2.2:total number of routes: 1bgp routing table entry information of 6.6.6.6/32:label information (received/applied): 1027/nullfrom: 5.5.5.5 (5.5.5.5)route duration: 00h11m23srelay tunnel out-interface: gigabitethernet0/0/1relay token: 0x5original nexthop: 5.5.5.5qos information : 0x0ext-community:rt , ospf domain id ,ospf rt , ospf router id as-path nil, origin incomplete, med 2, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, igp cost 3not advertised to any peer yet
在pe1上查看路由6.6.6.6/32的详细信息。该条路由是通过mp-ibgp从pe2传递过来的。从详细信息的输出我们可以看到路由的下一跳是5.5.5.5。并且该路由捆绑的vpn标签是1027。因此当pe1收到ip数据包要去往6.6.6.6时,会为数据包压入vpn标签1027,同时为了让这个标签包能够正常的穿越骨干网并到达pe2上,还需为该标签包再增加一层标签。由于去往6.6.6.6的下一跳是5.5.5.5,因此在外层压入5.5.5.5路由对应的标签:
[pe1] display mpls lsp-------------------------------------------------------------------------------lsp information: bgp lsp-------------------------------------------------------------------------------fec in/out label in/out if vrf name1.1.1.1/32 1027/null -/- abc10.1.12.0/24 1028/null -/- abc-------------------------------------------------------------------------------lsp information: ldp lsp-------------------------------------------------------------------------------fec in/out label in/out if vrf name2.2.2.2/32 3/null -/-3.3.3.3/32 null/3 -/ge0/0/13.3.3.3/32 1024/3 -/ge0/0/14.4.4.4/32 null/1025 -/ge0/0/14.4.4.4/32 1025/1025 -/ge0/0/15.5.5.5/32 null/1026 -/ge0/0/15.5.5.5/32 1026/1026 -/ge0/0/1
从上面的输出我们可以看到pe1的标签转发表中,5.5.5.5的出站标签是1026。所以最终去往6.6.6.6的ip包被压入两层标签。内层vpn标签值是1027,外层ldp标签是1026。报文被处理后转发给了p1。p1在收到这个标签包后查看自己的标签转发表,注意,它只会查看外层标签。
[p1]display mpls lsp-------------------------------------------------------------------------------lsp information: ldp lsp-------------------------------------------------------------------------------fec in/out label in/out if vrf name3.3.3.3/32 3/null -/-2.2.2.2/32 null/3 -/ge0/0/02.2.2.2/32 1024/3 -/ge0/0/04.4.4.4/32 null/3 -/ge0/0/14.4.4.4/32 1025/3 -/ge0/0/15.5.5.5/32 null/1026 -/ge0/0/15.5.5.5/32 1026/1026 -/ge0/0/1
从p1的转发表我们可以看出,1026的入站标签,对应的出站标签是1026,并且出站接口是ge0/0/1。因此它将收到的标签包的外层标签从1026置换成1026(碰巧置换前后标签值是一样的),然后从ge0/0/1口发出去。p2将收到这个标签包,也是查标签转发表:
display mpls lsp-------------------------------------------------------------------------------lsp information: ldp lsp-------------------------------------------------------------------------------fec in/out label in/out if vrf name2.2.2.2/32 null/1024 -/ge0/0/02.2.2.2/32 1024/1024 -/ge0/0/04.4.4.4/32 3/null -/-3.3.3.3/32 null/3 -/ge0/0/03.3.3.3/32 1025/3 -/ge0/0/05.5.5.5/32 null/3 -/ge0/0/15.5.5.5/32 1026/3 -/ge0/0/1
p2发现,1026的入站标签,对应的出站标签是3,而3是一个保留标签,意味着要将该顶层标签弹出。于是它将收到的标签数据的顶层标签弹出,然后剩余的数据从ge0/0/1口送出去。pe2将最终收到仍然携带者vpn标签的数据。由于这个vpn标签是它自己发给pe1的,因此它知道这个标签值意味着什么、与哪一个vpn实例对应。因此最终它将vpn标签剥去,然后将ip数据包转发给ce2。
在pe1上tracert 6.6.6.6,可以查看到整个数据层面的过程:
tracert -vpn-instance abc -v -a 10.1.12.2 6.6.6.6traceroute to abc 6.6.6.6(6.6.6.6), max hops: 30 ,packet length: 40,press ctrl_c tobreak1 10.1.23.3[mpls label=1026/1027 exp=0/0 s=0/1 ttl=1/1] 110 ms 60 ms 70 ms2 10.1.34.4[mpls label=1026/1027 exp=0/0 s=0/1 ttl=1/2] 110 ms 50 ms 80 ms3 10.1.56.5 80 ms 80 ms 60 ms4 10.1.56.6 110 ms 80 ms 70 ms
实际上是这样的:
超声波换能报警器
AEG高端家电,让品质成就美好生活
光模块的选择小技巧与使用小常识分享
便携式彩超机有什么功能
关于无人机反制枪的工作原理的简单介绍
华为实验|MPLS VPN基础实验
哈希算法的前世、今生和未来
Molex医疗业务实现强劲增长
NB-IoT的发展优势,nb-iot技术可以自组网吗
腾讯云新一代分布式存储系统发布,支持百亿甚至千亿级文件规模存储
全球第一张规模部署的煤矿井下商用5G专网基本建成
vivo 文档正式发布:支持 AI 识图转文档,可与 Windows、macOS 互传
PCB设计中处理信号完整性的常见问题及解决方案
移动通信技术专业介绍
2022大华存储新品发布会举行,五大系列新品齐登场
国际大厂又一全面屏神机,力战小米MIX!
服务器租用的稳定性对于用户网站至关重要
LG 4K显示器不在欧洲的苹果商店出售
基于LabVIEW的探索频道望远镜控制
法雷奥推出Move Up计划 航盛电子揽获一汽集团三大奖项