我们主要使用静态方式来演示MGRE的非shortcut和shortcut
基本的配置
第一步:地址配置
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 15.0.0.1 24
[R1-GigabitEthernet0/0/0]int l0
[R1-LoopBack0]ip add 192.168.1.1 24
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 25.0.0.1 24
[R2-GigabitEthernet0/0/0]int l0
[R2-LoopBack0]ip add 192.168.2.1 24
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 35.0.0.1 24
[R3-GigabitEthernet0/0/0]int l0
[R3-LoopBack0]ip add 192.168.3.1 24
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 45.0.0.1 24
[R4-GigabitEthernet0/0/0]int l0
[R4-LoopBack0]ip add 192.168.4.1 24
[ISP]int g0/0/0
[ISP-GigabitEthernet0/0/0]ip add 15.0.0.2 24
[ISP-GigabitEthernet0/0/0]int g0/0/1
[ISP-GigabitEthernet0/0/1]ip add 25.0.0.2 24
[ISP-GigabitEthernet0/0/1]int g0/0/2
[ISP-GigabitEthernet0/0/2]ip add 5.0.0.2 243
[ISP-GigabitEthernet0/0/2]int g4/0/0
[ISP-GigabitEthernet4/0/0]ip add 45.0.0.2 24
[ISP-GigabitEthernet4/0/0]int l0
[ISP-LoopBack0]ip add 5.5.5.5 24
这里我们主要是介绍MGRE的两种方式,R5起不起环回无所谓
第二步,静态缺省指向R5,实现公网互通
[R1]ip route-static 0.0.0.0 0 15.0.0.2
[R2]ip route-static 0.0.0.0 0 25.0.0.2
[R3]ip route-static 0.0.0.0 0 35.0.0.2
[R4]ip route-static 0.0.0.0 0 45.0.0.2
测试:
注意:物理地址的畅通才可以实现我们MGRE的畅通,测试很重要。
第三步:MGRE
[R1]int t0/0/0
[R1-Tunnel0/0/0]ip add 192.168.5.1 24
[R1-Tunnel0/0/0]tunnel-protocol gre p2mp
[R1-Tunnel0/0/0]source 15.0.0.1
[R2]int t0/0/0
[R2-Tunnel0/0/0]ip add 192.168.5.2 24
[R2-Tunnel0/0/0]tunnel-protocol gre p2mp
[R2-Tunnel0/0/0]nhrp entry 192.168.5.1 15.0.0.1 register
[R2-Tunnel0/0/0]source g0/0/0
[R3]int t0/0/0
[R3-Tunnel0/0/0]ip ad 192.168.5.3 24
[R3-Tunnel0/0/0]tunnel-protocol gre p2mp
[R3-Tunnel0/0/0]nhrp entry 192.168.5.1 15.0.0.1 re
[R3-Tunnel0/0/0]source g0/0/0
[R4]int t0/0/0
[R4-Tunnel0/0/0]ip add 192.168.5.4 24
[R4-Tunnel0/0/0]tunnel-protocol gre p2mp
[R4-Tunnel0/0/0]nhrp entry 192.168.5.1 15.0.0.1 register
[R4-Tunnel0/0/0]source g0/0/0
看表:
[R1]ip route-static 192.168.2.0 24 192.168.5.2
[R1]ip route-static 192.168.3.0 24 192.168.5.3
[R1]ip route-static 192.168.4.0 24 192.168.5.4
1、非shortcut配置:
[R2]ip route-static 192.168.4.0 24 192.168.5.4
[R2]ip route-static 192.168.3.0 24 192.168.5.3
[R2]ip route-static 192.168.1.0 24 192.168.5.1
[R3]ip route-static 192.168.4.0 24 192.168.5.4
[R3]ip route-static 192.168.2.0 24 192.168.5.2
[R3]ip route-static 192.168.1.0 24 192.168.5.1
[R4]ip route-static 192.168.3.0 24 192.168.5.3
[R4]ip route-static 192.168.2.0 24 192.168.5.2
[R4]ip route-static 192.168.1.0 24 192.168.5.1
在R4上ping,在R1接口抓包
R4仅有两个ping包经过R1
2、shortcut
[R2]undo ip route-static 192.168.4.0 24 192.168.5.4
[R2]undo ip route-static 192.168.3.0 24 192.168.5.3
[R2]ip route-static 192.168.4.0 24 192.168.5.1
[R2]ip route-static 192.168.3.0 24 192.168.5.1
[R3]undo ip route-static 192.168.4.0 24 192.168.5.4
[R3]undo ip route-static 192.168.2.0 24 192.168.5.2
[R3]ip route-static 192.168.4.0 24 192.168.5.1
[R3]ip route-static 192.168.2.0 24 192.168.5.1
[R4]undo ip route-static 192.168.3.0 24 192.168.5.3
[R4]undo ip route-static 192.168.2.0 24 192.168.5.2
[R4]ip route-static 192.168.3.0 24 192.168.5.1
[R4]ip route-static 192.168.2.0 24 192.168.5.1
显示:
很明显,spoke节点想要访问路由,都要经过Hub点。
我们再次进行R4pingR2,抓包R1接口
R4与R2的所有ping包都经过了R1
我们在R1上开启重定向
[R1]int t0/0/0
[R1-Tunnel0/0/0]nhrp redirect
再次抓包
和前面相似,虽然R1给R4发了重定向,但是R4,不为所动
改进:R4开启快捷方式
[R2]int t0/0/0
[R2-Tunnel0/0/0]nhrp shortcut
[R4]int t0/0/0
[R4-Tunnel0/0/0]nhrp shortcut
重新抓包:
效果显著
shortcut和非shortcut方式主要区别:
1、配置上:
shortcut方式,针对静态路由,走向的下一跳都是去Hub站点。且为了使得选路优化,需要在Hub上进行重定向操作,在spoke节点上开启快捷方式
非shortcut方式,针对静态路由,走向的 下一跳是去对应网段的隧道地址的下一跳,Hub和Spoke无需过多操作
2、原理上,shortcut方式比非shortcut方式多了一个重定向。