DS-虚隧道之shortcut模式(Huawei设备)
写在前面
为什么会有DS-虚隧道?
-
DS-虚隧道是华为的动态智能的虚拟专用网络,即分之间的通信可以直接进行通信,无需绕行总部
-
基于MGRE,即多点GRE
华为的DS-虚隧道
-
Normal方式:spoke间的通信,第一步要绕行总部,第二部是不绕行总部的;
核心逻辑是解析下一跳,即根据下一跳是隧道地址解析为公网地址;先查路由表再查映射表
-
Shortcut方式:spoke间的通信,第一次绕行总部时,总部觉得你直接去就行,不用通过我绕行,且spoke间的通信属于同一个网段,所以总部发送一个重定向;不同之处在于shortcut映射的是公网地址
核心是解析目的地址(私网地址);可以做到跨多层级的直通;
与Normal区别:存在私网地址与公网地址的映射,查找简单,速度快
参考阅读
实验环境
实验拓扑
分析
需求:spoke间建立隧道,进行分支间的通信,且不能绕行总部
将隧道部署在OSPF的NBMA环境下,分支间的通信将不会绕行总部,但是P2MP肯定会绕行总部;那么就使用DS-虚隧道的shortcut模式,即无论何种网络类型下,分支间的通信都不会绕行总部
配置部署
1、公网要通,即ISP间要全网可达
解决:在hub与spoke上配置默认路由,下一跳为连接R2的链路地址
[R1]ip route-static 0.0.0.0 0.0.0.0 12.1.1.2
[R3]ip route-static 0.0.0.0 0.0.0.0 23.1.1.1
[R4]ip route-static 0.0.0.0 0.0.0.0 24.1.1.1
2、创建tunnel,进行nhrp的配置;由于MA网络要进行DR/BDR的选举,所以要在spoke上关闭DR的选举,即将优先级配置为0
hub
[R1-Tunnel0/0/0]di th
[V200R003C00]
#
interface Tunnel0/0/0
ip address 100.1.1.1 255.255.255.0
tunnel-protocol gre p2mp
source GigabitEthernet0/0/0
ospf network-type broadcast
nhrp entry multicast dynamic
nhrp network-id 100
#
return
spoke1
[R3-Tunnel0/0/0]di th
[V200R003C00]
#
interface Tunnel0/0/0
ip address 100.1.1.3 255.255.255.0
tunnel-protocol gre p2mp
source GigabitEthernet0/0/0
ospf network-type broadcast
ospf dr-priority 0
nhrp network-id 100
nhrp entry 100.1.1.1 12.1.1.1 register
#
return
spoke2
[R4-Tunnel0/0/0]di th
[V200R003C00]
#
interface Tunnel0/0/0
ip address 100.1.1.4 255.255.255.0
tunnel-protocol gre p2mp
source GigabitEthernet0/0/0
ospf network-type broadcast
ospf dr-priority 0
nhrp network-id 100
nhrp entry 100.1.1.1 12.1.1.1 register
#
return
3、将私网路由、隧道路由宣告在OSPF中
hub
[R1-ospf-1]di th
[V200R003C00]
#
ospf 1
area 0.0.0.0
network 100.1.1.1 0.0.0.0
network 192.168.1.0 0.0.0.255
#
return
spoke1
[R3-ospf-1]di th
[V200R003C00]
#
ospf 1
area 0.0.0.0
network 100.1.1.3 0.0.0.0
network 192.168.1.0 0.0.0.255
#
return
spoke2
[R4-ospf-1]di th
[V200R003C00]
#
ospf 1
area 0.0.0.0
network 100.1.1.4 0.0.0.0
network 192.168.1.0 0.0.0.255
#
return
验证测试
Normal模式(默认)
- 测试公网连通性
[R1]tracert -a 12.1.1.1 23.1.1.2
traceroute to 23.1.1.2(23.1.1.2), max hops: 30 ,packet length: 40,press CTRL_C to break
1 12.1.1.2 30 ms 20 ms 20 ms
2 23.1.1.2 40 ms 30 ms 20 ms
- 测试隧道连通性,抓包可见,由于套上了一层GRE的封装,外表看上去是公网的通信,其实是隧道的通信
[R1]ping -a 100.1.1.1 100.1.1.3
PING 100.1.1.3: 56 data bytes, press CTRL_C to break
Reply from 100.1.1.3: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 100.1.1.3: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 100.1.1.3: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 100.1.1.3: bytes=56 Sequence=4 ttl=255 time=40 ms
Reply from 100.1.1.3: bytes=56 Sequence=5 ttl=255 time=30 ms
--- 100.1.1.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/32/40 ms
- 测试私网的连通信,以及是否绕行总部
[R3]ping -a 192.168.1.3 192.168.1.4
PING 192.168.1.4: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.4: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 192.168.1.4: bytes=56 Sequence=2 ttl=255 time=40 ms
Reply from 192.168.1.4: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 192.168.1.4: bytes=56 Sequence=4 ttl=255 time=40 ms
Reply from 192.168.1.4: bytes=56 Sequence=5 ttl=255 time=40 ms
--- 192.168.1.4 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/36/40 ms
[R3]tracert -a 192.168.1.3 192.168.1.4
traceroute to 192.168.1.4(192.168.1.4), max hops: 30 ,packet length: 40,press CTRL_C to break
1 100.1.1.4 30 ms 30 ms 30 ms
抓包可以明显的看出,外表看上去是公网的通信,而其实是私网路由通过隧道进行通信的
此NBMA环境下分支间通信会先去总部进行注册,之后的分支间通信将不会绕行总部,即Normal模式下的核心逻辑是解析下一跳,即根据下一跳是隧道地址解析为公网地址;先查路由表再查映射表
[R3]dis nhrp peer all
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
100.1.1.1 32 12.1.1.1 100.1.1.1 static hub
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 01:48:06
Expire time : --
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
100.1.1.4 32 24.1.1.2 100.1.1.4 dynamic route tunnel
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 00:00:03
Expire time : 01:59:57
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
100.1.1.3 32 23.1.1.2 100.1.1.3 dynamic local
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 00:00:03
Expire time : 01:59:57
Number of nhrp peers: 3
[R4]dis nhrp peer all
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
100.1.1.1 32 12.1.1.1 100.1.1.1 static hub
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 01:50:05
Expire time : --
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
100.1.1.3 32 23.1.1.2 100.1.1.3 dynamic route tunnel
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 00:03:00
Expire time : 01:57:00
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
100.1.1.4 32 24.1.1.2 100.1.1.4 dynamic local
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 00:03:00
Expire time : 01:57:00
Number of nhrp peers: 3
以上这种是OSPF的NBMA网络类型,其发送的是伪广播,所以肯定不用绕行总部,如下为此环境下的拓扑
什么是伪广播呢?还请查看本篇开头的参考阅读
下面开始使用OSPF的P2MP类型
hub
[R1-Tunnel0/0/0]ospf network-type p2mp
spoke
[R3-Tunnel0/0/0]ospf network-type p2mp
[R4-Tunnel0/0/0]ospf network-type p2mp
此时,分支间的私网通信,肯定绕行的是总部,因为P2MP的网络拓扑决定了的,如下
路由追踪
[R3]tracert -a 192.168.1.3 192.168.1.4
traceroute to 192.168.1.4(192.168.1.4), max hops: 30 ,packet length: 40,press CTRL_C to break
1 100.1.1.1 30 ms 30 ms 20 ms
2 100.1.1.4 50 ms 30 ms 50 ms
在这种环境下,由于分支只能看到总部,所以nhrp的映射表只有总部的隧道地址与总部的公网地址的映射关系
[R3]dis nhrp peer all
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
100.1.1.1 32 12.1.1.1 100.1.1.1 static hub
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 01:41:20
Expire time : --
Number of nhrp peers: 1
[R4]dis nhrp peer all
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
100.1.1.1 32 12.1.1.1 100.1.1.1 static hub
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 01:41:49
Expire time : --
Number of nhrp peers: 1
Shortcut模式(需配置)
hub配置nhrp的重定向;spoke配置nhrp的shortcut
[R1-Tunnel0/0/0]nhrp redirect
[R3-Tunnel0/0/0]nhrp shortcut
[R4-Tunnel0/0/0]nhrp shortcut
测试:
[R3]ping -a 192.168.1.3 192.168.1.4
PING 192.168.1.4: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.4: bytes=56 Sequence=1 ttl=254 time=50 ms
Reply from 192.168.1.4: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 192.168.1.4: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 192.168.1.4: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 192.168.1.4: bytes=56 Sequence=5 ttl=255 time=30 ms
--- 192.168.1.4 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/32/50 ms
[R3]tracert -a 192.168.1.3 192.168.1.4
traceroute to 192.168.1.4(192.168.1.4), max hops: 30 ,packet length: 40,press CTRL_C to break
1 100.1.1.4 40 ms 20 ms 20 ms
可见,分支间的通信并没有绕行总部;
查看nhrp映射表,可以明显的看出来,spoke间的通信,第一次绕行总部时,总部觉得你直接去就行,不用通过我绕行,且spoke间的通信属于同一个网段,所以总部发送一个重定向;不同之处在于shortcut映射的是公网地址
核心是解析目的地址(私网地址);可以做到跨多层级的直通;
与Normal区别:存在私网地址与公网地址的映射,查找简单,速度快