• 利用sham-link实现路由还原


    实验目的 

    1、理解sham-link作用和限制。

    2、熟练使用Tunnel跨设备完成OSPF邻接关系的建立 。

    3、熟练利用OSPF 选路机制完成BACKDOOR链路的。

    实验拓扑

    接口ip配置

    1. R1(config)#interface e0/0
    2. R1(config-if)#ip address 12.12.12.1 255.255.255.0
    3. R1(config-if)#no shutdown
    4. R1(config-if)#interface e0/1
    5. R1(config-if)#ip address 13.13.13.1 255.255.255.0
    6. R1(config-if)#no shutdown
    7. R1(config)#interface loopback 0
    8. R1(config-if)#ip address 10.1.1.1 255.255.255.0
    9. R2(config)#interface e0/0
    10. R2(config-if)#ip address 12.12.12.2 255.255.255.0
    11. R2(config-if)#no shutdown
    12. R2(config-if)#interface e0/1
    13. R2(config-if)#ip address 25.25.25.2 255.255.255.0
    14. R2(config-if)#no shutdown
    15. R2(config)#interface loopback 0
    16. R2(config-if)#ip address 10.2.2.2 255.255.255.0
    17. R3(config)#interface e0/1
    18. R3(config-if)#ip address 13.13.13.3 255.255.255.0
    19. R3(config-if)#no shutdown
    20. R3(config-if)#interface e0/0
    21. R3(config-if)#ip address 34.34.34.3 255.255.255.0
    22. R3(config-if)#no shutdown
    23. R3(config)#interface loopback 0
    24. R3(config-if)#ip address 10.3.3.3 255.255.255.0
    25. R4(config)#interface e0/0
    26. R4(config-if)#ip address 34.34.34.4 255.255.255.0
    27. R4(config-if)#no shutdown
    28. R4(config-if)#interface e0/1
    29. R4(config-if)#ip address 45.45.45.4 255.255.255.0
    30. R4(config-if)#no shutdown
    31. R4(config)#interface loopback 0
    32. R4(config-if)#ip address 10.4.4.4 255.255.255.0
    33. R5(config)#interface e0/1
    34. R5(config-if)#ip address 45.45.45.5 255.255.255.0
    35. R5(config-if)#no shutdown
    36. R5(config-if)#interface e0/0
    37. R5(config-if)#ip address 25.25.25.5 255.255.255.0
    38. R5(config-if)#no shutdown
    39. R5(config)#interface loopback 0
    40. R5(config-if)#ip add 10.5.5.5 255.255.255.0

    p-network配置(isis\mpls)

    1. R1(config)#router isis
    2. R1(config-router)#net 49.0001.0000.0000.0001.00
    3. R1(config)#interface e0/0
    4. R1(config-if)#ip router isis
    5. R1(config)#interface loopback 0
    6. R1(config-if)#ip router isis
    7. R1(config)#mpls label protocol ldp
    8. R1(config)#mpls label range 100 199
    9. R1(config)#mpls ldp router-id loopback 0
    10. R1(config)#interface e0/0
    11. R1(config-if)#mpls ip
    12. R2(config)#router isis
    13. R2(config-router)#net 49.0001.0000.0000.0002.00
    14. R2(config)#interface e0/0
    15. R2(config-if)#ip router isis
    16. R2(config)#interface loopback 0
    17. R2(config-if)#ip router isis
    18. R2(config)#mpls label protocol ldp
    19. R2(config)#mpls label range 200 299
    20. R2(config)#mpls ldp router-id loopback 0
    21. R2(config)#interface e0/0
    22. R2(config-if)#mpls ip

    查看isis邻接关系建立情况

    1. R1#show clns neighbors
    2. Tag null:
    3. System Id Interface SNPA State Holdtime Type Protocol
    4. R2 Et0/0 aabb.cc00.0200 Up 7 L1L2 IS-IS

    查看mpls邻接关系建立情况

    1. R1#show mpls ldp neighbor
    2. Peer LDP Ident: 10.2.2.2:0; Local LDP Ident 10.1.1.1:0
    3. TCP connection: 10.2.2.2.45343 - 10.1.1.1.646
    4. State: Oper; Msgs sent/rcvd: 13/12; Downstream
    5. Up time: 00:05:13
    6. LDP discovery sources:
    7. Ethernet0/0, Src IP addr: 12.12.12.2
    8. Addresses bound to peer LDP Ident:
    9. 12.12.12.2 25.25.25.2 10.2.2.2

    检查网络联通性

    1. R1#ping 10.2.2.2 source 10.1.1.1
    2. Type escape sequence to abort.
    3. Sending 5, 100-byte ICMP Echos to 10.2.2.2, timeout is 2 seconds:
    4. Packet sent with a source address of 10.1.1.1
    5. !!!!!
    6. Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

    mp-bgp配置

    1. R1(config)#router bgp 12
    2. R1(config-router)#bgp router-id 10.1.1.1
    3. R1(config-router)#neighbor 10.2.2.2 remote-as 12
    4. R1(config-router)#neighbor 10.2.2.2 update-source loopback 0
    5. R1(config-router)#address-family vpnv4
    6. R1(config-router-af)#neighbor 10.2.2.2 activate
    7. R1(config-router-af)#neighbor 10.2.2.2 send-community extended
    8. R2(config)#router bgp 12
    9. R2(config-router)#bgp router-id 10.2.2.2
    10. R2(config-router)#neighbor 10.1.1.1 remote-as 12
    11. R2(config-router)#neighbor 10.1.1.1 update-source loopback 0
    12. R2(config-router)#address-family vpnv4
    13. R2(config-router-af)#neighbor 10.1.1.1 activate
    14. R2(config-router-af)#neighbor 10.1.1.1 send-community extended

    校验MP-BGP PEER 关系是否建立:

    1. R1#show ip bgp vpnv4 all summary
    2. BGP router identifier 10.1.1.1, local AS number 12
    3. BGP table version is 1, main routing table version 1
    4. Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
    5. 10.2.2.2 4 12 16 16 1 0 0 00:10:43 0
    1. R1(config)#ip vrf r12
    2. R1(config-vrf)#rd 1:2
    3. R1(config-vrf)#route-target 1:2
    4. R1(config-vrf)#int e0/1
    5. R1(config-if)#ip vrf forwarding r12
    6. R1(config-if)#ip address 13.13.13.1 255.255.255.0
    7. R2(config)#ip vrf r12
    8. R2(config-vrf)#rd 1:2
    9. R2(config-vrf)#route-target 1:2
    10. R2(config)#interface e0/1
    11. R2(config-if)#ip vrf r12
    12. R2(config-vrf)#interface e0/1
    13. R2(config-if)#ip vrf forwarding r12

    完成PE CE 上OSPF 的配置,并且校验PE 学习C-NETWORK 路由的结果。
    R4 R5 间OSPF 此时先不去配置。

    1. R1(config)#router ospf 1 vrf r12
    2. R1(config-router)#network 13.13.13.0 0.0.0.255 area 1
    3. R2(config)#router ospf 1 vrf r12
    4. R2(config-router)#network 25.25.25.2 255.255.255.0 area 0
    5. R3(config)#router ospf 1
    6. R3(config-router)#router-id 10.3.3.3
    7. R3(config-router)#network 10.3.3.3 0.0.0.0 area 0
    8. R3(config-router)#network 13.13.13.0 0.0.0.255 area 1
    9. R3(config-router)#network 34.34.34.0 0.0.0.255 area 0
    10. R4(config)#router ospf 1
    11. R4(config-router)#router-id 10.4.4.4
    12. R4(config-router)#network 10.4.4.4 0.0.0.0 area 0
    13. R4(config-router)#network 34.34.34.0 0.0.0.255 area 0
    14. R5(config)#router ospf 1
    15. R5(config-router)#router-id 10.5.5.5
    16. R5(config-router)#network 10.5.5.5 0.0.0.0 area 0
    17. R5(config-router)#network 25.25.25.0 0.0.0.255 area 0

    PE路由重分发

    1. R1(config)#router bgp 12
    2. R1(config-router)#address-family ipv4 vrf r12
    3. R1(config-router-af)#redistribute ospf 1
    4. R1(config)#router ospf 1 vrf r12
    5. R1(config-router)#redistribute bgp 12 subnets
    6. R2(config)#router bgp 12
    7. R2(config-router)#address-family ipv4 vrf r12
    8. R2(config-router-af)#redistribute ospf 1
    9. R2(config)#router ospf 1 vrf r12
    10. R2(config-router)#redistribute bgp 12 subnets


    完成如上配置后,请在R1 上校验VRF 路由表,现象如下;

    1. R1#show ip route vrf r12 ospf
    2. Gateway of last resort is not set
    3. 10.0.0.0/32 is subnetted, 1 subnets
    4. O 10.3.3.3 [110/11] via 13.13.13.3, 00:00:22, Ethernet0/1
    5. //如上现象表明R1并没有学习area 0的路由。
    6. R3#show ip route ospf
    7. Gateway of last resort is not set
    8. 10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
    9. O 10.4.4.4/32 [110/11] via 34.34.34.4, 00:00:01, Ethernet0/0
    10. //如上现象表明R3学习了R4路由。
    11. R2#show ip route vrf r12 ospf
    12. Gateway of last resort is not set
    13. 10.0.0.0/32 is subnetted, 1 subnets
    14. O 10.5.5.5 [110/11] via 25.25.25.5, 00:07:57, Ethernet0/1

    在R1 R3 间配置虚链路,帮助PE设备R1 学习R4 loopback 0路由。

    1. R1(config)#router ospf 1 vrf r12
    2. R1(config-router)#area 1 virtual-link 10.3.3.3
    3. R3(config)#router ospf 1
    4. R3(config-router)#area 1 virtual-link 13.13.13.1

    此时一定要在R1 上确认和R3 建立了虚链路邻接关系,并且R1 学习了R4的路由;

    1. R1#show ip ospf neighbor
    2. Neighbor ID Pri State Dead Time Address Interface
    3. 10.3.3.3 0 FULL/ - - 13.13.13.3 OSPF_VL3
    4. 10.3.3.3 1 FULL/BDR 00:00:33 13.13.13.3 Ethernet0/1
    5. Routing Table: r12
    6. Gateway of last resort is not set
    7. 10.0.0.0/32 is subnetted, 2 subnets
    8. O 10.3.3.3 [110/11] via 13.13.13.3, 04:28:28, Ethernet0/1
    9. O 10.4.4.4 [110/21] via 13.13.13.3, 00:01:31, Ethernet0/1
    10. 34.0.0.0/24 is subnetted, 1 subnets
    11. O 34.34.34.0 [110/20] via 13.13.13.3, 00:01:31, Ethernet0/1
    12. //如上现象表明R1 与R3的虚链路邻接关系已经建立,且R1正常学习了R4路由。

    在R5上确认通过P-NETWORK 共享了R3 R4路由。

    1. R5#show ip route ospf
    2. Gateway of last resort is not set
    3. 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
    4. O IA 10.3.3.3/32 [110/21] via 25.25.25.2, 00:00:18, Ethernet0/0
    5. //区域间路由被共享,路由类型维持不变。
    6. O IA 10.4.4.4/32 [110/31] via 25.25.25.2, 00:00:18, Ethernet0/0
    7. //相同区域路由被P-NETWORK 共享变成了区域间路由。
    8. 13.0.0.0/24 is subnetted, 1 subnets
    9. O IA 13.13.13.0 [110/11] via 25.25.25.2, 00:00:18, Ethernet0/0
    10. 34.0.0.0/24 is subnetted, 1 subnets
    11. O IA 34.34.34.0 [110/30] via 25.25.25.2, 00:00:18, Ethernet0/0

    R4 R5 间backdoor 链路激活,启用OSPF,查看路由表。

    1. R4(config)#router os 1
    2. R4(config-router)#network 45.45.45.0 0.0.0.255 area 0
    3. R5(config)#router ospf 1
    4. R5(config-router)#network 45.45.45.0 0.0.0.255 area 0
    1. R5#show ip route ospf
    2. Gateway of last resort is not set
    3. 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
    4. O IA 10.3.3.3/32 [110/21] via 45.45.45.4, 00:00:03, Ethernet0/1
    5. [110/21] via 25.25.25.2, 00:00:03, Ethernet0/0
    6. //如上现象表明后门链路启用后,导致抵达10.3.3.0/24出现了负载均衡。
    7. O IA 10.4.4.4/32 [110/31] via 25.25.25.2, 00:02:20, Ethernet0/0
    8. 13.0.0.0/24 is subnetted, 1 subnets
    9. //如上现象表明后门链路启用后,R5 抵达R4 10.4.4.0/24网络不走P-NETWORK,走BACKDOOR。
    10. O IA 13.13.13.0 [110/11] via 25.25.25.2, 00:02:20, Ethernet0/0
    11. 34.0.0.0/24 is subnetted, 1 subnets
    12. O IA 34.34.34.0 [110/30] via 25.25.25.2, 00:02:20, Ethernet0/0

    R4 R1 的隧道创建。

    1. R4(config)#interface tunnel 14
    2. R4(config-if)#ip unnumbered ethernet 0/0
    3. R4(config-if)#tunnel source 34.34.34.4
    4. R4(config-if)#tunnel destination 13.13.13.1
    5. R4(config-if)#tunnel mode gre ip
    6. R4(config-if)#ip ospf 1 area 0
    7. R1(config)#interface tunnel 14
    8. R1(config-if)#ip vrf forwarding r12
    9. R1(config-if)#ip unnumbered ethernet 0/1
    10. R1(config-if)#tunnel source 13.13.13.1
    11. R1(config-if)#tunnel destination 34.34.34.4
    12. R1(config-if)#tunnel source 13.13.13.1
    13. R1(config-if)#tunnel mode gre ip
    14. R1(config-if)#ip ospf 1 area 0
    15. R1(config-if)#tunnel vrf r12
    16. //告诉隧道目的地是需要在VRF R12下查询

    确认R1 R4 建立了基于隧道的OSPF 邻接关系。

    1. R1#show ip ospf neighbor
    2. Neighbor ID Pri State Dead Time Address Interface
    3. 10.4.4.4 0 FULL/ - 00:00:38 34.34.34.4 Tunnel14
    4. 10.3.3.3 0 FULL/ - - 13.13.13.3 OSPF_VL3
    5. 10.3.3.3 1 FULL/BDR 00:00:34 13.13.13.3 Ethernet0/1

    R1 R2 上完成伪链路配置。

    1. R1(config)#interface loopback 12
    2. R1(config-if)#ip vrf forwarding r12
    3. R1(config-if)#ip address 100.100.100.1 255.255.255.255
    4. R1(config-if)#router bgp 12
    5. R1(config-router)#address-family ipv4 vrf r12
    6. R1(config-router-af)#network 100.100.100.1 mask 255.255.255.255
    7. R1(config-router-af)#router ospf 1 vrf r12
    8. R1(config-router)#area 0 sham-link 100.100.100.1 100.100.100.2
    9. R2(config)#interface loopback 12
    10. R2(config-if)#ip vrf forwarding r12
    11. R2(config-if)#ip address 100.100.100.2 255.255.255.255
    12. R2(config-if)#router bgp 12
    13. R2(config-router)#address-family ipv4 vrf r12
    14. R2(config-router-af)#network 100.100.100.2 mask 255.255.255.255
    15. R2(config-router-af)#router ospf 1 vrf r12
    16. R2(config-router)#area 0 sham-link 100.100.100.2 100.100.100.1

    在R4 R5 上对后门链路OSPF 的开销做修改。

    1. R4(config)#interface e0/1
    2. R4(config-if)#ip ospf cost 10000
    3. R5(config)#interface e0/1
    4. R5(config-if)#ip ospf cost 10000

    R5 和R4 确认抵达对端是否首选P-NETWORK。

    1. R4#show ip route ospf
    2. Gateway of last resort is not set
    3. 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
    4. O IA 10.3.3.3/32 [110/11] via 34.34.34.3, 05:20:54, Ethernet0/0
    5. O 10.5.5.5/32 [110/32] via 34.34.34.3, 00:04:49, Ethernet0/0
    6. //如上现象表明伪链路已经成功还原路由,且通过开销的比对选择优选P-NETWORK
    7. 13.0.0.0/24 is subnetted, 1 subnets
    8. O IA 13.13.13.0 [110/20] via 34.34.34.3, 05:20:54, Ethernet0/0
    9. 25.0.0.0/24 is subnetted, 1 subnets
    10. O 25.25.25.0 [110/31] via 34.34.34.3, 00:04:49, Ethernet0/0
    11. 100.0.0.0/32 is subnetted, 2 subnets
    12. O E2 100.100.100.1 [110/1] via 34.34.34.3, 00:08:52, Ethernet0/0
    13. O E2 100.100.100.2 [110/1] via 34.34.34.3, 00:06:00, Ethernet0/0
    14. R5#show ip route ospf
    15. Gateway of last resort is not set
    16. 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
    17. O IA 10.3.3.3/32 [110/22] via 25.25.25.2, 00:03:05, Ethernet0/0
    18. O 10.4.4.4/32 [110/32] via 25.25.25.2, 00:03:05, Ethernet0/0
    19. //如上现象表明伪链路已经成功还原路由,且通过开销的比对选择优选P-NETWORK
    20. 13.0.0.0/24 is subnetted, 1 subnets
    21. O IA 13.13.13.0 [110/21] via 25.25.25.2, 00:06:35, Ethernet0/0
    22. 34.0.0.0/24 is subnetted, 1 subnets
    23. O 34.34.34.0 [110/31] via 25.25.25.2, 00:03:05, Ethernet0/0
    24. 100.0.0.0/32 is subnetted, 2 subnets
    25. O E2 100.100.100.1 [110/1] via 25.25.25.2, 00:07:18, Ethernet0/0
    26. O E2 100.100.100.2 [110/1] via 25.25.25.2, 00:07:02, Ethernet0/0

    R5上利用traceroute 命令验证路径。

    1. R5#traceroute 10.4.4.4 source 10.5.5.5
    2. Type escape sequence to abort.
    3. Tracing the route to 10.4.4.4
    4. VRF info: (vrf in name/id, vrf out name/id)
    5. 1 25.25.25.2 1 msec 0 msec 0 msec
    6. 2 13.13.13.1 [MPLS: Label 102 Exp 0] 1 msec 1 msec 1 msec
    7. 3 13.13.13.3 0 msec 0 msec 1 msec
    8. 4 34.34.34.4 0 msec 0 msec *
    9. //如上现象表明路径符合需求

  • 相关阅读:
    CV+Deep Learning——网络架构Pytorch复现系列——basenets(BackBones)(一)
    优先级队列(堆)
    Hadoop生态之Mapreduce
    蓝桥杯刷题(三)
    PowerDsigner 数据库逆向pdm数模 常见数据库连接问题
    Nacos系列【25】源码分析篇之Spring Cloud启动器
    新疆旅游8天要多少钱,新疆8天价格记录分享
    dos batch动态设置数组
    ros入门之一,发布者,订阅者的python文件创建以及最后的终端执行(含python文件代码)
    公司如何实现多套环境的自动化测试?
  • 原文地址:https://blog.csdn.net/qq_43210022/article/details/125527521