一般來說 IPSEC的流量分佈於基於總部與分支之間,分支與分支之間的流量分佈較少,若分支到分支通信必須跨越中心,這會耗費中心的資源並導致帶寬佔用導致延時.而且分支多的時候,管理與維護必將繁瑣,且不便於維護和排錯.如果讓分支到分支的流量不跨越中心,而且引入動態路由,將使得網絡便於維護和得到充分利用.
但是IPSEC只支持單播加密,而動態路由的更新依賴於多播(RIPV1)或組播(RIPV2,EIGRP,OSPF),到這裏我們便引入了動態多點××× (DM×××)的概念。
動態多點××× 依賴於GRE和NHRP
GRE:通用路由封裝。它可以封裝任意一種的網絡協議,所以非常適合於×××中作爲封裝路由協議.由於GRE包是單播包(不加密),所以適合用IPSEC加密在×××之間傳輸,這樣也可以作爲GRE Over IPSec
百科連接 http://baike.baidu.com/view/1004.htm
NHRP:下一跳解析協議 用於連接到非廣播多路訪問(NBMA)式子網絡的源站(主機或路由器)決定到達目標站間的 “ NBMA 下一跳 ”的互聯網絡層地址和 NBMA 子網地址。如果目的地與 NBMA 子網連接, NBMA 下一跳就是目標站;否則, NBMA 下一跳是從 NBMA 子網到目標站最近的出口路由器。 NHRP 被設計用於 NBMA 子網下的多重協議互聯網絡層環境中。
在到達要生成響應的站之前, NBMA 子網內的 NHRP 解析請求經過一個甚至更多的跳。包括源站在內的每個站選擇一個它要轉發 NHRP 解析請求所去的鄰近 NHS 。 NHS 選擇過程是:在能返回路由決定的協議層路由表上應用目的協議層地址。這種路由選擇決定用於轉發 NHRP 請求給下游的 NHS 。先前提到的目標協議層地址存放在 NHRP 解析請求包中。注意:即使一個協議層地址被用來獲取路由選擇決定, NHRP 包不會被封裝於協議層頭,而是通過由它自己的頭描述的封裝形式存放於 NBMA 層。
百科連接:http://baike.baidu.com/view/876129.htm
簡單來說NHRP就是尋找到某條動態路由最近的下一跳而存在的
下面看動態隧道的建立
1.分支到中心(Spoke−to−Hub)的動態隧道建立
在DM×××網絡中,各分支路由通過IPSEC加密GRE通道連接到中心路由,中心路由TUNNEL 配置如下:
- interface Tunnel0
ip address 192.168.1.1 255.255.255.0
ip nhrp authentication cisco
ip nhrp map multicast dynamic
ip nhrp network-id 999
ip nhrp cache non-authoritative
ip ospf network broadcast
tunnel source FastEthernet1/0
tunnel mode gre multipoint
tunnel protection ipsec profile cisco
其中某分支TUNNEL配置如下:
- interface Tunnel0
- ip address 192.168.1.3 255.255.255.0
- ip nhrp authentication cisco
- ip nhrp map multicast 202.96.128.2
- ip nhrp map 192.168.1.1 202.96.128.2
- ip nhrp network-id 999
- ip nhrp nhs 192.168.1.1
- ip nhrp cache non-authoritative
- ip ospf network broadcast
- tunnel source FastEthernet1/0
- tunnel mode gre multipoint
- tunnel protection ipsec profile cisco
由於分支路由器外網端口的IP地址是自動獲取的(許多機構大都是採用ADSL),每次連接公網的IP地址可能不同,所以中心路由器無法根據該地址信息進行配置。分支路由器上則必須依據中心路由器的公網IP地址和NHRP協議來配置GRE隧道,中心路由器不必針對所有分支分別配置GRE或IPSec信息,新加入的分支路由器將自動註冊到中心路由器,將大大簡化中心路由器的配置。
2、分支到分支(Spoke−to−Spoke)的動態隧道建立
分支到中心(Spoke−to−Hub)的隧道一旦建立便持續存在,但各分支之間並不需要持續隧道。當一個分支需要向另一個分支需要通信時,它利用NHRP來動態獲取目的分支的IP地址。該過程中,中心路由器充當NHRP服務器的角色,響應NHRP請求,向源分支提供目標分支的公網地址。於是,兩個分支之間通過端口動態建立IPSec隧道,進行數據傳輸,過程就像DNS查詢一樣,該隧道在預定義的週期之後將關閉.
在路由器初始化後,中心路由器會通過持續存在的隧道向分支路由器宣告其它分支子網的可達路由。這樣分支路由器的路由表中到達其它分支子網的“下一跳”地址仍是中心路由器的隧道端口地址,而不是其它分支路由器的隧道端口地址,這個問題如果我們使用的是鏈路狀態路由協議的時候,是不存在下一跳地址被改變,但是如果我們使用的是距離向量型路由協議(RIP,EIGRP)的時候,默認是開啓水平分割的,必須關閉,否則,分支路由器將無法學習到通往其它分支子網的路由。另外各點的TUNNEL下必須開啓ip ospf broadcast,不然使用OSPF會導致上述問題
下面是主要配置
拓撲如下:
中心路由器R1配置如下:
- crypto isakmp policy 10 //ISAKMP策略
- encr 3des
- authentication pre-share
- crypto isakmp key 110 address 0.0.0.0 0.0.0.0
- !
- !
- crypto ipsec transform-set myset esp-3des esp-md5-hmac //統一IPSC策略集爲ESP
- !
- crypto ipsec profile cisco //IPSEC配置profile
- set transform-set myset
- interface Tunnel0
- ip address 192.168.1.1 255.255.255.0
- no ip redirects
- ip nhrp authentication cisco //nhrp認證
- ip nhrp map multicast dynamic
- ip nhrp network-id 999 //network-id認證
- ip nhrp cache non-authoritative
- ip ospf network broadcast //OSPF接口類型
- tunnel source FastEthernet1/0
- tunnel mode gre multipoint //接口爲GRE 多播
- tunnel protection ipsec profile cisco //啓用IPSEC的profile
- !
- interface FastEthernet1/0
- ip address 202.96.128.2 255.255.255.0
- duplex auto
- speed auto
- !
- router ospf 100 //OSPF動態路由
- log-adjacency-changes
- router-id 192.168.1.1
- network 3.3.3.0 0.0.0.255 area 0
- network 192.168.1.0 0.0.0.255 area 0
- !
- ip route 0.0.0.0 0.0.0.0 202.96.128.1
分支R5配置:
- crypto isakmp policy 10
- encr 3des
- authentication pre-share
- crypto isakmp key 110 address 0.0.0.0 0.0.0.0
- !
- crypto ipsec transform-set myset esp-3des esp-md5-hmac
- !
- crypto ipsec profile cisco
- set transform-set myset
- !
- interface Loopback0
- ip address 2.2.2.1 255.255.255.0
- !
- interface Tunnel0
- ip address 192.168.1.2 255.255.255.0
- no ip redirects
- ip nhrp authentication cisco
- ip nhrp map multicast 202.96.128.2 //靜態指向Hub的物理接口地址
- ip nhrp map 192.168.1.1 202.96.128.2 ////創建一個邏輯IP地址和NBMA地址的靜態綁定
- ip nhrp network-id 999
- ip nhrp nhs 192.168.1.1 //NHS查詢器地址
- ip nhrp cache non-authoritative
- ip ospf network broadcast
- tunnel source FastEthernet1/0
- tunnel mode gre multipoint
- tunnel protection ipsec profile cisco
- !
- interface FastEthernet0/0
- no ip address
- shutdown
- duplex half
- !
- interface FastEthernet1/0
- ip address 202.96.129.2 255.255.255.0
- duplex auto
- speed auto
- !
- interface FastEthernet1/1
- no ip address
- shutdown
- duplex auto
- speed auto
- !
- router ospf 100
- log-adjacency-changes
- network 2.2.2.0 0.0.0.255 area 0
- network 192.168.1.0 0.0.0.255 area 0
- !
- ip route 0.0.0.0 0.0.0.0 202.96.129.1
分支R6配置如下:
- crypto isakmp policy 10
- encr 3des
- authentication pre-share
- crypto isakmp key 110 address 0.0.0.0 0.0.0.0
- !
- crypto ipsec transform-set myset esp-3des esp-md5-hmac
- !
- crypto ipsec profile cisco
- set transform-set myset
- !
- interface Loopback0
- ip address 4.4.4.1 255.255.255.0
- !
- interface Tunnel0
- ip address 192.168.1.3 255.255.255.0
- no ip redirects
- ip nhrp authentication cisco
- ip nhrp map multicast 202.96.128.2
- ip nhrp map 192.168.1.1 202.96.128.2
- ip nhrp network-id 999
- ip nhrp nhs 192.168.1.1
- ip nhrp cache non-authoritative
- ip ospf network broadcast
- tunnel source FastEthernet1/0
- tunnel mode gre multipoint
- tunnel protection ipsec profile cisco
- !
- router ospf 100
- log-adjacency-changes
- network 4.4.4.0 0.0.0.255 area 0
- network 192.168.1.0 0.0.0.255 area 0
- !
- ip route 0.0.0.0 0.0.0.0 202.96.130.1
現在看一下分支與中心的路由表
中心R1
分支R5
分支R6
在R5上TRCKER一下4.4.4.1(在R6上)
OK.實驗結束