總部/分支之間建立點到多點IPSec ×××
分支機構和總部之間通信,如果某些分支機構的公網地址固定,另外一些分支機構的公網地址不固定,可採用此方式建立IPSec隧道。
組網需求
如圖1所示,組網情況如下:
某企業由總部和若干個分支機構組成。總部和分支機構1~分支機構n的IP地址都爲固定地址,其他分支機構的IP地址爲動態地址。
總部和各分支機構的私網IP都屬於10.0.0.0/8網段。
該企業網絡需實現以下需求:
每個分支機構都要訪問總部的服務器設備,且傳輸的數據需要加密。
各分支機構之間不能直接進行任何通信,只能經過總部進行通信。
網絡規劃
將圖1的網絡結構抽象爲如圖2所示組網,其中分支機構1的公網IP地址爲動態地址,分支機構2的公網IP地址爲固定地址。USG_B和USG_C分別對應IP地址不固定和IP地址固定的分支機構的×××網關。網絡規劃如下:
總部和分支機構1、總部和分支機構2之間通信數據需要加密,需分別配置IPSec ×××。
對於總部和分支機構1,由於只有分支機構1主動訪問總部服務器,故在總部採用策略模板方式建立IPSec ×××即可。
對於總部和分支機構2,由於要進行互訪,故只能建立點到點方式的IPSec。
USG_A作爲總部的網關設備,連接公網的接口只有一個,故要將上述兩個IPSec ×××的IPSec策略都應用到此接口上。由於每個接口上只能應用一個IPSec策略,故需採用子策略方式建立IPSec隧道。
由於分支機構1和分支機構2之間不能直接進行任何通信,USG_B和USG_C之間不建立任何IPSEC隧道。由於分支機構1的公網地址不固定,雙方進行通信的方式如下。
由USG_B向總部發起連接並建立IPSec隧道。
在分支機構1、分支機構2與總部能夠通過IPSec隧道安全通信之後,分支機構1和分支機構2通過USG_A進行安全通信。
項目 | USG_A | USG_B | USG_C | |
---|---|---|---|---|
接口 | (1) GigabitEthernet 6/0/0 IP地址:10.10.1.1/24 (2) GigabitEthernet 0/0/2 IP地址:200.1.1.1/24 | (3) GigabitEthernet 0/0/2 IP地址:位於30.1.2.1/24~30.1.2.254/24網段。 (5) GigabitEthernet 6/0/0 IP地址:10.20.1.1/24 | (4) GigabitEthernet 0/0/2 IP地址:30.1.1.1/24 (6) GigabitEthernet 6/0/0 IP地址:10.20.2.1/24 | |
IPSec策略建立方式 | 子策略1:策略模板 子策略2:非模板 | 非模板 | 非模板 | |
IPSec安全提議 | 封裝模式 | 隧道模式 | 隧道模式 | 隧道模式 |
安全協議 | ESP | ESP | ESP | |
ESP協議驗證算法 | SHA1 | SHA1 | SHA1 | |
ESP協議加密算法 | AES | AES | AES | |
IKE對等體 | 協商模式 | 子策略1:主模式 子策略2:主模式 | 主模式 | 主模式 |
預共享密鑰 | 子策略1:Key123 子策略2:Key456 | Key123 | Key456 | |
本地身份類型 | 子策略1:fqdn 子策略2:IP地址 | fqdn | IP地址 | |
版本 | v1和v2 | v1和v2 | v1和v2 |
操作步驟
配置USG_A的IPSec功能。
說明:
USG_A的基礎配置過程略。基礎配置包括配置相關接口的IP地址,將接口加入相應的安全區域,配置域間包過濾,配置路由等。
配置訪問控制列表,定義要保護的數據流。
說明:
總部網關USG_A配置若干個ACL,其中爲所有的動態分支配置一個ACL,每一個靜態分支創建一個ACL。ACL規則的源地址爲總部和分支的所有網段地址範圍,目的地址爲某分支網段。
# 配置源IP地址爲10.0.0.0/8、目的IP地址爲10.20.1.0/24的規則。
[USG_A] acl 3000 [USG_A-acl-adv-3000] rule permit ip source 10.0.0.0 0.255.255.255 destination 10.20.1.0 0.0.0.255 [USG_A-acl-adv-3000] quit
# 配置源IP地址爲10.0.0.0/8、目的IP地址爲10.20.2.0/24的規則。
[USG_A] acl 3001 [USG_A-acl-adv-3001] rule permit ip source 10.0.0.0 0.255.255.255 destination 10.20.2.0 0.0.0.255 [USG_A-acl-adv-3001] quit
配置USG_A到達USG_B和USG_C的靜態路由,假設下一跳地址爲200.1.1.2/24。
[USG_A] ip route-static 10.20.1.0 255.255.255.0 200.1.1.2
[USG_A] ip route-static 10.20.2.0 255.255.255.0 200.1.1.2
創建IPSec安全提議。
[USG_A] ipsec proposal tran1 [USG_A-ipsec-proposal-tran1] encapsulation-mode tunnel [USG_A-ipsec-proposal-tran1] transform esp [USG_A-ipsec-proposal-tran1] esp authentication-algorithm sha1 [USG_A-ipsec-proposal-tran1] esp encryption-algorithm aes [USG_A-ipsec-proposal-tran1] quit
[USG_A] ipsec proposal tran2 [USG_A-ipsec-proposal-tran2] encapsulation-mode tunnel [USG_A-ipsec-proposal-tran2] transform esp [USG_A-ipsec-proposal-tran2] esp authentication-algorithm sha1 [USG_A-ipsec-proposal-tran2] esp encryption-algorithm aes [USG_A-ipsec-proposal-tran2] quit
創建IKE安全提議。
[USG_A] ike proposal 10 [USG_A-ike-proposal-10] authentication-method pre-share [USG_A-ike-proposal-10] authentication-algorithm sha1 [USG_A-ike-proposal-10] quit
[USG_A] ike proposal 11 [USG_A-ike-proposal-11] authentication-method pre-share [USG_A-ike-proposal-11] authentication-algorithm sha1 [USG_A-ike-proposal-11] quit
配置IKE peer。
[USG_A] ike local-name USG_A[USG_A] ike peer a1 [USG_A-ike-peer-a1] ike-proposal 10 [USG_A-ike-peer-a1] local-id-type fqdn [USG_A-ike-peer-a1] remote-id USG_B[USG_A-ike-peer-a1] pre-shared-key Key123[USG_A-ike-peer-a1] quit
[USG_A] ike peer a2 [USG_A-ike-peer-a2] ike-proposal 11 [USG_A-ike-peer-a2] remote-address 30.1.1.1[USG_A-ike-peer-a2] pre-shared-key Key456 [USG_A-ike-peer-a2] quit
創建安全策略。
[USG_A] ipsec policy-template map_temp 10 [USG_A-ipsec-policy-template-map_temp-10] security acl 3000 [USG_A-ipsec-policy-template-map_temp-10] proposal tran1 [USG_A-ipsec-policy-template-map_temp-10] ike-peer a1 [USG_A-ipsec-policy-template-map_temp-10] quit[USG_A] ipsec policy map1 100 isakmp template map_temp
[USG_A] ipsec policy map1 11 isakmp [USG_A-ipsec-policy-isakmp-map1-11] security acl 3001 [USG_A-ipsec-policy-isakmp-map1-11] proposal tran2 [USG_A-ipsec-policy-isakmp-map1-11] ike-peer a2 [USG_A-ipsec-policy-isakmp-map1-11] quit
說明:
同一個IPSec安全策略組中模板方式安全策略的序號必須大於直接創建的安全策略的序號。即同一個IPSec安全策略組中模板方式安全策略的優先級必須最低,否則可能導致協商失敗。
在接口上引用安全策略。
[USG_A] interface GigabitEthernet 0/0/2 [USG_A-GigabitEthernet0/0/2] ipsec policy map1
配置完成後,可執行display ipsec policy命令查看IPSec的配置情況。出現以下顯示信息說明配置成功。
=========================================== IPsec Policy Group: "map1" Using interface: {GigabitEthernet0/0/2} =========================================== ----------------------------- IPsec policy name: "map1" sequence number: 11 mode: isakmp state: active ----------------------------- security data flow : 3001 ike-peer name: a2 perfect forward secrecy: None proposal name: tran2 IPsec sa local duration(time based): 22222 seconds sa soft-duration time-based buffer: 22200 seconds sa soft-duration traffic-based buffer: 22200 kilobytes IPsec sa local duration(traffic based): 22222 kilobytes IPSec sa anti-replay: use global IPSec sa anti-replay window-size: use global ----------------------------- IPsec policy name: "map1" sequence number: 100 mode: template state: active ----------------------------- policy template name: map_temp
配置USG_B的IPSec功能。
配置訪問控制列表,定義要保護的數據流。
# 配置源IP地址爲10.20.1.0/24、目的地址爲10.0.0.0/8的規則。
[USG_B] acl 3000 [USG_B-acl-adv-3000] rule permit ip source 10.20.1.0 0.0.0.255 destination 10.0.0.0 0.255.255.255 [USG_B-acl-adv-3000] quit
配置USG_B到達USG_A和USG_C的靜態路由。
說明:
假設USG_B目前的公網IP地址爲30.1.2.1,到達USG_A和USG_C的下一跳地址爲30.1.2.2。
[USG_B] ip route-static 10.10.1.0 255.255.255.0 30.1.2.2[USG_B] ip route-static 10.20.2.0 255.255.255.0 30.1.2.2
創建IPSec安全提議。
[USG_B] ipsec proposal tran1 [USG_B-ipsec-proposal-tran1] encapsulation-mode tunnel [USG_B-ipsec-proposal-tran1] transform esp [USG_B-ipsec-proposal-tran1] esp authentication-algorithm sha1 [USG_B-ipsec-proposal-tran1] esp encryption-algorithm aes[USG_B-ipsec-proposal-tran1] quit
創建IKE安全提議。
[USG_B] ike proposal 10 [USG_B-ike-proposal-10] authentication-method pre-share [USG_B-ike-proposal-10] authentication-algorithm sha1 [USG_B-ike-proposal-10] quit
配置IKE peer。
[USG_B] ike local-name USG_B[USG_B] ike peer b [USG_B-ike-peer-b] ike-proposal 10 [USG_B-ike-peer-b] local-id-type fqdn [USG_B-ike-peer-b] remote-id USG_A[USG_B-ike-peer-b] pre-shared-key Key123 [USG_B-ike-peer-b] remote-address 200.1.1.1[USG_B-ike-peer-b] quit
創建安全策略。
[USG_B] ipsec policy map1 10 isakmp [USG_B-ipsec-policy-isakmp-map1-10] security acl 3000 [USG_B-ipsec-policy-isakmp-map1-10] proposal tran1 [USG_B-ipsec-policy-isakmp-map1-10] ike-peer b [USG_B-ipsec-policy-isakmp-map1-10] quit
在物理接口上引用安全策略。
[USG_B] interface GigabitEthernet 0/0/2 [USG_B-GigabitEthernet0/0/2] ipsec policy map1
配置完成後,可執行display ipsec policy命令查看IPSec的配置情況。出現以下顯示信息說明配置成功。
[USG_B] display ipsec policy name map1 =========================================== IPsec Policy Group: "map1" Using interface: {GigabitEthernet0/0/2} =========================================== ----------------------------- IPsec policy name: "map1" sequence number: 10 mode: isakmp state: active ----------------------------- security data flow : 3000 ike-peer name: b perfect forward secrecy: None proposal name: tran1 IPsec sa local duration(time based): 22222 seconds sa soft-duration time-based buffer: 22200 seconds sa soft-duration traffic-based buffer: 22200 kilobytes IPsec sa local duration(traffic based): 22222 kilobytes IPSec sa anti-replay: use global IPSec sa anti-replay window-size: use global
配置USG_C的IPSec功能。
配置訪問控制列表,定義要保護的數據流。
# 配置源IP地址爲10.20.2.0/24、目的IP地址爲10.0.0.0/8的規則。
[USG_C] acl 3000 [USG_C-acl-adv-3000] rule permit ip source 10.20.2.0 0.0.0.255 destination 10.0.0.0 0.255.255.255 [USG_C-acl-adv-3000] quit
配置USG_C到達USG_A和USG_B的靜態路由,假設下一跳地址爲30.1.1.2。
[USG_C] ip route-static 10.10.1.0 255.255.255.0 30.1.1.2[USG_C] ip route-static 10.20.1.0 255.255.255.0 30.1.1.2
創建IPSec安全提議。
[USG_C] ipsec proposal tran1 [USG_C-ipsec-proposal-tran1] encapsulation-mode tunnel [USG_C-ipsec-proposal-tran1] transform esp [USG_C-ipsec-proposal-tran1] esp authentication-algorithm sha1 [USG_C-ipsec-proposal-tran1] esp encryption-algorithm aes [USG_C-ipsec-proposal-tran1] quit
創建IKE安全提議。
[USG_C] ike proposal 10 [USG_C-ike-proposal-10] authentication-method pre-share [USG_C-ike-proposal-10] authentication-algorithm sha1 [USG_C-ike-proposal-10] quit
配置IKE peer。
[USG_C] ike peer c [USG_C-ike-peer-c] ike-proposal 10 [USG_C-ike-peer-c] pre-shared-key Key456 [USG_C-ike-peer-c] remote-address 200.1.1.1[USG_C-ike-peer-c] quit
創建安全策略。
[USG_C] ipsec policy map1 10 isakmp [USG_C-ipsec-policy-isakmp-map1-10] security acl 3000 [USG_C-ipsec-policy-isakmp-map1-10] proposal tran1 [USG_C-ipsec-policy-isakmp-map1-10] ike-peer c [USG_C-ipsec-policy-isakmp-map1-10] quit
在物理接口上引用安全策略。
[USG_C] interface GigabitEthernet 0/0/2 [USG_C-GigabitEthernet0/0/2] ipsec policy map1
配置完成後,可執行display ipsec policy命令查看IPSec的配置情況。出現以下顯示信息說明配置成功。
[USG_C] display ipsec policy name map1 =========================================== IPsec Policy Group: "map1" Using interface: {GigabitEthernet0/0/2} =========================================== ----------------------------- IPsec policy name: "map1" sequence number: 10 mode: isakmp state: active ----------------------------- security data flow : 3000 ike-peer name: c perfect forward secrecy: None proposal name: tran1 IPsec sa local duration(time based): 22222 seconds sa soft-duration time-based buffer: 22200 seconds sa soft-duration traffic-based buffer: 22200 kilobytes IPsec sa local duration(traffic based): 22222 kilobytes IPSec sa anti-replay: use global IPSec sa anti-replay window-size: use global
結果驗證
分支機構2和總部之間可以互相訪問,雙方都可以觸發IPSEC SA的建立。如用總部來ping分支機構2內網設備,可以ping通,且分別在USG_A和USG_C上執行display ike sa、display ipsec sa會顯示安全聯盟的建立情況。以USG_A爲例,出現以下顯示說明IKE安全聯盟、IPSec安全聯盟建立成功。
<USG_A>display ike sa current ike sa number: 2 --------------------------------------------------------------------- conn-id peer flag phase *** --------------------------------------------------------------------- 40001 30.1.1.1 RD|ST v2:2 public 1 30.1.1.1 RD|ST v2:1 public flag meaning RD--READY ST--STAYALIVE RL--REPLACED FD--FADING TO--TIMEOUT TD--DELETING NEG--NEGOTIATING D--DPD
<USG_A>display ipsec sa brief current ipsec sa number: 2 current ipsec tunnel number: 1 -------------------------------------------------------------- Src Address Dst Address SPI Protocol Algorithm ------------------------------------------------------------------- 30.1.1.1 200.1.1.1 49286024 ESP E:AES;A:HMAC-SHA1-96; 200.1.1.1 30.1.1.1 239495571 ESP E:AES;A:HMAC-SHA1-96;
分支機構1能夠主動訪問總部。配置成功後,在分支機構1執行ping操作可以ping通總部。分別在USG_A和USG_B上執行display ike sa、display ipsec sa會顯示安全聯盟的建立情況。以USG_A爲例,出現以下顯示說明IKE安全聯盟、IPSec安全聯盟建立成功。
<USG_A>display ike sa current ike sa number: 4 --------------------------------------------------------------------- conn-id peer flag phase *** --------------------------------------------------------------------- 40001 30.1.1.1 RD|ST v2:2 public 1 30.1.1.1 RD|ST v2:1 public 40003 30.1.2.1 RD v2:2 public 40002 30.1.2.1 RD v2:1 public flag meaning RD--READY ST--STAYALIVE RL--REPLACED FD--FADING TO--TIMEOUT TD--DELETING NEG--NEGOTIATING D--DPD
<USG_A>display ipsec sa brief current ipsec sa number: 4 current ipsec tunnel number: 2 -------------------------------------------------------------- Src Address Dst Address SPI Protocol Algorithm ------------------------------------------------------------------- 30.1.1.1 200.1.1.1 142427840 ESP E:AES;A:HMAC-SHA1-96; 200.1.1.1 30.1.1.1 52885424 ESP E:AES;A:HMAC-SHA1-96; 30.1.2.1 200.1.1.1 49286024 ESP E:AES;A:HMAC-SHA1-96; 200.1.1.1 30.1.2.1 239495571 ESP E:AES;A:HMAC-SHA1-96;
執行命令display ipsec statistics可以查看被加密的數據包的變化,即它們之間的數據傳輸將被加密。以USG_A爲例。
<USG_A>display ipsec statistics the security packet statistics: input/output security packets: 9/9 input/output security bytes: 756/756 input/output dropped security packets: 0/0 the encrypt packet statistics send sae:9, recv sae:9, send err:0 local cpu:9, other cpu:0, recv other cpu:0 intact packet:2, first slice:0, after slice:0 the decrypt packet statistics send sae:9, recv sae:9, send err:0 local cpu:9, other cpu:0, recv other cpu:0 reass first slice:0, after slice:0, len err:0 dropped security packet detail: no enough memory: 0, too long: 0 can't find SA: 0, wrong SA: 0 authentication: 0, replay: 0 front recheck: 0, after recheck: 0 exceed byte limit: 0, exceed packet limit: 0 change cpu enc: 0, dec change cpu: 0 change datachan: 0, fib search: 0 rcv enc(dec) form sae said err: 0, 0 port number error: 0 send port: 0, output l3: 0, l2tp input: 0 negotiate about packet statistics: IP packet ok:0, err:0, drop:0 IP rcv other cpu to ike:0, drop:0 IKE packet inbound ok:2, err:0 IKE packet outbound ok:2, err:0 SoftExpr:0, HardExpr:0, DPDOper:0, SwapSa:0 ModpCnt: 2, SaeSucc: 2, SoftwareSucc: 0
當兩條IPSec隧道都建立成功後,分支機構1與分支機構2能夠互相訪問,且兩者之間的訪問是經過了總部設備來實現的。
配置腳本
USG_A的配置腳本
# ike local-name USG_A # acl number 3000 rule 5 permit ip source 10.0.0.0 0.255.255.255 destination 10.20.1.0 0.0.0.255 # acl number 3001 rule 5 permit ip source 10.0.0.0 0.255.255.255 destination 10.20.2.0 0.0.0.255 # ip route-static 10.20.1.0 255.255.255.0 200.1.1.2 ip route-static 10.20.2.0 255.255.255.0 200.1.1.2 # ike proposal 10 encryption-algorithm aes-cbc dh group2 # ike proposal 11 encryption-algorithm aes-cbc dh group2 # ike peer a1 pre-shared-key %$%$+x!93lf{r+w#M27fa9Z8jmd[%$%$ ike-proposal 10 local-id-type fqdn remote-id USG_B # ike peer a2 pre-shared-key %$%${vC:RV[[email protected]=4+%$%$ ike-proposal 11 remote-address 30.1.1.1 # ipsec proposal tran1 esp authentication-algorithm sha1 esp encryption-algorithm aes # ipsec proposal tran2 esp authentication-algorithm sha1 esp encryption-algorithm aes # ipsec policy-template map_temp 10 security acl 3000 ike-peer a1 proposal tran1 # ipsec policy map1 11 isakmp security acl 3001 ike-peer a2 proposal tran2 # ipsec policy map1 100 isakmp template map_temp # interface GigabitEthernet6/0/0 ip address 10.10.1.1 255.255.255.0 # interface GigabitEthernet0/0/2 ip address 200.1.1.1 255.255.255.0 ipsec policy map1
USG_B的配置腳本
# ike local-name USG_B # acl number 3000 rule 5 permit ip source 10.20.1.0 0.0.0.255 destination 10.0.0.0 0.255.255.255 # ip route-static 10.10.1.0 255.255.255.0 30.1.2.2 ip route-static 10.20.2.0 255.255.255.0 30.1.2.2 # ike proposal 10 encryption-algorithm aes-cbc dh group2 # ike peer b pre-shared-key %$%$+x!93lf{r+w#M27fa9Z8jmd[%$%$ ike-proposal 10 local-id-type fqdn remote-address 200.1.1.1 remote-id USG_A # ipsec proposal tran1 esp authentication-algorithm sha1 esp encryption-algorithm aes # ipsec policy map1 10 isakmp security acl 3000 ike-peer b proposal tran1 # interface GigabitEthernet6/0/0 ip address 10.20.1.1 255.255.255.0 # interface GigabitEthernet0/0/2 ip address 30.1.2.1 255.255.255.0 ipsec policy map1
USG_C配置腳本
# acl number 3000 rule 5 permit ip source 10.20.2.0 0.0.0.255 destination 10.0.0.0 0.255.255.255 # ip route-static 10.10.1.0 255.255.255.0 30.1.1.2 ip route-static 10.20.1.0 255.255.255.0 30.1.1.2 # ike proposal 10 encryption-algorithm aes-cbc dh group2 # ike peer c pre-shared-key %$%${vC:RV[[email protected]=4+%$%$ ike-proposal 10 remote-address 200.1.1.1 # ipsec proposal tran1 esp authentication-algorithm sha1 esp encryption-algorithm aes # ipsec policy map1 10 isakmp security acl 3000 ike-peer c proposal tran1 # interface GigabitEthernet6/0/0 ip address 10.20.2.1 255.255.255.0 # interface GigabitEthernet6/0/0 ip address 30.1.1.1 255.255.255.0 ipsec policy map1
父主題: 專網內部通過×××互通
華爲專有和保密信息
版權所有 華爲技術有限公司