06-IKEv2配置
本章節下載: 06-IKEv2配置 (472.75 KB)
目 錄
1.4.2 指定IKEv2協商時本端和對端采用的身份認證方式
1.8.1 配置IKEv2 cookie-challenge功能
1.11.1 IKEv2提議不匹配導致IKEv2 SA協商失敗
1.11.2 IPsec提議不匹配導致IPsec SA協商失敗
IKEv2(Internet Key Exchange Version 2,互聯網密鑰交換協議第2版)是第1版本的IKE協議(本文簡稱IKEv1)的增強版本。IKEv2與IKEv1相同,具有一套自保護機製,可以在不安全的網絡上安全地進行身份認證、密鑰分發、建立IPsec SA。相對於IKEv1,IKEv2具有抗攻擊能力和密鑰交換能力更強以及報文交互數量較少等特點。
要建立一對IPsec SA,IKEv1需要經曆兩個階段,至少需要交換6條消息。在正常情況下,IKEv2隻需要進行兩次交互,使用4條消息就可以完成一個IKEv2 SA和一對IPsec SA的協商建立,如果要求建立的IPsec SA的數目大於一對,則每增加一對IPsec SA隻需要額外增加一次交互,也就是兩條消息就可以完成,這相比於IKEv1簡化了設備的處理過程,提高了協商效率。
IKEv2定義了三種交互:初始交換、創建子SA交換以及通知交換。
下麵簡單介紹一下IKEv2協商過程中的初始交換過程。
圖1-1 IKEv2的初始交換過程
如圖1-1所示,IKEv2的初始交換過程中包含兩個交換:IKE_SA_INIT交換(兩條消息)和IKE_AUTH交換(兩條消息)。
· IKE_SA_INIT交換:完成IKEv2 SA參數的協商以及密鑰交換;
· IKE_AUTH交換:完成通信對等體的身份認證以及IPsec SA的創建。
這兩個交換過程順序完成後,可以建立一個IKEv2 SA和一對IPsec SA。
創建子SA交換:當一個IKE SA需要創建多個IPsec SA時,使用創建子SA交換來協商多於一個的SA,另外還可用於進行IKE SA的重協商功能。
通知交換:用於傳遞控製信息,例如錯誤信息或通告信息。
在IKE_SA_INIT交換階段,發起方采用“猜”的辦法,猜一個響應方最可能使用的DH組攜帶在第一條消息中發送。響應方根據發起方“猜”的DH組來響應發起方。如果發起方猜測成功,則這樣通過兩條消息就可以完成IKE_SA_INIT交換。如果發起方猜測錯誤,則響應方會回應一個INVALID_KE_PAYLOAD消息,並在該消息中指明將要使用的DH組。之後,發起方采用響應方指定的DH組重新發起協商。這種DH猜想機製,使得發起方的DH組配置更為靈活,可適應不同的響應方。
在IKE_SA_INIT交換中消息是明文傳輸的,響應方接收到第一個消息後無法確認該消息是否來自一個仿冒的地址。如果此時一個網絡攻擊者偽造大量地址向響應方發送IKE_SA_INIT請求,根據IKEv1協議,響應方需要維護這些半開的IKE會話信息,從而耗費大量響應方的係統資源,造成對響應方的DoS攻擊。
IKEv2使用cookie-challenge機製來解決這類DoS攻擊問題。當響應方發現存在的半開IKE SA超過指定的數目時,就啟用cookie-challenge機製。響應方收到IKE_SA_INIT請求後,構造一個Cookie通知載荷並響應發起方,若發起方能夠正確攜帶收到的Cookie通知載荷向響應方重新發起IKE_SA_INIT請求,則可以繼續後續的協商過程。
半開狀態的IKEv2 SA是指那些正在協商過程中的IKEv2 SA。若半開狀態的IKEv2 SA數目減少到閾值以下,則cookie-challenge功能將會停止工作
為了保證安全,IKE SA和IPsec SA都有一個生存時間,超過生存時間的SA需要重新協商,即SA 的重協商。與IKEv1不同的是,IKEv2 SA的生存時間不需要協商,由各自的配置決定,重協商總是由生存時間較小的一方發起,可盡量避免兩端同時發起重協商造成冗餘SA的生成,導致兩端SA狀態不一致。
與IKEv1不同,IKEv2中所有消息都是以“請求–響應”對的形式出現,IKEv2通過消息頭中的一個Message ID字段來標識一個“請求–響應”對。發起方發送的每一條消息都需要響應方給予確認,例如建立一個IKE SA一般需要兩個“請求-響應”對。如果發起方在規定時間內沒有接收到確認報文,則需要對該請求消息進行重傳。IKEv2消息的重傳隻能由發起方發起,且重傳消息的Message ID必須與原始消息的Message ID一致。
與IKEv2相關的協議規範有:
· RFC 2408:Internet Security Association and Key Management Protocol (ISAKMP)
· RFC 4306:Internet Key Exchange (IKEv2) Protocol
· RFC 4718:IKEv2 Clarifications and Implementation Guidelines
· RFC 2412:The OAKLEY Key Determination Protocol
· RFC 5996:Internet Key Exchange Protocol Version 2 (IKEv2)
IKEv2配置任務如下:
(1) 配置IKEv2 profile
d. 配置本端身份信息
e. 配置匹配對端身份的規則
g. 配置內部VPN實例
(2) 配置IKEv2安全策略
(3) 配置IKEv2安全提議
若IKEv2安全策略中指定了IKEv2提議,則必配。
(4) 配置IKEv2 keychain
隻要其中一端配置的認證方式為預共享密鑰方式,則必選。
如果兩端配置的認證方式都是RSA數字簽名方式,則不需要配置。
(5) (可選)配置IKEv2 cookie-challenge功能
該功能僅對於響應方有意義。
(6) (可選)配置全局IKEv2 DPD探測功能
(7) (可選)配置IKEv2 NAT Keepalive功能
(8) (可選)配置為對端分配IP地址的IKEv2本地地址池
為了配置過程順利進行,在IKEv2配置之前,用戶需要確定以下幾個因素:
· 確定IKEv2初始交換過程中使用的算法的強度,即確定對初始交換進行安全保護的強度(包括加密算法、完整性校驗算法、PRF算法和DH組算法)。不同的算法的強度不同,算法強度越高,受保護數據越難被破解,但消耗的計算資源越多。一般來說,密鑰越長的算法強度越高。
· 確定本地認證方法以及對端的認證方法。若使用預共享密鑰方式,則要確定通信雙方預先約定的預共享密鑰;若使用RSA數字簽名方式,則要確定本端所使用的PKI域。關於PKI的配置,請參見“安全配置指導”中的“PKI”。
創建一個IKEv2 profile,並進入IKEv2 Profile視圖。
(1) 進入係統視圖。
system-view
(2) 創建一個IKEv2 profile,並進入IKEv2 Profile視圖。
ikev2 profile profile-name
IKEv2協商時本端和對端采用的身份認證方式。隻能指定一個本端身份認證方式,可以指定多個對端身份認證方式。本端和對端可以采用不同的身份認證方式。
(1) 進入係統視圖。
system-view
(2) 進入IKEv2 Profile視圖。
ikev2 profile profile-name
(3) 指定IKEv2本端和對端的身份認證方式。
authentication-method { local | remote } { dsa-signature | ecdsa-signature | pre-share | rsa-signature }
缺省情況下,未配置本端和對端認證方式。
根據IKEv2 profile中配置的認證方法,配置IKEv2 keychain或PKI域。
· 如果任意一方指定的身份認證方式為數字簽名(dsa-signature、rsa-signature或者ecdsa-signature),則需要配置PKI域。
· 如果任意一方指定的身份認證方式為預共享密鑰(pre-share),則需要配置IKEv2 keychain。
(1) 進入係統視圖。
system-view
(2) 進入IKEv2 Profile視圖。
ikev2 profile profile-name
(3) 根據IKEv2 profile中配置的認證方法,配置IKEv2 keychain或PKI域
¡ 配置采用預共享密鑰認證時使用的Keychain
keychain keychain-name
¡ 配置采用數字簽名認證時使用的PKI域。
certificate domain domain-name [ sign | verify ]
根據authentication-method命令使用的認證方法選擇其中一個配置。
· 如果本端的認證方式為數字簽名,則可以配置任何類型的身份信息。若配置的本端身份為IP地址,但這個IP地址與本地證書中的IP地址不同,設備將使用FQDN類型的本端身份,該身份的內容為設備的名稱(可通過sysname命令配置)。
· 如果本端的認證方式為預共享密鑰,則隻能配置除DN之外的其它類型的身份信息。
(1) 進入係統視圖。
system-view
(2) 進入IKEv2 Profile視圖。
ikev2 profile profile-name
(3) 配置本端身份信息。
identity local { address { ipv4-address | ipv6 ipv6-address } | dn | email email-string | fqdn fqdn-name | key-id key-id-string }
缺省情況下,未配置本端身份信息。此時使用IP地址標識本端的身份,該IP地址為IPsec安全策略應用的接口的IP地址。
IKEv2對等體需要根據對端的身份信息查找一個本端的IKEv2 profile,然後使用此IKEv2 profile中的信息驗證對端身份。對端身份信息若能滿足本地某個IKEv2 profile中指定的匹配規則,則該IKEv2 profile為查找的結果。匹配IKEv2 profile的順序取決於IKEv2 profile的優先級,優先級高的先匹配。
(1) 進入係統視圖。
system-view
(2) 進入IKEv2 Profile視圖。
ikev2 profile profile-name
(3) 配置匹配對端身份的規則。
match remote { certificate policy-name | identity { address { { ipv4-address [ mask | mask-length ] | range low-ipv4-address high-ipv4-address } | ipv6 { ipv6-address [ prefix-length ] | range low-ipv6-address high-ipv6-address } } | fqdn fqdn-name | email email-string | key-id key-id-string } }
協商雙方都必須配置至少一個match remote規則,當對端的身份與IKEv2 profile中配置的match remote規則匹配時,則使用此IKEv2 profile中的信息與對端完成認證。
本功能限製IKEv2 profile隻能在所屬VPN實例的接口上協商。
(1) 進入係統視圖。
system-view
(2) 進入IKEv2 Profile視圖。
ikev2 profile profile-name
(3) 配置IKEv2 profile所屬的VPN實例。
match vrf { name vrf-name | any }
缺省情況下,IKEv2 profile屬於公網。
當IPsec解封裝後的報文需要繼續轉發到不同的VPN時,設備需要知道在哪個VPN實例中查找相應的路由。缺省情況下,設備在與外網相同的VPN實例中查找路由,如果不希望在與外網相同的VPN實例中查找路由,則可以指定一個內部VPN實例,通過查找該內部VPN實例的路由來轉發報文。
同一個ACL下配置的多條規則中綁定的VPN實例必須相同,且本功能配置的VPN實例必須與ACL下綁定的VPN實例相同。
(1) 進入係統視圖。
system-view
(2) 進入IKEv2 Profile視圖。
ikev2 profile profile-name
(3) 配置內部VPN實例。
inside-vrf vrf-name
缺省情況下,IKEv2 profile未指定內部VPN實例,即內網與外網在同一個VPN中。
(1) 進入係統視圖。
system-view
(2) 進入IKEv2 Profile視圖。
ikev2 profile profile-name
(3) 配置IKEv2 profile的可選功能。
¡ 配置IKEv2 DPD探測功能。
dpd interval interval [ retry seconds ] { on-demand | periodic }
缺省情況下,IKEv2 profile視圖下沒有配置DPD探測功能,采用係統視圖下的DPD配置。若兩者沒有配置,則不進行DPD探測。
¡ 配置IKEv2 profile的使用範圍。
match local address { interface-type interface-number | ipv4-address | ipv6 ipv6-address }
缺省情況下,未限製IKEv2 profile的使用範圍。
限製IKEv2 profile隻能在指定的地址或指定接口的地址下使用(這裏的地址指的是IPsec策略下配置的本端地址,若本端地址沒有配置,則為引用IPsec策略的接口下地址)。
¡ 配置IKEv2 profile的優先級。
priority priority
缺省情況下,IKEv2 profile的優先級為100。
優先級僅用於響應方在查找IKEv2 profile時調整IKEv2 profile的匹配順序。
¡ 配置IKEv2 SA生存時間。
sa duration seconds
缺省情況下,IKEv2 SA的生存時間為86400秒。
本端和對端的IKEv2 SA生存時間可以不一致,也不需要進行協商,由生存時間較短的一方在本端IKEv2 SA生存時間到達之後發起重協商。
¡ 配置發送NAT keepalive的時間間隔。
nat-keepalive seconds
缺省條件下,使用全局的IKEv2 NAT keepalive配置。
在IKEv2 peer之間存在NAT網關的情況下,設備通過定期向對端發送NAT keepalive 報文,防止已有的NAT會話表項因長時間無流量匹配而被老化。
¡ 開啟指定的配置交換功能。
config-exchange { request | set { accept | send } }
缺省條件下,所有的配置交換功能均處於關閉狀態。
該功能用於分支和總部虛擬隧道IP地址的請求和分配。
參數 |
說明 |
request |
用於分支側向中心側安全網關提交IP地址分配請求 |
set accept |
用於分支側接受中心側主動推送的IP地址 |
set send |
用於中心側主動推送IP地址給分支側 |
¡ 開啟AAA授權功能。
aaa authorization domain domain-name username user-name
缺省條件下,IKEv2的AAA授權功能處於關閉狀態。
通過AAA授權獲取一個地址池的名字,地址池中配置了可分配給對端的IP地址。關於AAA授權IKE本地地址池的具體配置請參見“用戶接入與認證”中的“AAA”。
在進行IKE_SA_INIT協商時,係統需要查找到一個與本端相匹配的IKEv2安全策略,並使用其中引用的安全提議進行安全參數的協商,匹配的依據為本端安全網關的IP地址。
· 若係統中配置了IKEv2安全策略,則根據本端安全網關的IP地址與所有已配置的IKEv2安全策略進行逐一匹配,如果未找到匹配的IKEv2安全策略或找到的安全策略中引用的安全提議配置不完整,則IKE_SA_INIT協商將會失敗。
· 若係統中未配置任何IKEv2安全策略,則直接采用缺省的IKEv2安全策略default。
· 係統中存在多個IKEv2安全策略的情況下,係統根據安全策略的優先級從高到低的順序依次匹配。如果通過match local address命令指定了匹配IKEv2安全策略的本端地址,則優先匹配指定了本端地址匹配條件的策略,其次匹配未指定本端地址匹配條件的策略。
(1) 進入係統視圖。
system-view
(2) 創建IKEv2安全策略,並進入IKEv2安全策略視圖。
ikev2 policy policy-name
缺省情況下,存在一個名稱為default的缺省IKEv2安全策略。
(3) 指定匹配IKEv2安全策略的本端地址。
match local address { interface-type interface-number | ipv4-address | ipv6 ipv6-address }
缺省情況下,未指定用於匹配IKEv2安全策略的本端地址,表示本策略可匹配所有本端地址。
(4) 配置匹配IKEv2安全策略的VPN實例。
match vrf { name vrf-name | any }
缺省情況下,未指定用於匹配IKEv2安全策略的VPN實例,表示本策略可匹配公網內的所有本端地址。
(5) 指定IKEv2安全策略引用的IKEv2安全提議。
proposal proposal-name
缺省情況下,IKEv2安全策略未引用IKEv2安全提議。
(6) 指定IKEv2安全策略的優先級。
priority priority
缺省情況下,IKEv2安全策略的優先級為100。
IKEv2安全提議用於保存IKE_SA_INIT交換中使用的安全參數,包括加密算法、完整性驗證算法、PRF算法和DH組,其中每類安全參數均可以配置多個,其優先級按照配置順序依次降低。
· 一個完整的IKEv2安全提議中至少應該包含一組安全參數,即一個加密算法、一個完整性驗證算法、一個PRF算法和一個DH組。
· 若同時指定了多個IKEv2安全提議,則它們的優先級按照配置順序依次降低。
(1) 進入係統視圖。
system-view
(2) 創建IKEv2安全提議,並進入IKEv2提議視圖。
ikev2 proposal proposal-name
缺省條件下,存在一個名稱為default的缺省IKEv2安全提議。
該提議中定義的加密算法為aes-cbc-128和3des,完整性校驗算法為sha1和md5,PRF算法為sha1和md5,DH組為group5和group2。
(3) 指定IKEv2安全提議使用的加密算法。
encryption { 3des-cbc | aes-cbc-128 | aes-cbc-192 | aes-cbc-256 | aes-ctr-128 | aes-ctr-192 | aes-ctr-256 | camellia-cbc-128 | camellia-cbc-192 | camellia-cbc-256 | des-cbc } *
缺省情況下,IKEv2安全提議未定義加密算法。
(4) 指定IKEv2安全提議使用的完整性校驗算法。
integrity { aes-xcbc-mac | md5 | sha1 | sha256 | sha384 | sha512 } *
缺省情況下,IKEv2安全提議未定義完整性校驗算法。
(5) 指定IKEv2安全提議使用的DH組。
dh { group1 | group14 | group2 | group24 | group5 | group19 | group20 } *
缺省情況下,IKEv2安全提議未定義DH組。
(6) 指定IKEv2安全提議使用的PRF算法。
prf { aes-xcbc-mac | md5 | sha1 | sha256 | sha384 | sha512 } *
缺省情況下,IKEv2安全提議使用配置的完整性校驗算法作為PRF算法。
IKEv2 keychain用來指定與對端進行IKEv2協商時使用的共享密鑰信息。一個IKEv2 keychain下可以指定多個IKEv2 peer,每個IKEv2 peer中包含了一個對稱預共享密鑰或一個非對稱預共享密鑰對,以及用於查找該IKEv2 peer的匹配參數(對等體的主機名稱、IP地址或地址範圍、身份信息)。其中,IKEv2協商的發起方使用對端的主機名稱、IP地址或地址範圍查找IKEv2 peer,響應方使用對端的IP地址、地址範圍或身份信息查找IKEv2 peer。
(1) 進入係統視圖。
system-view
(2) 創建IKEv2 keychain,並進入IKEv2 keychain視圖。
ikev2 keychain keychain-name
(3) 創建IKEv2 peer,並進入IKEv2 peer視圖。
peer name
(4) 指定IKEv2 peer的主機名稱。
hostname name
缺省情況下,未配置IKEv2 peer的主機名稱。
(5) 指定IKEv2 peer的主機地址。
address { ipv4-address [ mask | mask-length ] | ipv6 ipv6-address [ prefix-length ] }
缺省情況下,未指定IKEv2 peer的主機地址。
不同的IKEv2 peer中不能指定相同的主機地址。
(6) 指定IKEv2 peer的身份信息。
identity { address { ipv4-address | ipv6 { ipv6-address } } | fqdn fqdn-name | email email-string | key-id key-id-string }
缺省情況下,未指定IKEv2 peer的身份信息。
(7) 配置IKEv2 peer的預共享密鑰。
pre-shared-key [ local | remote ] { ciphertext | plaintext } string
缺省情況下,未配置IKEv2 peer的預共享密鑰。
IKEv2 cookie-challenge功能用來防止攻擊者通過源IP仿冒對響應方造成DoS攻擊。
開啟IKEv2 cookie-challenge功能的同時需要指定啟用cookie-challenge功能的閾值,當響應方本地存在的半開狀態的IKEv2 SA數目達到指定的閾值時,則cookie-challenge功能開始生效。
(1) 進入係統視圖。
system-view
(2) 開啟IKEv2 cookie-challenge功能。
ikev2 cookie-challenge number
缺省情況下,IKEv2 cookie-challenge功能處於關閉狀態。
IKEv2 DPD探測功能用來探測對端是否存活,包括以下兩種模式:
· 按需探測模式(on-demand):根據流量來探測對端是否存活。在本端發送用戶報文時,如果發現自最後一次收到對端報文之後,在指定的觸發IKEv2 DPD的時間間隔內一直未收到對端報文,則發送DPD報文探測對端是否存活。
· 定時探測模式(periodic):按照配置的觸發IKEv2 DPD的時間間隔定時發送DPD報文,探測對端是否存活。
當係統視圖下和IKEv2 profile視圖下都配置DPD探測功能時,IKEv2 profile視圖下的DPD配置覆蓋係統視圖下的全局DPD配置。若IKEv2 profile視圖下沒有配置DPD探測功能,則應用全局DPD配置。
(1) 進入係統視圖。
system-view
(2) 配置IKEv2 DPD探測功能。
ikev2 dpd interval interval [ retry seconds ] { on-demand | periodic }
缺省情況下,全局IKEv2 DPD探測功能處於關閉狀態。
IKEv2 NAT Keepalive功能僅對位於NAT之後的設備(即該設備位於NAT設備連接的私網側)有意義。NAT之後的IKEv2網關設備需要定時向NAT之外的IKEv2網關設備發送NAT Keepalive報文,以確保NAT設備上相應於該流量的會話存活,從而讓NAT之外的設備可以訪問NAT之後的設備。因此,配置的發送NAT Keepalive報文的時間間隔需要小於NAT設備上會話表項的存活時間。本功能必須在探測到NAT之後才能生效。
(1) 進入係統視圖。
system-view
(2) 配置向對端發送NAT Keepalive報文的時間間隔。
ikev2 nat-keepalive seconds
缺省情況下,探測到NAT後發送NAT Keepalive報文的時間間隔為10秒。
IKEv2本地地址池與AAA授權配合使用,可以向對端網關(客戶端)分配地址或應答地址請求,從而使得對端網關(企業分支客戶端)使用由企業中心網關統一分配的IP地址作為私網地址來進行通信,達到由企業中心統一管理的目的。關於AAA授權IKEv2本地地址池的具體配置請參見“用戶接入與認證”中的“AAA”。
(1) 進入係統視圖。
system-view
(2) 配置為對端分配IPv4地址的IKEv2本地地址池。
ikev2 address-group group-name start-ipv4-address end-ipv4-address [ mask | mask-length ]
(3) 配置為對端分配IPv6地址的IKEv2本地地址池。
ikev2 ipv6-address-group group-name prefix prefix/prefix-len assign-len assign-len
可在任意視圖下執行以下命令:
· 顯示IKEv2安全策略的配置信息。
display ikev2 policy [ policy-name | default ]
· 顯示IKEv2 profile的配置信息。
display ikev2 profile [ profile-name ]
· 顯示IKEv2安全提議的配置信息。
display ikev2 proposal [ name | default ]
· 顯示當前IKEv2 SA的信息。
display ikev2 sa [ count | [ { local | remote } { ipv4-address | ipv6 ipv6-address } [ vpn-instance vpn-instance-name ] ] [ verbose [ tunnel tunnel-id ] ] ]
· 顯示IKEv2統計信息。
display ikev2 statistics
請在用戶視圖下執行以下命令:
· 清除IKEv2 SA及其協商生成的Child SA。
reset ikev2 sa [ [ { local | remote } { ipv4-address | ipv6 ipv6-address } [ vpn-instance vpn-instance-name ] ] | tunnel tunnel-id ] [ fast ]
· 清除IKEv2統計信息。
reset ikev2 statistics
在Device A和Device B之間建立IPsec隧道,對Host A所在的子網(10.1.1.0/24)與Host B所在的子網(10.1.2.0/24)之間的數據流進行安全保護。
· Device A和Device B之間采用IKEv2協商方式建立IPsec SA。
· 使用缺省的IKEv2提議。
· 使用缺省的IKEv2安全策略。
圖1-2 IKEv2預共享密鑰認證典型組網圖
(1) 配置Device A
# 配置各接口的IP地址,具體略。
# 配置ACL 3101,定義要保護由子網10.1.1.0/24去子網10.1.2.0/24的數據流。
<DeviceA> system-view
[DeviceA] acl advanced 3101
[DeviceA-acl-ipv4-adv-3101] rule permit ip source 10.1.1.0 0.0.0.255 destination 10.1.2.0 0.0.0.255
[DeviceA-acl-ipv4-adv-3101] quit
# 創建IPsec安全提議tran1。
[DeviceA] ipsec transform-set tran1
# 配置安全協議對IP報文的封裝形式為隧道模式。
[DeviceA-ipsec-transform-set-tran1] encapsulation-mode tunnel
# 配置采用的安全協議為ESP。
[DeviceA-ipsec-transform-set-tran1] protocol esp
# 配置ESP協議采用的加密算法為DES,認證算法為HMAC-SHA1。
[DeviceA-ipsec-transform-set-tran1] esp encryption-algorithm des-cbc
[DeviceA-ipsec-transform-set-tran1] esp authentication-algorithm sha1
[DeviceA-ipsec-transform-set-tran1] quit
# 創建IKEv2 keychain,名稱為keychain1。
[DeviceA] ikev2 keychain keychain1
# 創建IKEv2對端,名稱為peer1。
[DeviceA-ikev2-keychain-keychain1] peer peer1
# 指定對端peer1的主機地址為2.2.2.2/16。
[DeviceA-ikev2-keychain-keychain1-peer-peer1] address 2.2.2.2 16
# 指定對端peer1的身份信息。
[DeviceA-ikev2-keychain-keychain1-peer-peer1] identity address 2.2.2.2
# 配置對端peer1使用的預共享密鑰為明文abcde。
[DeviceA-ikev2-keychain-keychain1-peer-peer1] pre-shared-key plaintext abcde
[DeviceA-ikev2-keychain-keychain1-peer-peer1] quit
[DeviceA-ikev2-keychain-keychain1] quit
# 創建IKEv2 profile,名稱為profile1。
[DeviceA] ikev2 profile profile1
# 指定本端的身份認證方式為預共享密鑰。
[DeviceA-ikev2-profile-profile1] authentication-method local pre-share
# 指定對端的身份認證方式為預共享密鑰。
[DeviceA-ikev2-profile-profile1] authentication-method remote pre-share
# 指定引用的IKEv2 keychain為keychain1。
[DeviceA-ikev2-profile-profile1] keychain keychain1
# 配置匹配對端身份的規則為IP地址2.2.2.2/16。
[DeviceA-ikev2-profile-profile1] match remote identity address 2.2.2.2 255.255.0.0
[DeviceA-ikev2-profile-profile1] quit
# 創建一條IKEv2協商方式的IPsec安全策略,名稱為map1,順序號為10。
[DeviceA] ipsec policy map1 10 isakmp
# 配置IPsec隧道的對端IP地址為2.2.2.2。
[DeviceA-ipsec-policy-isakmp-map1-10] remote-address 2.2.2.2
# 指定引用ACL 3101。
[DeviceA-ipsec-policy-isakmp-map1-10] security acl 3101
# 指定引用的安全提議為tran1。
[DeviceA-ipsec-policy-isakmp-map1-10] transform-set tran1
# 指定引用的IKEv2 profile為profile1。
[DeviceA-ipsec-policy-isakmp-map1-10] ikev2-profile profile1
[DeviceA-ipsec-policy-isakmp-map1-10] quit
# 在接口GigabitEthernet0/0/1上應用IPsec安全策略map1。
[DeviceA] interface gigabitethernet 0/0/1
[DeviceA-GigabitEthernet0/0/1] ipsec apply policy map1
[DeviceA-GigabitEthernet0/0/1] quit
# 配置到Host B所在子網的靜態路由。1.1.1.2為本例中的直連下一跳地址,實際使用中請以具體組網情況為準。
[DeviceA] ip route-static 10.1.2.0 255.255.255.0 1.1.1.2
(2) 配置Device B
# 配置各接口的IP地址,具體略。
# 配置ACL 3101,定義要保護由子網10.1.2.0/24去往子網10.1.1.0/24的數據流。
<DeviceB> system-view
[DeviceB] acl advanced 3101
[DeviceB-acl-ipv4-adv-3101] rule permit ip source 10.1.2.0 0.0.0.255 destination 10.1.1.0 0.0.0.255
[DeviceB-acl-ipv4-adv-3101] quit
# 創建IPsec安全提議tran1。
[DeviceB] ipsec transform-set tran1
# 配置安全協議對IP報文的封裝形式為隧道模式。
[DeviceB-ipsec-transform-set-tran1] encapsulation-mode tunnel
# 配置采用的安全協議為ESP。
[DeviceB-ipsec-transform-set-tran1] protocol esp
# 配置ESP協議采用的加密算法為DES,認證算法為HMAC-SHA1。
[DeviceB-ipsec-transform-set-tran1] esp encryption-algorithm des-cbc
[DeviceB-ipsec-transform-set-tran1] esp authentication-algorithm sha1
[DeviceB-ipsec-transform-set-tran1] quit
# 創建IKEv2 keychain,名稱為keychain1。
[DeviceB] ikev2 keychain keychain1
# 創建IKEV2對端,名稱為peer1。
[DeviceB-ikev2-keychain-keychain1] peer peer1
# 指定peer1的主機地址為1.1.1.1/16。
[DeviceB-ikev2-keychain-keychain1-peer-peer1] address 1.1.1.1 16
# 指定peer1的身份信息。
[DeviceB-ikev2-keychain-keychain1-peer-peer1] identity address 1.1.1.1
# 配置對端peer1使用的預共享密鑰為明文abcde。
[DeviceB-ikev2-keychain-keychain1-peer-peer1] pre-shared-key plaintext abcde
[DeviceB-ikev2-keychain-keychain1-peer-peer1] quit
[DeviceB-ikev2-keychain-keychain1] quit
# 創建IKEv2 profile,名稱為profile1。
[DeviceB] ikev2 profile profile1
# 指定本端的身份認證方式為預共享密鑰。
[DeviceB-ikev2-profile-profile1] authentication-method local pre-share
# 指定對端的身份認證方式為預共享密鑰。
[DeviceB-ikev2-profile-profile1] authentication-method remote pre-share
# 指定引用的IKEv2 keychain為keychain1。
[DeviceB-ikev2-profile-profile1] keychain keychain1
# 配置匹配對端身份的規則為IP地址1.1.1.1/16。
[DeviceA-ikev2-profile-profile1] match remote identity address 1.1.1.1 255.255.0.0
[DeviceA-ikev2-profile-profile1] quit
# 創建一條IKEv2協商方式的IPsec安全策略,名稱為use1,順序號為10。
[DeviceB] ipsec policy use1 10 isakmp
# 配置IPsec隧道的對端IP地址為1.1.1.1。
[DeviceB-ipsec-policy-isakmp-use1-10] remote-address 1.1.1.1
# 指定引用ACL 3101。
[DeviceB-ipsec-policy-isakmp-use1-10] security acl 3101
# 指定引用的安全提議為tran1。
[DeviceB-ipsec-policy-isakmp-use1-10] transform-set tran1
# 指定引用的IKEv2 profile為profile1。
[DeviceB-ipsec-policy-isakmp-use1-10] ikev2-profile profile1
[DeviceB-ipsec-policy-isakmp-use1-10] quit
# 在接口GigabitEthernet0/0/1上應用IPsec安全策略use1。
[DeviceB] interface gigabitethernet 0/0/1
[DeviceB-GigabitEthernet0/0/1] ipsec apply policy use1
[DeviceB-GigabitEthernet0/0/1] quit
# 配置到Host A所在子網的靜態路由。2.2.2.1為本例中的直連下一跳地址,實際使用中請以具體組網情況為準。
[DeviceB] ip route-static 10.1.1.0 255.255.255.0 2.2.2.1
以上配置完成後,Device A和Device B之間如果有子網10.1.1.0/24與子網10.1.2.0/24之間的報文通過,將觸發IKEv2協商。
# 可通過如下顯示信息查看到Device A上的IKEv2提議和IKEv2安全策略。
[DeviceA] display ikev2 proposal
IKEv2 proposal : default
Encryption: AES-CBC-128 3DES-CBC
Integrity: SHA1 MD5
PRF: SHA1 MD5
DH Group: MODP1536/Group5 MODP1024/Group2
[DeviceA] display ikev2 policy
IKEv2 policy : default
Match VRF : any
Proposal: default
Device B上IKEv2 提議和IKEv2安全策略的查看方式與Device A同,此處略。
# 可通過如下顯示信息查看到Device A上IKEv2協商成功後生成的IKEv2 SA。
[DeviceA] display ikev2 sa
Tunnel ID Local Remote Status
---------------------------------------------------------------------------
1 1.1.1.1/500 2.2.2.2/500 EST
Status:
IN-NEGO: Negotiating, EST: Established, DEL:Deleting
# 可通過如下顯示信息查看到IKEv2協商生成的IPsec SA。
[DeviceA] display ipsec sa
-------------------------------
Interface: GigabitEthernet0/0/1
-------------------------------
-----------------------------
IPsec policy: map1
Sequence number: 10
Mode: ISAKMP
-----------------------------
Tunnel id: 0
Encapsulation mode: tunnel
Perfect Forward Secrecy:
Inside VPN:
Extended Sequence Numbers enable: N
Traffic Flow Confidentiality enable: N
Path MTU: 1456
Tunnel:
local address: 1.1.1.1
remote address: 2.2.2.2
Flow:
sour addr: 10.1.1.0/255.255.255.0 port: 0 protocol: ip
dest addr: 10.1.2.0/255.255.255.0 port: 0 protocol: ip
[Inbound ESP SAs]
SPI: 3264152513 (0xc28f03c1)
Connection ID: 141733920771
Transform set: ESP-ENCRYPT-DES-CBC ESP-AUTH-SHA1
SA duration (kilobytes/sec): 1843200/3600
SA remaining duration (kilobytes/sec): 1843200/3484
Max received sequence-number:
Anti-replay check enable: Y
Anti-replay window size: 64
UDP encapsulation used for NAT traversal: N
Status: Active
[Outbound ESP SAs]
SPI: 738451674 (0x2c03e0da)
Connection ID: 64424509441
Transform set: ESP-ENCRYPT-DES-CBC ESP-AUTH-SHA1
SA duration (kilobytes/sec): 1843200/3600
SA remaining duration (kilobytes/sec): 1843200/3484
Max sent sequence-number:
UDP encapsulation used for NAT traversal: N
Status: Active
Device B上也會產生相應的IKEv2 SA和IPsec SA,查看方式與Device A同,此處略。
在Device A和Device B之間建立IPsec隧道,對Host A所在的子網(10.1.1.0/24)與Host B所在的子網(10.1.2.0/24)之間的數據流進行安全保護。
· Device A和Device B之間采用IKEv2協商方式建立IPsec SA。
· Device A和DeviceB均使用RSA數字簽名的認證方法。
· Device A側子網的IP地址為動態分配,並作為發起方。
圖1-3 IKEv2 RSA數字簽名認證典型組網圖
(1) 配置Device A
# 配置各接口的IP地址,具體略。
# 配置ACL 3101,定義要保護由子網10.1.1.0/24去往子網10.1.2.0/24的數據流。
<DeviceA> system-view
[DeviceA] acl advanced 3101
[DeviceA-acl-ipv4-adv-3101] rule permit ip source 10.1.1.0 0.0.0.255 destination 10.1.2.0 0.0.0.255
[DeviceA-acl-ipv4-adv-3101] quit
# 創建IPsec安全提議tran1。
[DeviceA] ipsec transform-set tran1
# 配置安全協議對IP報文的封裝形式為隧道模式。
[DeviceA-ipsec-transform-set-tran1] encapsulation-mode tunnel
# 配置采用的安全協議為ESP。
[DeviceA-ipsec-transform-set-tran1] protocol esp
# 配置ESP協議采用的加密算法為DES,認證算法為HMAC-SHA1。
[DeviceA-ipsec-transform-set-tran1] esp encryption-algorithm des-cbc
[DeviceA-ipsec-transform-set-tran1] esp authentication-algorithm sha1
[DeviceA-ipsec-transform-set-tran1] quit
# 創建PKI實體entity1。
[DeviceA] pki entity entity1
# 配置PKI實體的通用名。
[DeviceA-pki-entity-entity1] common-name devicea
[DeviceA-pki-entity-entity1] quit
# 創建PKI域domain1。
[DeviceA]pki domain domain1
# 配置證書申請模式為自動模式,並設置吊銷證書時使用的口令。
[DeviceA-pki-domain-domain1] certificate request mode auto password simple 123
# 配置驗證CA根證書時所使用的指紋。
[DeviceA-pki-domain-domain1] root-certificate fingerprint md5 50c7a2d282ea710a449eede6c56b102e
# 配置CA服務器名稱。
[DeviceA-pki-domain-domain1] ca identifier 8088
# 配置實體通過SCEP進行證書申請的注冊受理機構服務器的URL(此處的URL僅為示例,請以組網環境中的實際情況為準)。
[DeviceA-pki-domain-domain1] certificate request url http://192.168.222.1:446/eadbf9af4f2c4641e685f7a6021e7b298373feb7
# 配置證書申請的注冊受理機構。
[DeviceA-pki-domain-domain1] certificate request from ca
# 配置指定用於申請證書的PKI實體名稱。
[DeviceA-pki-domain-domain1] certificate request entity entity1
# 配置指定證書申請使用的RSA密鑰對。
[DeviceA-pki-domain-domain1] public-key rsa general name rsa1
[DeviceA-pki-domain-domain1] quit
# 創建IKEv2 profile,名稱為profile1。
[DeviceA] ikev2 profile profile1
# 指定本端的身份認證方式為RSA數字簽名。
[DeviceA-ikev2-profile-profile1] authentication-method local rsa-signature
# 指定對端的身份認證方式為RSA數字簽名。
[DeviceA-ikev2-profile-profile1] authentication-method remote rsa-signature
# 指定引用的PKI域為domain1。
[DeviceA-ikev2-profile-profile1] certificate domain domain1
# 配置FQDN名www.devicea.com作為本端的身份標識。
[DeviceA-ikev2-profile-profile1] identity local fqdn www.devicea.com
# 配置匹配對端身份的規則為FQDN名www.deviceb.com。
[DeviceA-ikev2-profile-profile1] match remote identity fqdn www.deviceb.com
[DeviceA-ikev2-profile-profile1] quit
# 創建IKEv2提議10。
[DeviceA] ikev2 proposal 10
# 指定IKEv2提議使用的完整性校驗算法為HMAC-MD5。
[DeviceA-ikev2-proposal-10] integrity md5
# 指定IKEv2提議使用的加密算法為3DES。
[DeviceA-ikev2-proposal-10] encryption 3des-cbc
# 指定IKEv2提議使用的DH group為group1。
[DeviceA-ikev2-proposal-10] dh group1
# 指定IKEv2提議使用的PRF算法為HMAC-MD5。
[DeviceA-ikev2-proposal-10] prf md5
[DeviceA-ikev2-proposal-10] quit
# 創建IKEv2安全策略1。
[DeviceA] ikev2 policy 1
# 指定引用的IKEv2 proposal 10。
[DeviceA-ikev2-policy-1] proposal 10
[DeviceA-ikev2-policy-1] quit
# 創建一條IKEv2協商方式的IPsec安全策略,名稱為map1,順序號為10。
[DeviceA] ipsec policy map1 10 isakmp
# 配置IPsec隧道的對端IP地址為2.2.2.2。
[DeviceA-ipsec-policy-isakmp-map1-10] remote-address 2.2.2.2
# 指定引用的安全提議為tran1。
[DeviceA-ipsec-policy-isakmp-map1-10] transform-set tran1
# 指定引用ACL 3101。
[DeviceA-ipsec-policy-isakmp-map1-10] security acl 3101
# 指定引用的IKEv2 profile為profile1。
[DeviceA-ipsec-policy-isakmp-map1-10] ikev2-profile profile1
[DeviceA-ipsec-policy-isakmp-map1-10] quit
# 在接口GigabitEthernet0/0/1上應用IPsec安全策略map1。
[DeviceA] interface gigabitethernet 0/0/1
[DeviceA-GigabitEthernet0/0/1] ipsec apply policy map1
[DeviceA-GigabitEthernet0/0/1] quit
# 配置到Host B所在子網的靜態路由。1.1.1.2為本例中的直連下一跳地址,實際使用中請以具體組網情況為準。
[DeviceA] ip route-static 10.1.2.0 255.255.255.0 1.1.1.2
(2) 配置Device B
# 配置各接口的IP地址,具體略。
# 配置ACL 3101,定義要保護由子網10.1.2.0/24去子網10.1.1.0/24的數據流。
[DeviceB] acl advanced 3101
[DeviceB-acl-ipv4-adv-3101] rule permit ip source 10.1.2.0 0.0.0.255 destination 10.1.1.0 0.0.0.255
[DeviceB-acl-ipv4-adv-3101] quit
# 創建IPsec安全提議tran1。
[DeviceB] ipsec transform-set tran1
# 配置安全協議對IP報文的封裝形式為隧道模式。
[DeviceB-ipsec-transform-set-tran1] encapsulation-mode tunnel
# 配置采用的安全協議為ESP。
[DeviceB-ipsec-transform-set-tran1] protocol esp
# 配置ESP協議采用的加密算法為DES,認證算法為HMAC-SHA-1-96。
[DeviceB-ipsec-transform-set-tran1] esp encryption-algorithm des-cbc
[DeviceB-ipsec-transform-set-tran1] esp authentication-algorithm sha1
[DeviceB-ipsec-transform-set-tran1] quit
# 創建PKI實體entity2。
[DeviceB] pki entity entity2
# 配置PKI實體的通用名。
[DeviceB-pki-entity-entity2] common-name deviceb
[DeviceB-pki-entity-entity2] quit
# 創建PKI域domain2。
[DeviceB] pki domain domain2
# 配置證書申請模式為自動模式,並設置吊銷證書時使用的口令。
[DeviceB-pki-domain-domain2] certificate request mode auto password simple 123
# 配置驗證CA根證書時所使用的指紋。
[DeviceB-pki-domain-domain2] root-certificate fingerprint md5 50c7a2d282ea710a449eede6c56b102e
# 配置CA服務器名稱。
[DeviceB-pki-domain-domain2] ca identifier 8088
# 配置實體通過SCEP進行證書申請的注冊受理機構服務器的URL(此處的URL僅為示例,請以組網環境中的實際情況為準)。
[DeviceB-pki-domain-domain2] certificate request url http://192.168.222.1:446/eadbf9af4f2c4641e685f7a6021e7b298373feb7
# 配置證書申請的注冊受理機構。
[DeviceB-pki-domain-domain2] certificate request from ca
# 配置指定用於申請證書的PKI實體名稱。
[DeviceB-pki-domain-domain2] certificate request entity entity2
# 配置指定證書申請使用的RSA密鑰對。
[DeviceB-pki-domain-domain2] public-key rsa general name rsa1
[DeviceB-pki-domain-domain2] quit
# 創建IKEv2 profile,名稱為profile2。
[DeviceB] ikev2 profile profile2
# 指定本端的身份認證方式為RSA數字簽名。
[DeviceB-ikev2-profile-profile2] authentication-method local rsa-signature
# 指定對端的身份認證方式為RSA數字簽名。
[DeviceB-ikev2-profile-profile2] authentication-method remote rsa-signature
# 配置FQDN名www.deviceb.com作為本端的身份標識。
[DeviceB-ikev2-profile-profile2] identity local fqdn www.deviceb.com
# 配置匹配對端身份的規則為FQDN名www.devicea.com。
[DeviceB-ikev2-profile-profile2] match remote identity fqdn www.devicea.com
[DeviceB-ikev2-profile-profile2] quit
# 創建IKEv2提議10。
[DeviceB] ikev2 proposal 10
# 指定IKEv2提議使用的完整性校驗算法為HMAC-MD5。
[DeviceB-ikev2-proposal-10] integrity md5
# 指定IKEv2提議使用的加密算法為3DES。
[DeviceB-ikev2-proposal-10] encryption 3des-cbc
# 指定IKEv2提議使用的DH group為group1。
[DeviceB-ikev2-proposal-10] dh group1
# 指定IKEv2提議使用的PRF算法為HMAC-MD5。
[DeviceB-ikev2-proposal-10] prf md5
[DeviceB-ikev2-proposal-10] quit
# 創建IKEv2安全策略1。
[DeviceB] ikev2 policy 1
# 指定引用的IKEv2 proposal 10。
[DeviceB-ikev2-policy-1] proposal 10
[DeviceB-ikev2-policy-1] quit
# 創建一條IPsec安全策略模板,名稱為template1,順序號為1。
[DeviceB] ipsec policy-template template1 1
# 配置IPsec隧道的對端IP地址為1.1.1.1。
[DeviceB-ipsec-policy-template-template1-1] remote-address 1.1.1.1
# 指定引用ACL 3101。
[DeviceB-ipsec-policy-template-template1-1] security acl 3101
# 指定引用的安全提議為tran1。
[DeviceB-ipsec-policy-template-template1-1] transform-set tran1
# 指定引用的IKEv2 profile為profile2。
[DeviceB-ipsec-policy-template-template1-1] ikev2-profile profile2
[DeviceB-ipsec-policy-template-template1-1] quit
# 引用IPsec安全策略模板創建一條IPsec安全策略,名稱為use1,順序號為1。
[DeviceB] ipsec policy use1 1 isakmp template template1
# 在接口GigabitEthernet0/0/1上應用IPsec安全策略use1。
[DeviceB] interface gigabitethernet 0/0/1
[DeviceB-GigabitEthernet0/0/1] ipsec apply policy use1
[DeviceB-GigabitEthernet0/0/1] quit
# 配置到Host A所在子網的靜態路由。2.2.2.1為本例中的直連下一跳地址,實際使用中請以具體組網情況為準。
[DeviceB] ip route-static 10.1.1.0 255.255.255.0 2.2.2.1
以上配置完成後,Device A和Device B之間如果有子網10.1.1.0/24與子網10.1.2.0/24之間的報文通過,將觸發IKEv2協商。
# 可通過如下顯示信息查看到Device A和Device B上的IKEv2提議。
[DeviceA] display ikev2 proposal 10
IKEv2 proposal : 10
Encryption : 3DES-CBC
Integrity : MD5
PRF : MD5
DH Group : MODP768/Group1
[DeviceB] display ikev2 proposal 10
IKEv2 proposal : 10
Encryption : 3DES-CBC
Integrity : MD5
PRF : MD5
DH Group : MODP768/Group1
# 可通過如下顯示信息查看到Device A和Device B上的IKEv2安全策略。
[DeviceA] display ikev2 policy 1
IKEv2 policy : 1
Priority: 100
Match Local : any
Match VRF : public
Proposal : 10
[DeviceB] display ikev2 policy 1
IKEv2 policy : 1
Priority: 100
Match Local : any
Match VRF : public
Proposal : 10
# 可通過如下顯示信息查看到Device A上IKEv2協商成功後生成的IKEv2 SA。
[DeviceA] display ikev2 sa
Tunnel ID Local Remote Status
---------------------------------------------------------------------------
1 1.1.1.1/500 2.2.2.2/500 EST
Status:
IN-NEGO: Negotiating, EST: Established, DEL:Deleting
# 可通過如下顯示信息查看到Device A上自動觸發獲取到的CA證書。
[DeviceA] display pki certificate domain domain1 ca
Certificate:
Data:
Version: 1 (0x0)
Serial Number:
b9:14:fb:25:c9:08:2c:9d:f6:94:20:30:37:4e:00:00
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=cn, O=rnd, OU=sec, CN=8088
Validity
Not Before: Sep 6 01:53:58 2012 GMT
Not After : Sep 8 01:50:58 2015 GMT
Subject: C=cn, O=rnd, OU=sec, CN=8088
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (1024 bit)
Modulus:
00:de:81:f4:42:c6:9f:c2:37:7b:21:84:57:d6:42:
00:69:1c:4c:34:a4:5e:bb:30:97:45:2b:5e:52:43:
c0:49:1f:e1:d8:0f:5c:48:c2:39:69:d1:84:e4:14:
70:3d:98:41:28:1c:20:a1:9a:3f:91:67:78:77:27:
d9:08:5f:7a:c4:36:45:8b:f9:7b:e7:7d:6a:98:bb:
4e:a1:cb:2c:3d:92:66:bd:fb:80:35:16:c6:35:f0:
ff:0b:b9:3c:f3:09:94:b7:d3:6f:50:8d:83:f1:66:
2f:91:0b:77:a5:98:22:b4:77:ac:84:1d:03:8e:33:
1b:31:03:78:4f:77:a0:db:af
Exponent: 65537 (0x10001)
Signature Algorithm: sha1WithRSAEncryption
9a:6d:8c:46:d3:18:8a:00:ce:12:ee:2b:b0:aa:39:5d:3f:90:
08:49:b9:a9:8f:0d:6e:7b:e1:00:fb:41:f5:d4:0c:e4:56:d8:
7a:a7:61:1d:2b:b6:72:e3:09:0b:13:9d:fa:c8:fc:c4:65:a7:
f9:45:21:05:75:2c:bf:36:7b:48:b4:4a:b9:fe:87:b9:d8:cf:
55:16:87:ec:07:1d:55:5a:89:74:73:68:5e:f9:1d:30:55:d9:
8a:8f:c5:d4:20:7e:41:a9:37:57:ed:8e:83:a7:80:2f:b8:31:
57:3a:f2:1a:28:32:ea:ea:c5:9a:55:61:6a:bc:e5:6b:59:0d:
82:16
# 可通過如下顯示信息查看到Device A上自動觸發申請到的本地證書。
[DeviceA]display pki certificate domain domain1 local
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
a1:f4:d4:fd:cc:54:c3:07:c4:9e:15:2d:5f:64:57:77
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=cn, O=rnd, OU=sec, CN=8088
Validity
Not Before: Sep 26 02:06:43 2012 GMT
Not After : Sep 26 02:06:43 2013 GMT
Subject: CN=devicea
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (1024 bit)
Modulus:
00:b0:a1:cd:24:6e:1a:1d:51:79:f0:2a:3e:9f:e9:
84:07:16:78:49:1b:7d:0b:22:f0:0a:ed:75:91:a4:
17:fd:c7:ef:d0:66:5c:aa:e3:2a:d9:71:12:e4:c6:
25:77:f0:1d:97:bb:92:a8:bd:66:f8:f8:e8:d5:0d:
d2:c8:01:dd:ea:e6:e0:80:ad:db:9d:c8:d9:5f:03:
2d:22:07:e3:ed:cc:88:1e:3f:0c:5e:b3:d8:0e:2d:
ea:d6:c6:47:23:6a:11:ef:3c:0f:6b:61:f0:ca:a1:
79:a0:b1:02:1a:ae:8c:c9:44:e0:cf:d1:30:de:4c:
f0:e5:62:e7:d0:81:5d:de:d3
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 CRL Distribution Points:
Full Name:
URI:http://xx.rsa.com:447/8088.crl
Signature Algorithm: sha1WithRSAEncryption
73:ac:66:f9:b8:b5:39:e1:6a:17:e4:d0:72:3e:26:9e:12:61:
9e:c9:7a:86:6f:27:b0:b9:a3:5d:02:d9:5a:cb:79:0a:12:2e:
cb:e7:24:57:e6:d9:77:12:6b:7a:cf:ee:d6:17:c5:5f:d2:98:
30:e0:ef:00:39:4a:da:ff:1c:29:bb:2a:5b:60:e9:33:8f:78:
f9:15:dc:a5:a3:09:66:32:ce:36:cd:f0:fe:2f:67:e5:72:e5:
21:62:85:c4:07:92:c8:f1:d3:13:9c:2e:42:c1:5f:0e:8f:ff:
65:fb:de:7c:ed:53:ab:14:7a:cf:69:f2:42:a4:44:7c:6e:90:
7e:cd
# 可通過如下顯示信息查看到Device A上IKEv2協商生成的IPsec SA。
[DeviceA] display ipsec sa
-------------------------------
Interface: GigabitEthernet0/0/1
-------------------------------
-----------------------------
IPsec policy: map1
Sequence number: 10
Mode: ISAKMP
-----------------------------
Tunnel id: 0
Encapsulation mode: tunnel
Perfect Forward Secrecy:
Inside VPN:
Extended Sequence Numbers enable: N
Traffic Flow Confidentiality enable: N
Path MTU: 1456
Tunnel:
local address: 1.1.1.1
remote address: 2.2.2.2
Flow:
sour addr: 10.1.1.0/255.255.255.0 port: 0 protocol: ip
dest addr: 10.1.2.0/255.255.255.0 port: 0 protocol: ip
[Inbound ESP SAs]
SPI: 3264152513 (0xc28f03c1)
Connection ID: 141733920771
Transform set: ESP-ENCRYPT-DES-CBC ESP-AUTH-SHA1
SA duration (kilobytes/sec): 1843200/3600
SA remaining duration (kilobytes/sec): 1843200/3484
Max received sequence-number:
Anti-replay check enable: Y
Anti-replay window size: 64
UDP encapsulation used for NAT traversal: N
Status: Active
[Outbound ESP SAs]
SPI: 738451674 (0x2c03e0da)
Connection ID: 141733920770
Transform set: ESP-ENCRYPT-DES-CBC ESP-AUTH-SHA1
SA duration (kilobytes/sec): 1843200/3600
SA remaining duration (kilobytes/sec): 1843200/3484
Max sent sequence-number:
UDP encapsulation used for NAT traversal: N
Status: Active
Device B上也會產生相應的IKEv2 SA和IPsec SA,並自動獲取CA證書,自動申請本地證書,查看方式與Device A同,此處略。
Device A在NAT安全網關內網側。要求在Device A和Device B之間建立一個IPsec隧道,對Host A所在的子網(10.1.1.2/24)與Host B所在的子網(10.1.2.2/24)之間的數據流進行安全保護。具體需要求如下:
· 協商雙方使用缺省的IKEv2安全提議和IKEv2安全策略。
· 第一階段協商的認證方法為預共享密鑰認證。
圖1-4 IKEv2 NAT穿越典型組網圖
(1) 配置Device A
# 配置各接口的IP地址,具體略。
# 配置ACL 3101,定義要保護由子網10.1.1.0/24去往子網10.1.2.0/24的數據流。
<DeviceA> system-view
[DeviceA] acl advanced 3101
[DeviceA-acl-ipv4-adv-3101] rule 0 permit ip source 10.1.1.0 0.0.0.255 destination 10.1.2.0 0.0.0.255
[DeviceA-acl-ipv4-adv-3101] quit
# 創建IPsec安全提議transform1。
[DeviceA] ipsec transform-set transform1
# 配置采用的安全協議為ESP。
[DeviceA-ipsec-transform-set-transform1] protocol esp
# 配置ESP協議采用的加密算法為3DES,認證算法為HMAC-MD5。
[DeviceA-ipsec-transform-set-transform1] esp encryption-algorithm 3des-cbc
[DeviceA-ipsec-transform-set-transform1] esp authentication-algorithm md5
[DeviceA-ipsec-transform-set-transform1] quit
# 創建IKEv2 keychain,名稱為keychain1。
[DeviceA] ikev2 keychain keychain1
# 創建IKEV2對端,名稱為peer1。
[DeviceA-ikev2-keychain-keychain1] peer peer1
# 指定對端peer1的主機地址為2.2.2.2/16。
[DeviceA-ikev2-keychain-keychain1-peer-peer1] address 2.2.2.2 16
# 指定對端 peer1 的身份信息。
[DeviceA-ikev2-keychain-keychain1-peer-peer1] identity address 2.2.2.2
# 配置對端peer1使用的預共享密鑰為明文123。
[DeviceA-ikev2-keychain-keychain1-peer-peer1] pre-shared-key plaintext 123
[DeviceA-ikev2-keychain-keychain1-peer-peer1] quit
[DeviceA-ikev2-keychain-keychain1] quit
# 創建IKEv2 profile,名稱為profile1。
[DeviceA] ikev2 profile profile1
# 指定引用的IKEv2 keychain為keychain1。
[DeviceA-ikev2-profile-profile1] keychain keychain1
# 配置本端身份為FQDN名稱www.devicea.com。
[DeviceA-ikev2-profile-profile1] identity local fqdn www.devicea.com
# 配置匹配對端身份的規則為IP地址2.2.2.2/16。
[DeviceA-ikev2-profile-profile1] match remote identity address 2.2.2.2 255.255.0.0
# 指定本端的身份認證方式為預共享密鑰。
[DeviceA-ikev2-profile-profile1] authentication-method local pre-share
# 指定對端的身份認證方式為預共享密鑰。
[DeviceA-ikev2-profile-profile1] authentication-method remote pre-share
[DeviceA-ikev2-profile-profile1] quit
# 創建一條IKEv2協商方式的IPsec安全策略,名稱為policy1,順序號為1。
[DeviceA] ipsec policy policy1 1 isakmp
# 配置IPsec隧道的對端IP地址為2.2.2.2。
[DeviceA-ipsec-policy-isakmp-policy1-1] remote-address 2.2.2.2
# 指定引用的安全提議為transform1。
[DeviceA-ipsec-policy-isakmp-policy1-1] transform-set transform1
# 指定引用ACL 3101。
[DeviceA-ipsec-policy-isakmp-policy1-1] security acl 3101
# 指定引用的IKEv2 profile為profile1。
[DeviceA-ipsec-policy-isakmp-policy1-1] ikev2-profile profile1
[DeviceA-ipsec-policy-isakmp-policy1-1] quit
# 在接口GigabitEthernet0/0/1上應用IPsec安全策略policy1。
[DeviceA] interface gigabitethernet 0/0/1
[DeviceA-GigabitEthernet0/0/1] ipsec apply policy policy1
[DeviceA-GigabitEthernet0/0/1] quit
# 配置到Host B所在子網的靜態路由。
[DeviceA] ip route-static 10.1.2.0 255.255.255.0 1.1.1.2
(2) 配置Device B
# 配置各接口的IP地址,具體略。
# 配置ACL 3101,定義要保護由子網10.1.2.0/24去往子網10.1.1.0/24的數據流。
<DeviceB> system-view
[DeviceB] acl advanced 3101
[DeviceB-acl-ipv4-adv-3101] rule 0 permit ip source 10.1.2.0 0.0.0.255 destination 10.1.1.0 0.0.0.255
[DeviceB-acl-ipv4-adv-3101] quit
# 創建IPsec安全提議transform1。
[DeviceB] ipsec transform-set transform1
# 配置采用的安全協議為ESP。
[DeviceB-ipsec-transform-set-transform1] protocol esp
# 配置ESP協議采用的加密算法為3DES,認證算法為HMAC-MD5。
[DeviceB-ipsec-transform-set-transform1] esp encryption-algorithm 3des-cbc
[DeviceB-ipsec-transform-set-transform1] esp authentication-algorithm md5
[DeviceB-ipsec-transform-set-transform1] quit
# 創建IKEv2 keychain,名稱為keychain1。
[DeviceB]ikev2 keychain keychain1
# 創建IKEV2對端,名稱為peer1。
[DeviceB-ikev2-keychain-keychain1] peer peer1
# 指定對端 peer1 的主機地址為3.3.3.1/16。
[DeviceB-ikev2-keychain-keychain1-peer-peer1] address 3.3.3.1 16
# 指定對端 peer1的身份信息。
[DeviceB-ikev2-keychain-keychain1-peer-peer1] identity address 3.3.3.1
# 配置對端peer1使用的預共享密鑰為明文123。
[DeviceB-ikev2-keychain-keychain1-peer-peer1] pre-shared-key plaintext 123
[DeviceB-ikev2-keychain-keychain1-peer-peer1] quit
[DeviceB-ikev2-keychain-keychain1] quit
# 創建IKEv2 profile,名稱為profile1。
[DeviceB] ikev2 profile profile1
# 指定引用的IKEv2 keychain為keychain1。
[DeviceB-ikev2-profile-profile1] keychain keychain1
# 配置匹配對端身份的規則為FQDN名稱www.devicea.com。
[DeviceB-ikev2-profile-profile1] match remote identity fqdn www.devicea.com
# 指定本端的身份認證方式為預共享密鑰。
[DeviceB-ikev2-profile-profile1] authentication-method local pre-share
# 指定對端的身份認證方式為預共享密鑰。
[DeviceB-ikev2-profile-profile1] authentication-method remote pre-share
[DeviceB-ikev2-profile-profile1] quit
# 創建一個IKEv2協商方式的IPsec安全策略模板,名稱為template1,順序號為1。
[DeviceB] ipsec policy-template template1 1
# 配置IPsec隧道的對端IP地址為3.3.3.1。
[DeviceB-ipsec-policy-template-template1-1] remote-address 3.3.3.1
# 指定引用ACL 3101。
[DeviceB-ipsec-policy-template-template1-1] security acl 3101
# 指定引用的安全提議為transform1。
[DeviceB-ipsec-policy-template-template1-1] transform-set transform1
# 指定引用的IKEv2 profile為profile1。
[DeviceB-ipsec-policy-template-template1-1] ikev2-profile profile1
[DeviceB-ipsec-policy-template-template1-1] quit
# 引用IPsec安全策略模板創建一條IKEv2協商方式的IPsec安全策略,名稱為policy1,順序號1。
[DeviceB] ipsec policy policy1 1 isakmp template template1
# 在接口GigabitEthernet0/0/1上應用安全策略policy1。
[DeviceB] interface gigabitethernet 0/0/1
[DeviceB-GigabitEthernet0/0/1] ipsec apply policy policy1
[DeviceB-GigabitEthernet0/0/1] quit
# 配置到Host A所在子網的靜態路由。2.2.2.1為本例中的直連下一跳地址,實際使用中請以具體組網情況為準。
[DeviceB] ip route-static 10.1.1.0 255.255.255.0 2.2.2.1
以上配置完成後,子網10.1.1.0/24若向子網10.1.2.0/24發送報文,將觸發IKEv2協商。
# 可通過如下顯示信息查看到Device A上IKEv2協商成功後生成的IKEv2 SA。
[DeviceA] display ikev2 sa
Tunnel ID Local Remote Status
---------------------------------------------------------------------------
1 1.1.1.1/4500 2.2.2.2/4500 EST
Status:
IN-NEGO: Negotiating, EST: Established, DEL:Deleting
[DeviceA] display ikev2 sa verbose
Tunnel ID: 45
Local IP/Port: 1.1.1.1/4500
Remote IP/Port: 2.2.2.2/4500
Outside VRF: -
Inside VRF: -
Local SPI: 372228d699a33c63
Remote SPI: 75c537621b4a7190
Local ID type: ID_FQDN
Local ID: www.devicea.com
Remote ID type: ID_IPV4_ADDR
Remote ID: 2.2.2.2
Auth sign method: Pre-shared key
Auth verify method: Pre-shared key
Integrity algorithm: SHA1
PRF algorithm: SHA1
Encryption algorithm: AES-CBC-128
Life duration: 86400 secs
Remaining key duration: 86177 secs
Diffie-Hellman group: MODP1536/Group5
NAT traversal: Detected
DPD: Interval 0 secs, retry interval 0 secs
Transmitting entity: Initiator
Local window: 1
Remote window: 1
Local request message ID: 2
Remote request message ID: 0
Local next message ID: 2
Remote next message ID: 0
# 可通過如下顯示信息查看到IKEv2協商生成的IPsec SA。
[DeviceA] display ipsec sa
-------------------------------
Interface: GigabitEthernet0/0/1
-------------------------------
-----------------------------
IPsec policy: policy1
Sequence number: 1
Mode: ISAKMP
-----------------------------
Tunnel id: 0
Encapsulation mode: tunnel
Perfect Forward Secrecy:
Inside VPN:
Extended Sequence Numbers enable: N
Traffic Flow Confidentiality enable: N
Path MTU: 1435
Tunnel:
local address: 1.1.1.1
remote address: 2.2.2.2
Flow:
sour addr: 10.1.1.0/255.255.255.0 port: 0 protocol: ip
dest addr: 10.1.2.0/255.255.255.0 port: 0 protocol: ip
[Inbound ESP SAs]
SPI: 830667426 (0x3182faa2)
Connection ID: 605590388736
Transform set: ESP-ENCRYPT-3DES-CBC ESP-AUTH-MD5
SA duration (kilobytes/sec): 1843200/3600
SA remaining duration (kilobytes/sec): 1843200/2313
Max received sequence-number:
Anti-replay check enable: Y
Anti-replay window size: 64
UDP encapsulation used for NAT traversal: Y
Status: Active
[Outbound ESP SAs]
SPI: 3516214669 (0xd1952d8d)
Connection ID: 227633266689
Transform set: ESP-ENCRYPT-3DES-CBC ESP-AUTH-MD5
SA duration (kilobytes/sec): 1843200/3600
SA remaining duration (kilobytes/sec): 1843200/2313
Max sent sequence-number:
UDP encapsulation used for NAT traversal: Y
Status: Active
通過如下命令查看當前的IKEv2 SA信息,發現IKEv2 SA的狀態(Status字段)為IN-NEGO。
<Sysname> display ikev2 sa
Tunnel ID Local Remote Status
---------------------------------------------------------------------------
5 123.234.234.124/500 123.234.234.123/500 IN-NEGO
Status:
IN-NEGO: Negotiating, EST: Established, DEL:Deleting
IKEv2提議配置錯誤。
(1) 排查IKEv2相關配置。具體包括:檢查兩端的IKEv2提議是否匹配,即IKEv2提議中的認證方法、認證算法、加密算法、PRF算法是否匹配。
(2) 修改IKEv2提議的配置,使本端IKEv2提議的配置和對端匹配。
通過display ikev2 sa命令查看當前的IKEv2 SA信息,發現IKEv2 SA協商成功,其狀態(Status字段)為EST。但通過display ipsec sa命令查看當前的IPsec SA時,發現沒有協商出相應的IPsec SA。
IPsec安全策略參數配置錯誤。
(1) 排查IPsec相關配置。具體包括:檢查雙方接口上應用的IPsec安全策略的參數是否匹配,即引用的IPsec安全提議的協議、加密算法和認證算法是否匹配。
(2) 修改IPsec策略配置,使本端IPsec安全策略的配置和對端匹配。
雙方的ACL配置正確,也有相匹配的IKEv2安全提議,但安全隧道無法建立或者存在安全隧道卻無法通信。
這種情況一般是由於網絡狀態不穩定,安全隧道建立好以後,有一方的設備重啟造成了兩端的IKEv2 SA或者IPsec SA不對稱。
使用display ikev2 sa命令檢查雙方是否都已建立IKEv2 SA。如果有一端存在的IKEv2 SA在另一端上不存在,請先使用reset ikev2 sa命令清除雙方不對稱存在的IKEv2 SA,並重新發起協商;如果兩端存在對稱的IKEv2 SA,則使用display ipsec sa命令查看接口上的安全策略是否已建立了對稱的IPsec SA。如果一端存在的IPsec SA在另一端上不存在,請使用reset ipsec sa命令清除雙方不對稱存在的IPsec SA,並重新發起協商。
不同款型規格的資料略有差異, 詳細信息請向具體銷售和400谘詢。H3C保留在沒有任何通知或提示的情況下對資料內容進行修改的權利!