一、DM×××介绍
Dynamic Multipoint ×××(DM×××)是一种动态建立××× Tunnel的技术,目的是在Hub-And-Spoke网络环境下,使用Next Hop Resolution Protocol(NHRP)技术解析需要建立×××隧道的对端地址,并使用multipoint GRE tunnel端口建立多点的GRE over IPSec ×××隧道。由于IPSec ×××技术是目前使用最广的×××技术,而Hub-and-Spoke又是使用最多的网络拓扑,因此DM×××技术具有一定的应用价值。
DM×××具有以下特点:一,配置简单化,减少Hub端的配置过程,日后添加新的Spoke端也不需要再次进行配置修改;二,支持动态路由协议,基于GRE隧道技术的×××技术,可以跨网传递路由协议信息;三、支持隧道两端动态地址协商(Hub端地址必须固定),这在对端IP地址无法确定,例如使用虚拟拨号的site to site ×××而言重要性不言而喻;四、Spoke之间可以动态建立×××隧道。
NHRP协议介绍,NHRP是一种C/S架构的协议。其中服务端成为NHS,需要固定的地址为客户端提供注册服务。NHRP客户端必须将自己注册到NHS的映射表上。当其它NHRP客户端需要获得该客户端的地址时,通过向NHS发送请求即可获得。但建立了隧道后,NHRP之间的unicast流量通过隧道转发,而multicast或者控制流量仍旧通过Hub转发。
从下图可知,NHRP Mapping表与CEF Adjacence表基本上是一致的。
二、工作原理
DM×××工作原理如下:首先,各Spoke端与Hub端建立GRE over IPSec隧道,并向其注册作为NHRP客户端。当spoke之间需要建立×××隧道时,即向Hub端发送动态地址解析请求,获取对端地址。最后,×××两端利用已经解析到的地址,通过mGRE端口建立隧道。
三、拓扑介绍:
R1------(E0/1)------R5------(E0/3)------R3
其中R1内网1.0.0.0/24需要和R3内网3.0.0.0/24通信。
四、关键配置:
    关于IPSec
    首先,这不是GRE over IPSec模型,感觉应该是一个直接加密的GRE模型。所有使用GRE的数据流都是用IPSec保护的。而不再需要ACL作为判断依据。其次,调用IPSec的语句在Tunnel里面。tunnel protect ipsec profile DM×××_PF,这就是为何之前要配IPSec profile的原因。
    关于Tunnel
    首先,所有的DM×××设备,tunnel mode必须为gre multipoint,另外,IP地址必须在同一子网内。这样才能触发NHRP进行下一跳解析。
    关于Tunnel Source的选择
    R5作为NHRP Server,由于涉及到多个外连口,因此tunnel source使用loopback 0的IP(注意这里不能直接使用loopback 0,否则设置封装模式时会报错)。相对应的,当ISP使用动态IP分配给外连口时,R1、R3的tunnel source设置为物理接口更好一些。实际上,由于实验里运行了OSPF 100通告各路由器的loopback 0 IP地址,tunnel source可使用各自的Loopback 0地址。真实情况下,可能使用域名+DNS的情况会多一些。
    关于NHRP
    NHRP Server:R5的配置里,主要是ip nhrp map multicast dynamic,要求其接收到组播后根据NHRP列表转发;
    NHRP Client:这是困扰本人最多的问题,因为NHRP必须配置在Tunnel上,因此配置NHRP map相当有技巧,必须配置两条map,一条是静态映射NHRP Server IP到其Tunnel Source IP的,一条是映射multicast到NHRP Server的Tunnel Source IP的。另外还必须配置一条指明NHRP Server IP的语句。
    关于DM×××之间的路由协议
    可能有人会奇怪,路由协议有何需要介绍的呢?这里我解释一下,本实验最难的地方,个人认为是R1、R3之间原本是没有IPSec隧道的。在路由器发送初始化信息的时候,首先只能先通过本身的IPSec隧道转发到R5,然后R5通过另一条IPSec隧道转发到另一台路由器。路由表收敛后,两者都会认为通过R5的隧道才能到达对方,进而就不再建立相互间隧道了。因此,一开始我是用OSPF时,一直没有办法是的R1、R3获得对方的内网路由。最后只能通过把Tunnel的network type改为OSPF NBMA,并指定邻居才能够获得,而且得到的路由也是要通过R5中转的。这从show crypto isakmp sa里可以看出。
    后来,在翻阅资料时,我看到基本上所有的DM×××之间配置介绍都是用DV(距离矢量)路由协议,而且需要在Tunnel内配有一条no ip next-hop-self eigrp ASN。我才明白,原来必须要这样“欺骗”路由器,让其认为不能通过R5到达对端×××,才可使其主动建立新的IPSec 隧道。因此我在R5内加了两条语句:
    no ip next-hop-self eigrp 100
    no ip split-horizon eigrp 100
五、配置:
R1#show run
!
crypto isakmp policy 10
authentication pre-share
!注意,address为0/0,意味着所有的IPSec ×××域共享密钥都一样。理论上应该可以使用证书验证的。
crypto isakmp key cisco123 address 0.0.0.0 0.0.0.0
!
crypto ipsec transform-set DM×××_TFS esp-des esp-md5-hmac
mode transport
!
!以下为mGRE Tunnel所需要的profile
crypto ipsec profile DM×××_PF
set transform-set DM×××_TFS
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
!受保护内网地址
interface Loopback1
ip address 1.0.0.1 255.255.255.0
!
interface Tunnel0
ip address 135.0.0.1 255.255.255.0
no ip redirects
!NHRP Client配置,注意两个map,同时指向NHS mGRE的Source
!认证和网络ID个人认为可有可无,但实验好像必须配了才可开始NHRP查询,望指点
ip nhrp authentication 123456
ip nhrp map 135.0.0.5 5.5.5.5
ip nhrp map multicast 5.5.5.5
ip nhrp network-id 100
ip nhrp nhs 135.0.0.5
!mGRE。直接调用ipsec的profile,不需要ACL哦
tunnel source Ethernet0/1
tunnel mode gre multipoint
t unnel protection ipsec profile DM×××_PF
!
interface Ethernet0/1
ip address 15.0.0.1 255.255.255.0
!
router eigrp 100
network 1.0.0.1 0.0.0.0
network 135.0.0.1 0.0.0.0
no auto-summary
passive-interface Loopback1
eigrp router-id 1.1.1.1
!
router ospf 100
router-id 1.1.1.1
log-adjacency-changes
passive-interface Loopback0
network 1.1.1.1 0.0.0.0 area 0
network 15.0.0.1 0.0.0.0 area 0
!
End
//
R3#show run
!
crypto isakmp policy 10
authentication pre-share
crypto isakmp key cisco123 address 0.0.0.0 0.0.0.0
!
crypto ipsec transform-set DM×××_TFS esp-des esp-md5-hmac
mode transport
!
crypto ipsec profile DM×××_PF
set transform-set DM×××_TFS
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface Loopback1
ip address 3.0.0.1 255.255.255.0
!
interface Tunnel0
ip address 135.0.0.3 255.255.255.0
no ip redirects
ip nhrp authentication 123456
ip nhrp map 135.0.0.5 5.5.5.5
ip nhrp map multicast 5.5.5.5
ip nhrp network-id 100
ip nhrp nhs 135.0.0.5
tunnel source Ethernet0/3
tunnel mode gre multipoint
tunnel protection ipsec profile DM×××_PF
!
interface Ethernet0/3
ip address 35.0.0.3 255.255.255.0
!
router eigrp 100
network 3.0.0.1 0.0.0.0
network 135.0.0.3 0.0.0.0
no auto-summary
passive-interface Loopback1
eigrp router-id 3.3.3.3
!
router ospf 100
router-id 3.3.3.3
log-adjacency-changes
passive-interface Loopback0
network 3.3.3.3 0.0.0.0 area 0
network 35.0.0.3 0.0.0.0 area 0
!
End
//
R5#show run
!
crypto isakmp policy 10
authentication pre-share
crypto isakmp key cisco123 address 0.0.0.0 0.0.0.0
!
crypto ipsec transform-set DM×××_TFS esp-des esp-md5-hmac
mode transport
!
crypto ipsec profile DM×××_PF
set transform-set DM×××_TFS
!
interface Loopback0
ip address 5.5.5.5 255.255.255.255
!
interface Loopback1
ip address 5.0.0.1 255.255.255.0
!
interface Tunnel0
ip address 135.0.0.5 255.255.255.0
no ip redirects
!NHS和NHRP Client最大的不同,就是对路由协议的限制,以及组播包的处理。由此可以看出, nhs没有明确的定义,任何运行nhrp的端口均可作为nhs;另外我在此使用LS路由(OSPF)无法正常,使用eigrp+以下两条语句方可正常。望指教
no ip next-hop-self eigrp 100
ip nhrp authentication 123456
ip nhrp map multicast dynamic
ip nhrp network-id 100
no ip split-horizon eigrp 100
tunnel source 5.5.5.5
tunnel mode gre multipoint
tunnel protection ipsec profile DM×××_PF
!
interface Ethernet0/1
ip address 15.0.0.5 255.255.255.0
!
interface Ethernet0/3
ip address 35.0.0.5 255.255.255.0
!
router eigrp 100
network 5.0.0.1 0.0.0.0
network 135.0.0.5 0.0.0.0
no auto-summary
passive-interface Loopback1
eigrp router-id 5.5.5.5
!
router ospf 100
router-id 5.5.5.5
log-adjacency-changes
passive-interface Loopback0
network 5.5.5.5 0.0.0.0 area 0
network 15.0.0.5 0.0.0.0 area 0
network 35.0.0.5 0.0.0.0 area 0
!
End
六、实验结果:
R1#ping 3.0.0.1 so 1.0.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.0.0.1, timeout is 2 seconds:
Packet sent with a source address of 1.0.0.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/8 ms
R1#show cryp isa sa
IPv4 Crypto ISAKMP SA
dst src state conn-id status
15.0.0.1 35.0.0.3 QM_IDLE 1002 ACTIVE
5.5.5.5 15.0.0.1 QM_IDLE 1001 ACTIVE
35.0.0.3 15.0.0.1 QM_IDLE 1003 ACTIVE
上述红字为R1、R3之间动态协商生成的IPSec隧道。