普通的IPSEC ***主要適用於不同廠家***之間的對接,兼容性非常好,IOS路由器和ASA可以和大部分的非思科廠家的***設備進行IPSEC ***對接。然而,這種普通的IPSEC ***並不適用於複雜的網絡環境,主要存在如下問題:
由於沒有虛擬隧道接口,不支持通過運行動態路由協議來實現路由互通;
由於沒有虛擬隧道接口,不能對通信點之間的明文流量進行控制和監測(如ACL、QOS、NAT、Netflow等);
操作較多,每增加一個站點或網段,都要增加許多感興趣流,排錯複雜。
爲了解決普通IPSEC ***配置存在的問題,Cisco IOS提供了兩種解決方案,如下:
GREover IPSEC
SVTI(12.4以後開始支持)
今天介紹GRE Over IPSEC 技術。所謂GRE Over IPSEC,即通過GRE來建立虛擬隧道,運行動態路由協議(解決普通IPSEC ***不支持動態路由協議,感興趣多的問題)來學習路由,通過在虛擬隧道接口上配置ACL、QOS等技術來控制數據流(解決上述第二個問題),通過IPSEC技術將GRE隧道中的數據進行保護。
注意:思科的ASA不支持GRE技術,只能使用普通 IPSEC ***技術,因此當部署站點到站點的***的時候,優先使用思科的路由器。思科的路由器在購買的時候需要向代理商詢問購買的路由器是否包含了Security的license,否則還可能需要額外購買license。
分析GREOver IPSec 解決問題的思路
如圖所示,我們爲使兩個站點連通,使用GRE在兩臺路由器之間建立了一條隧道,GRE隧道的作用就是虛擬地把兩個站點連接在一起,就像是拉了一根專線一樣把站點A(R1路由器)和站點B(R3路由器)連接起來,中間沒有其他設備。這樣就可以在這根“線”兩端的兩個接口上配置IP地址,並且運行動態路由選擇協議,使得兩臺路由器分別學習到對方身後網絡的路由。這樣,已經解決了第一個問題,可以運行動態路由協議;第二個問題,在tunnel接口進行數據控制和採集。接下來來分析使感興趣流減少的問題。圖中的A和B分別是兩個站點的公網IP地址,讀者可以從圖中發現一個規律,即不管GRE封裝之前的原始數據如何,封裝之後的源IP都是A,目標IP都是B,也就是我們只需要將A到B和B到A的流量分別在R1和R3上配置爲感興趣流即可。這樣就可以把所有的GRE流量都進行了加密。這樣,通過GRE Over IPSec,即解決了安全問題,也解決了普通IPSEC ***感興趣流過多,配置複雜的問題。
GRE Over IPSEC,加密點等於通信點,是一個典型的傳輸模式的IPSEC***,因此GRE Over IPSEC推薦使用傳輸模式。如果使用隧道模式,就會增加一個20字節的IP頭部,因此,GRE技術經過IPSEC加密使用傳輸模式更加優化。
下面演示一個實驗
實驗拓撲:
基礎配置如下:
R1配置:
en
conf t
host R1
int f0/0
ip add 12.1.1.1 255.255.255.0
no shut
int lo 0
ip add 1.1.1.1 255.255.255.0
ip route 0.0.0.0 0.0.0.0 12.1.1.2
R2配置:
en
conf t
host R2
int f0/0
ip add 12.1.1.2 255.255.255.0
no shut
int f1/0
ip add 23.1.1.2 255.255.255.0
no shut
R3配置:
en
conf t
host R3
int f1/0
ip add 23.1.1.3 255.255.255.0
no shut
int lo 0
ip add 3.3.3.3 255.255.255.0
ip route 0.0.0.0 0.0.0.0 23.1.1.2
配置完成後,檢測R1和R3的連通性:
在R1上pingR3的公網IP地址:
R1#ping 23.1.1.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 23.1.1.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/67/80 ms
可以ping通,說明公網通信正常。
GRE隧道配置:
R1配置如下:
int tunnel 0
ip add 172.16.1.1 255.255.255.0
tunnel source f0/0
tunnel destination 23.1.1.3
R3配置如下:
int tunnel 0
ip add 172.16.1.2 255.255.255.0
tunnel source f1/0
tunnel destination 12.1.1.1
配置完成後,檢查GRE的連通性:
在R1上ping對端tunnel接口的IP地址:R1#ping 172.16.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 152/168/196 ms
可以ping通,說明GRE配置正確。
GRE Over IPSEC配置:
GRE Over IPSEC有配置起來有兩種實現方法,一種是按照按照我們的分析思路,配置crypto策略,ipsec轉換集,再配置感興趣流,最後配置crypto map來實現;另一種是在Cisco提供的直接在tunnel接口下啓用ipsec保護,通過ipsec profile的方式來進行加密GRE流量,相比第一種更加簡單,但實現的效果是一樣的,我們在R1上使用第一種配置方法,在R3上使用第二種配置方法。
R1(config)#crypto isakmp policy 10
R1(config-isakmp)# hash md5
R1(config-isakmp)# authentication pre-share
R1(config-isakmp)#
R1(config-isakmp)#crypto isakmp key cisco address 23.1.1.3
R1(config)#
R1(config)#crypto ipsec transform-set trans esp-des esp-md5-hmac
R1(cfg-crypto-trans)# mode transport
R1(cfg-crypto-trans)#
R1(cfg-crypto-trans)#access-list 100 permit gre host 12.1.1.1 host 23.1.1.3
//注意:這裏是將R1去往R3的GRE流量進行加密,因此協議需要選擇GRE,如果是IP,將會出問題。
R1(config)#
R1(config)#crypto map cisco 10 ipsec-isakmp
% NOTE: This new crypto map will remain disabled until a peer
and a valid access list have been configured.
R1(config-crypto-map)#set peer 23.1.1.3
R1(config-crypto-map)#set transform-set trans
R1(config-crypto-map)#match address 100
R1(config-crypto-map)#
R1(config-crypto-map)#int f0/0
R1(config-if)#crypto map cisco
R3配置如下:
R3(config)#crypto isakmp policy 10
R3(config-isakmp)# hash md5
R3(config-isakmp)# authentication pre-share
R3(config-isakmp)#crypto isakmp key cisco address 12.1.1.1
R3(config)#!
R3(config)#crypto ipsec transform-set trans esp-des esp-md5-hmac
R3(cfg-crypto-trans)# mode transport
R3(cfg-crypto-trans)#!
R3(cfg-crypto-trans)#crypto ipsec profile ipsec-profile
R3(ipsec-profile)# set transform-set trans
R3(ipsec-profile)#
R3(ipsec-profile)#int tunnel 0
R3(config-if)#tunnel protection ipsec profile ipsec-profile
這是一種全新的IPsec Profile的配置方式,僅僅在ipsec profile下配置了轉換集,而沒有設置對等體和感興趣的內容。但需要注意的是,這個配置是被運用在接口下的,因此用來保護的是這個tunnel接口下的流量,所以感興趣流是有的。對等體也不缺少,因爲保護隧道,隧道的目的自然是IPSEC的對等體。這種配置方式還會在VTI和DM***中繼續採用。
驗證:
在R1和R3上分別查看IKE SA和IPSEC的SA
R1#show crypto isakmp sa
IPv4 Crypto ISAKMP SA
dst src state conn-id slot status
12.1.1.1 23.1.1.3 QM_IDLE 1001 0 ACTIVE
R1#show crypto ipsec sa
interface: FastEthernet0/0
Crypto map tag: cisco, local addr 12.1.1.1
protected vrf: (none)
local ident (addr/mask/prot/port): (12.1.1.1/255.255.255.255/47/0)
remote ident (addr/mask/prot/port): (23.1.1.3/255.255.255.255/47/0)
current_peer 23.1.1.3 port 500
PERMIT, flags={origin_is_acl,}
#pkts encaps: 10, #pkts encrypt: 10, #pkts digest: 10
#pkts decaps: 10, #pkts decrypt: 10, #pkts verify: 10
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 0, #recv errors 0
local crypto endpt.: 12.1.1.1, remote crypto endpt.: 23.1.1.3
path mtu 1500, ip mtu 1500, ip mtu idb FastEthernet0/0
current outbound spi: 0xD2177EFF(3524755199)
inbound esp sas:
spi: 0xD9C7873B(3653732155)
transform: esp-des esp-md5-hmac ,
in use settings ={Transport, } //傳輸模式
conn id: 1, flow_id: SW:1, crypto map: cisco
sa timing: remaining key lifetime (k/sec): (4568194/3365)
IV size: 8 bytes
replay detection support: Y
Status: ACTIVE
outbound esp sas:
spi: 0xD2177EFF(3524755199)
transform: esp-des esp-md5-hmac ,
in use settings ={Transport, }
conn id: 2, flow_id: SW:2, crypto map: cisco
sa timing: remaining key lifetime (k/sec): (4568194/3364)
IV size: 8 bytes
replay detection support: Y
Status: ACTIVE
查看加解密:
R1#show crypto engine connections active
Crypto Engine Connections
ID Interface Type Algorithm Encrypt Decrypt IP-Address
1 Fa0/0 IPsec DES+MD5 0 10 12.1.1.1
2 Fa0/0 IPsec DES+MD5 10 0 12.1.1.1
1001 Fa0/0 IKE MD5+DES 0 0 12.1.1.1
運行動態路由協議:
R1配置:
router ospf 110
router-id 1.1.1.1
net 172.16.1.0 0.0.0.255 a 0
net 1.1.1.0 0.0.0.255 a 0
R3配置:
router ospf 110
router-id 3.3.3.3
net 172.16.1.0 0.0.0.255 a 0
net 3.3.3.0 0.0.0.255 a 0
測試R1和R3身後的網絡:
R1#ping 3.3.3.3 source 1.1.1.1
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 116/146/188 ms
ping測試成功,到此,實驗完成。