全部產品
Search
文件中心

:華三防火牆配置樣本

更新時間:Aug 16, 2024

使用IPsec-VPN實現本機資料中心IDC和阿里雲VPC之間的網路互連時,在阿里雲側完成VPN網關的配置後,您還需在本機資料中心的網關裝置中添加VPN配置。本文以華三(H3C)防火牆裝置為例,分別介紹在雙隧道模式和單隧道模式下,如何在H3C裝置中添加VPN配置。

說明

建議您優先使用雙隧道模式。關於什麼是雙隧道,請參見【升級公告】IPsec-VPN串連升級為雙隧道模式

雙隧道模式

情境樣本

以上圖情境為例:

  1. 某公司在本地擁有一個資料中心,本機資料中心中要與阿里雲互連的網段為10.34.0.0/24。

  2. 該公司在阿里雲擁有一個Virtual Private Cloud,VPC網段為192.168.0.0/16,VPC中使用Elastic Compute Service部署了應用服務。

  3. 公司計劃在本機資料中心與雲上VPC之間建立雙隧道模式的IPsec-VPN串連,實現資源互訪。

地址規劃

根據H3C裝置的公網出口數量,本文提供2種情境樣本:

  • 單出口:H3C裝置只配置了1個公網出口,對應只有1個公網IP地址。

  • 雙出口:H3C裝置配置了2個公網出口,對應有2個公網IP地址。

您可以根據本地裝置的實際情況,查看對應的地址規劃。

單出口

地址規劃如下所示。

位置

配置項

樣本值

本地IDC

H3C裝置地址

GE2(公網出口):10.32.0.175

出口下一跳:10.32.0.173

映射公網IP:8.XX.XX.3

GE4(私網介面):10.34.0.20

私網網段

10.34.0.0/24

伺服器IP

10.34.0.21

阿里雲

VPN網關地址

主隧道:39.XX.XX.17

備隧道:39.XX.XX.10

VPC網段

192.168.0.0/16

交換器網段

可用性區域J:192.168.1.0/24

可用性區域K:192.168.2.0/24

ECS地址

192.168.1.11

雙出口

地址規劃如下所示。

位置

配置項

樣本值

本地IDC

H3C裝置地址

GE2(公網出口1):10.32.0.175

出口下一跳:10.32.0.173

映射公網IP:8.XX.XX.3

GE3(公網出口2):10.33.0.238

出口下一跳:10.33.0.236

映射公網IP:116.XX.XX.68

GE4(私網介面):10.34.0.20

私網網段

10.34.0.0/24

伺服器IP

10.34.0.21

阿里雲

VPN網關地址

主隧道:39.XX.XX.17

備隧道:39.XX.XX.10

VPC網段

192.168.0.0/16

交換器網段

可用性區域J:192.168.1.0/24

可用性區域K:192.168.2.0/24

ECS地址

192.168.1.11

BGP規劃

本文將分別描述IPsec-VPN串連使用靜態路由方式BGP動態路由方式下如何配置H3C防火牆。如果您不需要使用BGP動態路由方式,可以忽略本部分。以下為本文的BGP網段規劃。

資源

隧道

BGP隧道網段

BGP IP地址

BGP AS號(本端自治系統號)

阿里雲VPN網關

隧道1

169.254.10.0/30

說明

一個VPN網關執行個體下,每個隧道的網段需保持唯一。

169.254.10.1

65535

隧道2

169.254.20.0/30

169.254.20.1

H3C防火牆

隧道1

169.254.10.0/30

169.254.10.2

65500

隧道2

169.254.20.0/30

169.254.20.2

IPsec串連配置規劃

  • 雙隧道模式下,隧道1(主隧道)和隧道2(備隧道)使用相同的樣本值。

  • 對於每條隧道,阿里雲側和H3C防火牆側IPsec串連配置需保持相同。

配置項

樣本值

預先共用金鑰

ChangeMe****

IKE

版本

ikev2

協商模式

main

密碼編譯演算法

aes256

認證演算法

sha256

DH分組

group14

SA生存周期(秒)

86400

IPsec

密碼編譯演算法

aes256

認證演算法

sha256

DH分組

group14

SA生存周期(秒)

86400

前提條件

配置H3C裝置之前,請先在阿里雲側完成建立VPN網關執行個體、建立使用者網關、建立IPsec串連、配置VPN網關路由的任務。

針對單出口和雙出口情境,使用者網關的配置有如下區別:

  • 單出口:只需建立1個使用者網關。建立IPsec串連時,兩條隧道都選擇同一個使用者網關。

  • 雙出口:需要建立2個使用者網關。建立IPsec串連時,兩條隧道選擇各自對應的使用者網關。

操作步驟

說明

本文使用H3C的vFW1k E1185版本進行配置樣本。不同型號版本的防火牆配置可能存在差別,您可以根據實際使用的版本,參考相應的文檔或諮詢防火牆廠商進行操作配置。

本文給出4種情境配置樣本,您可以根據本地裝置的實際情況,查看對應的配置步驟。

單出口+靜態路由

單公網IP單出口情境下,您可以將H3C裝置的單個出口,綁定至兩個Tunnel介面,並為其配置不同的IPsec profile,以此與阿里雲的主備隧道進行串連。

步驟一:介面網路設定

分別為H3C裝置的公網介面和私網介面配置IP地址和安全域,並配置路由。

#公網介面
interface GigabitEthernet 2/0
 ip addr 10.32.0.175 24
 quit

#私網介面
interface GigabitEthernet 4/0
 ip addr 10.34.0.10 24
 quit

#介面加入安全域
security-zone name Untrust
 import interface GigabitEthernet 2/0
 quit
security-zone name Trust
 import interface GigabitEthernet 4/0
 quit

#配置對端阿里雲的公網地址路由,下一跳指向公網
ip route-static 39.XX.XX.17 32 10.32.0.173
ip route-static 39.XX.XX.10 32 10.32.0.173
#配置本端內網網段路由,下一跳指向私網
ip route-static 10.0.0.0 8 10.34.0.253
步驟二:隧道配置

建立兩個Tunnel介面,以對接雲端的主備隧道。

#配置tunnel口,應用IPSec安全架構到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 quit
interface tunnel 2 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 quit

#tunnel介面加入安全域
security-zone name Untrust
 import interface Tunnel 1
 import interface Tunnel 2
 quit
步驟三:IPsec提議和策略配置

進行IPsec和IKE配置,注意和阿里雲側保持一致。

#配置IPsec安全提議
ipsec transform-set to-ali-trans
 encapsulation-mode tunnel
 protocol esp
 esp authentication-algorithm sha256
 esp encryption-algorithm aes-cbc-256
 pfs dh-group14
 quit

#配置IKE安全提議和ike安全性原則
ikev2 proposal to-ali-prop
 dh group14
 encryption aes-cbc-256
 integrity sha256
 prf sha256
 quit
ikev2 policy to-ali-policy
 priority 1
 proposal to-ali-prop
 quit

#配置IKE keychain,兩個peer分別對應阿里雲上兩個隧道,address是阿里雲上公網ip地址
ikev2 keychain to_ali_key1
 peer to-ali-peer1
  address 39.XX.XX.17 32
  identity address 39.XX.XX.17
  pre-shared-key plaintext ChangeMe****
  quit
 quit
ikev2 keychain to_ali_key2
 peer to-ali-peer2
  address 39.XX.XX.10 32
  identity address 39.XX.XX.10
  pre-shared-key plaintext ChangeMe****
  quit
 quit

#配置IKE profile,兩個peer分別對應阿里雲上兩個隧道
ikev2 profile to-ali-profile1
 authentication-method local pre-share
 authentication-method remote pre-share
 keychain to_ali_key1
 identity local address 8.XX.XX.3
 match remote identity address 39.XX.XX.17 32
 sa duration 86400
 dpd interval 30 periodic
 quit
 
ikev2 profile to-ali-profile2
 authentication-method local pre-share
 authentication-method remote pre-share
 keychain to_ali_key2
 identity local address 8.XX.XX.3
 match remote identity address 39.XX.XX.10 32
 sa duration 86400
 dpd interval 30 periodic
 quit


#配置IPsec profile,引用上面建立的ikev2 profile
#建議sa duration只使用time-based;如果需要設定traffic-based,請將traffic-based設定為最大值
ipsec profile to-ali-profile1 isakmp
 transform-set to-ali-trans
 ikev2-profile to-ali-profile1
 sa duration time-based 86400
 quit

ipsec profile to-ali-profile2 isakmp
 transform-set to-ali-trans
 ikev2-profile to-ali-profile2
 sa duration time-based 86400
 quit
 
#配置tunnel口,應用IPsec策略到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 tunnel protection ipsec profile to-ali-profile1
 source 10.32.0.175
 destination 39.XX.XX.17
 quit
interface tunnel 2 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 tunnel protection ipsec profile to-ali-profile2
 source 10.32.0.175
 destination 39.XX.XX.10
 quit

#配置對端內網網段路由指向tunnel介面,tunnel1為主隧道路由優先順序高
ip route-static 192.168.0.0 16 Tunnel 1 preference 10
ip route-static 192.168.0.0 16 Tunnel 2 preference 20
步驟四:安全性原則配置

配置安全性原則,以允許IKE協議流量和IPsec資料流量的通過。

重要
  • 此處樣本為簡化的配置,請根據實際需要,自行補充細粒度的規則。

  • 如果本地IDC側有多個網段要與VPC互連,建議採用目的路由模式與H3C對接。具體操作,請參見多網段配置方案推薦

#配置安全域,放通IKE協商報文和IPsec資料報文,這裡簡化了配置,如果需要細粒度的規則請自行補充
acl advanced 3001
 rule 0 permit ip
 quit
zone-pair security source any destination any
 packet-filter 3001
 quit
步驟五:結果驗證

在本機資料中心側,設定本機資料中心伺服器到H3C裝置的路由後,您可以開始測試本機資料中心和阿里雲VPC之間的網路連通性,並驗證主備切換。

  1. 測試本機資料中心和VPC之間的連通性。

    1. 登入VPC下任意一個ECS執行個體。關於如何登入ECS執行個體,請參見ECS遠端連線方式概述

    2. 在ECS執行個體中執行ping命令,訪問本機資料中心內的伺服器,驗證通訊是否正常。

      如果ECS執行個體可以收到本機資料中心伺服器的回複報文,則證明本機資料中心和VPC之間可以正常通訊。

      ping <本機資料中心伺服器私網IP地址>
  2. 測試IPsec-VPN串連的高可用性。

    1. 登入VPC下任意一個ECS執行個體。關於如何登入ECS執行個體,請參見ECS遠端連線方式概述

    2. 執行以下命令,使VPC下的ECS執行個體連續向本機資料中心發送訪問報文。

      ping <本機資料中心伺服器私網IP地址> -c 10000
    3. 中斷IPsec-VPN串連下的主隧道。

      您可以通過修改IPsec串連主隧道的預先共用金鑰來中斷主隧道,主隧道兩端的預先共用金鑰不一致,則主隧道會中斷。

    4. 中斷主隧道後,您可以觀察VPC執行個體下ECS執行個體的通訊情況,發現ECS執行個體下的流量在短暫中斷後,又重新恢複通訊,則表示在主隧道中斷後,流量自動通過備隧道進行通訊。

單出口+BGP路由

單公網IP單出口情境下,您可以將H3C裝置的單個出口,綁定至兩個Tunnel介面,並為其配置不同的IPsec profile,以此與阿里雲的主備隧道進行串連。

步驟一:介面網路設定

分別為H3C裝置的公網介面和私網介面配置IP地址和安全域,並配置路由。

#公網介面
interface GigabitEthernet 2/0
 ip addr 10.32.0.175 24
 quit

#私網介面
interface GigabitEthernet 4/0
 ip addr 10.34.0.10 24
 quit

#介面加入安全域
security-zone name Untrust
 import interface GigabitEthernet 2/0
 quit
security-zone name Trust
 import interface GigabitEthernet 4/0
 quit

#配置對端阿里雲的公網地址路由,下一跳指向公網
ip route-static 39.XX.XX.17 32 10.32.0.173
ip route-static 39.XX.XX.10 32 10.32.0.173
#配置本端內網網段路由,下一跳指向私網
ip route-static 10.0.0.0 8 10.34.0.253
步驟二:隧道配置

建立兩個Tunnel介面,以對接雲端的主備隧道。

#配置tunnel口,應用IPSec安全架構到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 quit
interface tunnel 2 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 quit

#tunnel介面加入安全域
security-zone name Untrust
 import interface Tunnel 1
 import interface Tunnel 2
 quit
步驟三:IPsec提議和策略配置

進行IPsec和IKE配置,注意和阿里雲側保持一致。

#配置IPsec安全提議
ipsec transform-set to-ali-trans
 encapsulation-mode tunnel
 protocol esp
 esp authentication-algorithm sha256
 esp encryption-algorithm aes-cbc-256
 pfs dh-group14
 quit

#配置IKE安全提議和ike安全性原則
ikev2 proposal to-ali-prop
 dh group14
 encryption aes-cbc-256
 integrity sha256
 prf sha256
 quit
ikev2 policy to-ali-policy
 priority 1
 proposal to-ali-prop
 quit

#配置IKE keychain,兩個peer分別對應阿里雲上兩個隧道,address是阿里雲上公網ip地址
ikev2 keychain to_ali_key1
 peer to-ali-peer1
  address 39.XX.XX.17 32
  identity address 39.XX.XX.17
  pre-shared-key plaintext ChangeMe****
  quit
 quit
ikev2 keychain to_ali_key2
 peer to-ali-peer2
  address 39.XX.XX.10 32
  identity address 39.XX.XX.10
  pre-shared-key plaintext ChangeMe****
  quit
 quit

#配置IKE profile,兩個peer分別對應阿里雲上兩個隧道
ikev2 profile to-ali-profile1
 authentication-method local pre-share
 authentication-method remote pre-share
 keychain to_ali_key1
 identity local address 8.XX.XX.3
 match remote identity address 39.XX.XX.17 32
 sa duration 86400
 dpd interval 30 periodic
 quit
 
ikev2 profile to-ali-profile2
 authentication-method local pre-share
 authentication-method remote pre-share
 keychain to_ali_key2
 identity local address 8.XX.XX.3
 match remote identity address 39.XX.XX.10 32
 sa duration 86400
 dpd interval 30 periodic
 quit


#配置IPsec profile,引用上面建立的ikev2 profile
#建議sa duration只使用time-based;如果需要設定traffic-based,請將traffic-based設定為最大值
ipsec profile to-ali-profile1 isakmp
 transform-set to-ali-trans
 ikev2-profile to-ali-profile1
 sa duration time-based 86400
 quit

ipsec profile to-ali-profile2 isakmp
 transform-set to-ali-trans
 ikev2-profile to-ali-profile2
 sa duration time-based 86400
 quit
 
#配置tunnel口,應用IPsec策略到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 tunnel protection ipsec profile to-ali-profile1
 source 10.32.0.175
 destination 39.XX.XX.17
 quit
interface tunnel 2 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 tunnel protection ipsec profile to-ali-profile2
 source 10.32.0.175
 destination 39.XX.XX.10
 quit

#配置對端內網網段路由指向tunnel介面,tunnel1為主隧道路由優先順序高
ip route-static 192.168.0.0 16 Tunnel 1 preference 10
ip route-static 192.168.0.0 16 Tunnel 2 preference 20
步驟四:安全性原則配置

配置安全性原則,以允許IKE協議流量和IPsec資料流量的通過。

重要
  • 此處樣本為簡化的配置,請根據實際需要,自行補充細粒度的規則。

  • 如果本地IDC側有多個網段要與VPC互連,建議採用目的路由模式與H3C對接。具體操作,請參見多網段配置方案推薦

#配置安全域,放通IKE協商報文和IPsec資料報文,這裡簡化了配置,如果需要細粒度的規則請自行補充
acl advanced 3001
 rule 0 permit ip
 quit
zone-pair security source any destination any
 packet-filter 3001
 quit
步驟五:BGP路由配置
#配置tunnel口的ip地址用於和阿里雲VPN協商BGP
interface tunnel 1 mode ipsec
 ip address 169.254.10.2 30
 quit
interface tunnel 2 mode ipsec
 ip address 169.254.20.2 30
 quit

#刪除靜態路由情境的指向隧道的靜態路由配置
undo ip route-static 192.168.0.0 16 Tunnel 1 preference 10
undo ip route-static 192.168.0.0 16 Tunnel 2 preference 20

#配置BGP,h3c fw發布10.0.0.0/8到阿里雲VPN
bgp 65500
peer 169.254.10.1 as-number 65535
peer 169.254.20.1 as-number 65535
address-family ipv4 unicast
peer 169.254.10.1 enable
peer 169.254.20.1 enable
network 10.0.0.0 8  #宣告10.0.0.0/8

配置完成後,查看BGP串連:

image

查看BGP路由:

image

查看路由表:

image

步驟六:結果驗證

在本機資料中心側,設定本機資料中心用戶端到H3C裝置的路由後,您可以開始測試本機資料中心和阿里雲VPC之間的網路連通性,並驗證主備切換。

  1. 測試本機資料中心和VPC之間的連通性。

    1. 登入VPC下任意一個ECS執行個體。關於如何登入ECS執行個體,請參見ECS遠端連線方式概述

    2. 在ECS執行個體中執行ping命令,訪問本機資料中心內的伺服器,驗證通訊是否正常。

      如果ECS執行個體可以收到本機資料中心伺服器的回複報文,則證明本機資料中心和VPC之間可以正常通訊。

      ping <本機資料中心伺服器私網IP地址>
  2. 測試IPsec-VPN串連的高可用性。

    1. 登入VPC下任意一個ECS執行個體。關於如何登入ECS執行個體,請參見ECS遠端連線方式概述

    2. 執行以下命令,使VPC下的ECS執行個體連續向本機資料中心發送訪問報文。

      ping <本機資料中心伺服器私網IP地址> -c 10000
    3. 中斷IPsec-VPN串連下的主隧道。

      您可以通過修改IPsec串連主隧道的預先共用金鑰來中斷主隧道,主隧道兩端的預先共用金鑰不一致,則主隧道會中斷。

    4. 中斷主隧道後,您可以觀察VPC執行個體下ECS執行個體的通訊情況,發現ECS執行個體下的流量在短暫中斷後,又重新恢複通訊,則表示在主隧道中斷後,流量自動通過備隧道進行通訊。

雙出口+靜態路由

在雙公網IP雙出口情境下,您可以將H3C裝置的兩個出口,分別綁定至兩個Tunnel介面,並為其配置不同的IPsec profile,以此與阿里雲的主備隧道進行串連。

步驟一:介面網路設定

分別為公網介面和私網介面配置IP地址和安全域,並配置路由。

#公網介面1
interface GigabitEthernet 2/0
 ip addr 10.32.0.175 24
 quit

#公網介面2
interface GigabitEthernet 3/0
 ip addr 10.33.0.238 24
 quit
 
#私網介面
interface GigabitEthernet 4/0
 ip addr 10.34.0.10 24
 quit

#介面加入安全域
security-zone name Untrust
 import interface GigabitEthernet 2/0
 import interface GigabitEthernet 3/0
 quit
security-zone name Trust
 import interface GigabitEthernet 4/0
 quit

#配置對端阿里雲的公網地址32位路由,下一跳指向公網
ip route-static 39.XX.XX.17 32 10.32.0.173
ip route-static 39.XX.XX.10 32 10.33.0.236
#配置本端內網網段路由,下一跳指向私網
ip route-static 10.0.0.0 8 10.34.0.253

步驟二:隧道配置

建立兩個Tunnel介面,以對接雲端的主備隧道。

#配置tunnel口,應用IPsec安全架構到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 quit
interface tunnel 2 mode ipsec
 ip address unnumbered interface GigabitEthernet 3/0
 quit

#tunnel介面加入安全域
security-zone name Untrust
 import interface Tunnel 1
 import interface Tunnel 2
 quit

步驟三:IPsec提議和策略配置

進行IPsec和IKE配置,注意和阿里雲側保持一致。

#配置IPsec安全提議
ipsec transform-set to-ali-trans
 encapsulation-mode tunnel
 protocol esp
 esp authentication-algorithm sha256
 esp encryption-algorithm aes-cbc-256
 pfs dh-group14
 quit

#配置IKE安全提議和ike安全性原則
ikev2 proposal to-ali-prop
 dh group14
 encryption aes-cbc-256
 integrity sha256
 prf sha256
 quit
ikev2 policy to-ali-policy
 priority 1
 proposal to-ali-prop
 quit

#配置IKE keychain,兩個peer分別對應阿里雲上兩個隧道,address是阿里雲上公網ip地址
ikev2 keychain to_ali_key1
 peer to-ali-peer1
  address 39.XX.XX.17 32
  identity address 39.XX.XX.17
  pre-shared-key plaintext ChangeMe****
  quit
 quit
ikev2 keychain to_ali_key2
 peer to-ali-peer2
  address 39.XX.XX.10 32
  identity address 39.XX.XX.10
  pre-shared-key plaintext ChangeMe****
  quit
 quit

#配置IKE profile,兩個peer分別對應阿里雲上兩個隧道
ikev2 profile to-ali-profile1
 authentication-method local pre-share
 authentication-method remote pre-share
 keychain to_ali_key1
 identity local address 8.XX.XX.3
 match remote identity address 39.XX.XX.17 32
 sa duration 86400
 dpd interval 30 periodic
 quit
 
ikev2 profile to-ali-profile2
 authentication-method local pre-share
 authentication-method remote pre-share
 keychain to_ali_key2
 identity local address 116.XX.XX.68
 match remote identity address 39.XX.XX.10 32
 sa duration 86400
 dpd interval 30 periodic
 quit


#配置IPsec profile,引用上面建立的ikev2 profile
#建議sa duration只使用time-based;如果需要設定traffic-based,請將traffic-based設定為最大值
ipsec profile to-ali-profile1 isakmp
 transform-set to-ali-trans
 ikev2-profile to-ali-profile1
 sa duration time-based 86400
 quit

ipsec profile to-ali-profile2 isakmp
 transform-set to-ali-trans
 ikev2-profile to-ali-profile2
 sa duration time-based 86400
 quit
 
#配置tunnel口,應用IPsec策略到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 tunnel protection ipsec profile to-ali-profile1
 source 10.32.0.175
 destination 39.XX.XX.17
 quit
interface tunnel 2 mode ipsec
 ip address unnumbered interface GigabitEthernet 3/0
 tunnel protection ipsec profile to-ali-profile2
 source 10.33.0.238
 destination 39.XX.XX.10
 quit

#配置對端內網網段路由指向tunnel介面,tunnel1為主隧道路由優先順序高
ip route-static 192.168.0.0 16 Tunnel 1 preference 10
ip route-static 192.168.0.0 16 Tunnel 2 preference 20

步驟四:安全性原則配置

配置安全性原則,以允許IKE協議流量和IPsec資料流量的通過。

重要
  • 此處樣本為簡化的配置,請根據實際需要,自行補充細粒度的規則。

  • 如果本地IDC側有多個網段要與VPC互連,建議採用目的路由模式與H3C對接。具體操作,請參見多網段配置方案推薦

#配置安全域,放通IKE協商報文和IPsec資料報文,這裡簡化了配置,如果需要細粒度的規則請自行補充
acl advanced 3001
 rule 0 permit ip
 quit
zone-pair security source any destination any
 packet-filter 3001
 quit

步驟五:結果驗證

在本機資料中心側,設定本機資料中心用戶端到H3C裝置的路由後,您可以開始測試本機資料中心和阿里雲VPC之間的網路連通性,並驗證主備切換。

  1. 測試本機資料中心和VPC之間的連通性。

    1. 登入VPC下任意一個ECS執行個體。關於如何登入ECS執行個體,請參見ECS遠端連線方式概述

    2. 在ECS執行個體中執行ping命令,訪問本機資料中心內的伺服器,驗證通訊是否正常。

      如果ECS執行個體可以收到本機資料中心伺服器的回複報文,則證明本機資料中心和VPC之間可以正常通訊。

      ping <本機資料中心伺服器私網IP地址>
  2. 測試IPsec-VPN串連的高可用性。

    1. 登入VPC下任意一個ECS執行個體。關於如何登入ECS執行個體,請參見ECS遠端連線方式概述

    2. 執行以下命令,使VPC下的ECS執行個體連續向本機資料中心發送訪問報文。

      ping <本機資料中心伺服器私網IP地址> -c 10000
    3. 中斷IPsec-VPN串連下的主隧道。

      您可以通過修改IPsec串連主隧道的預先共用金鑰來中斷主隧道,主隧道兩端的預先共用金鑰不一致,則主隧道會中斷。

    4. 中斷主隧道後,您可以觀察VPC執行個體下ECS執行個體的通訊情況,發現ECS執行個體下的流量在短暫中斷後,又重新恢複通訊,則表示在主隧道中斷後,流量自動通過備隧道進行通訊。

雙出口+BGP路由

在雙公網IP雙出口情境下,您可以將H3C裝置的兩個出口,分別綁定至兩個Tunnel介面,並為其配置不同的IPsec profile,以此與阿里雲的主備隧道進行串連。

步驟一:介面網路設定

分別為公網介面和私網介面配置IP地址和安全域,並配置路由。

#公網介面1
interface GigabitEthernet 2/0
 ip addr 10.32.0.175 24
 quit

#公網介面2
interface GigabitEthernet 3/0
 ip addr 10.33.0.238 24
 quit
 
#私網介面
interface GigabitEthernet 4/0
 ip addr 10.34.0.10 24
 quit

#介面加入安全域
security-zone name Untrust
 import interface GigabitEthernet 2/0
 import interface GigabitEthernet 3/0
 quit
security-zone name Trust
 import interface GigabitEthernet 4/0
 quit

#配置對端阿里雲的公網地址32位路由,下一跳指向公網
ip route-static 39.XX.XX.17 32 10.32.0.173
ip route-static 39.XX.XX.10 32 10.33.0.236
#配置本端內網網段路由,下一跳指向私網
ip route-static 10.0.0.0 8 10.34.0.253

步驟二:隧道配置

建立兩個Tunnel介面,以對接雲端的主備隧道。

#配置tunnel口,應用IPsec安全架構到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 quit
interface tunnel 2 mode ipsec
 ip address unnumbered interface GigabitEthernet 3/0
 quit

#tunnel介面加入安全域
security-zone name Untrust
 import interface Tunnel 1
 import interface Tunnel 2
 quit

步驟三:IPsec提議和策略配置

進行IPsec和IKE配置,注意和阿里雲側保持一致。

#配置IPsec安全提議
ipsec transform-set to-ali-trans
 encapsulation-mode tunnel
 protocol esp
 esp authentication-algorithm sha256
 esp encryption-algorithm aes-cbc-256
 pfs dh-group14
 quit

#配置IKE安全提議和ike安全性原則
ikev2 proposal to-ali-prop
 dh group14
 encryption aes-cbc-256
 integrity sha256
 prf sha256
 quit
ikev2 policy to-ali-policy
 priority 1
 proposal to-ali-prop
 quit

#配置IKE keychain,兩個peer分別對應阿里雲上兩個隧道,address是阿里雲上公網ip地址
ikev2 keychain to_ali_key1
 peer to-ali-peer1
  address 39.XX.XX.17 32
  identity address 39.XX.XX.17
  pre-shared-key plaintext ChangeMe****
  quit
 quit
ikev2 keychain to_ali_key2
 peer to-ali-peer2
  address 39.XX.XX.10 32
  identity address 39.XX.XX.10
  pre-shared-key plaintext ChangeMe****
  quit
 quit

#配置IKE profile,兩個peer分別對應阿里雲上兩個隧道
ikev2 profile to-ali-profile1
 authentication-method local pre-share
 authentication-method remote pre-share
 keychain to_ali_key1
 identity local address 8.XX.XX.3
 match remote identity address 39.XX.XX.17 32
 sa duration 86400
 dpd interval 30 periodic
 quit
 
ikev2 profile to-ali-profile2
 authentication-method local pre-share
 authentication-method remote pre-share
 keychain to_ali_key2
 identity local address 116.XX.XX.68
 match remote identity address 39.XX.XX.10 32
 sa duration 86400
 dpd interval 30 periodic
 quit


#配置IPsec profile,引用上面建立的ikev2 profile
#建議sa duration只使用time-based;如果需要設定traffic-based,請將traffic-based設定為最大值
ipsec profile to-ali-profile1 isakmp
 transform-set to-ali-trans
 ikev2-profile to-ali-profile1
 sa duration time-based 86400
 quit

ipsec profile to-ali-profile2 isakmp
 transform-set to-ali-trans
 ikev2-profile to-ali-profile2
 sa duration time-based 86400
 quit
 
#配置tunnel口,應用IPsec策略到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 tunnel protection ipsec profile to-ali-profile1
 source 10.32.0.175
 destination 39.XX.XX.17
 quit
interface tunnel 2 mode ipsec
 ip address unnumbered interface GigabitEthernet 3/0
 tunnel protection ipsec profile to-ali-profile2
 source 10.33.0.238
 destination 39.XX.XX.10
 quit

#配置對端內網網段路由指向tunnel介面,tunnel1為主隧道路由優先順序高
ip route-static 192.168.0.0 16 Tunnel 1 preference 10
ip route-static 192.168.0.0 16 Tunnel 2 preference 20

步驟四:安全性原則配置

配置安全性原則,以允許IKE協議流量和IPsec資料流量的通過。

重要
  • 此處樣本為簡化的配置,請根據實際需要,自行補充細粒度的規則。

  • 如果本地IDC側有多個網段要與VPC互連,建議採用目的路由模式與H3C對接。具體操作,請參見多網段配置方案推薦

#配置安全域,放通IKE協商報文和IPsec資料報文,這裡簡化了配置,如果需要細粒度的規則請自行補充
acl advanced 3001
 rule 0 permit ip
 quit
zone-pair security source any destination any
 packet-filter 3001
 quit

步驟五:BGP路由配置

#配置tunnel口的ip地址用於和阿里雲VPN協商BGP
interface tunnel 1 mode ipsec
 ip address 169.254.10.2 30
 quit
interface tunnel 2 mode ipsec
 ip address 169.254.20.2 30
 quit

#刪除靜態路由情境的指向隧道的靜態路由配置
undo ip route-static 192.168.0.0 16 Tunnel 1 preference 10
undo ip route-static 192.168.0.0 16 Tunnel 2 preference 20

#配置BGP,h3c fw發布10.0.0.0/8到阿里雲VPN
bgp 65500
peer 169.254.10.1 as-number 65535
peer 169.254.20.1 as-number 65535
address-family ipv4 unicast
peer 169.254.10.1 enable
peer 169.254.20.1 enable
network 10.0.0.0 8  #宣告10.0.0.0/8

配置完成後,查看BGP串連:

image

查看BGP路由:

image

查看路由表:

image

步驟六:結果驗證

在本機資料中心側,設定本機資料中心用戶端到H3C裝置的路由後,您可以開始測試本機資料中心和阿里雲VPC之間的網路連通性,並驗證主備切換。

  1. 測試本機資料中心和VPC之間的連通性。

    1. 登入VPC下任意一個ECS執行個體。關於如何登入ECS執行個體,請參見ECS遠端連線方式概述

    2. 在ECS執行個體中執行ping命令,訪問本機資料中心內的伺服器,驗證通訊是否正常。

      如果ECS執行個體可以收到本機資料中心伺服器的回複報文,則證明本機資料中心和VPC之間可以正常通訊。

      ping <本機資料中心伺服器私網IP地址>
  2. 測試IPsec-VPN串連的高可用性。

    1. 登入VPC下任意一個ECS執行個體。關於如何登入ECS執行個體,請參見ECS遠端連線方式概述

    2. 執行以下命令,使VPC下的ECS執行個體連續向本機資料中心發送訪問報文。

      ping <本機資料中心伺服器私網IP地址> -c 10000
    3. 中斷IPsec-VPN串連下的主隧道。

      您可以通過修改IPsec串連主隧道的預先共用金鑰來中斷主隧道,主隧道兩端的預先共用金鑰不一致,則主隧道會中斷。

    4. 中斷主隧道後,您可以觀察VPC執行個體下ECS執行個體的通訊情況,發現ECS執行個體下的流量在短暫中斷後,又重新恢複通訊,則表示在主隧道中斷後,流量自動通過備隧道進行通訊。

單隧道模式

單擊查看樣本

情境樣本

以上圖情境為例:

  1. 某公司在本地擁有一個資料中心,本機資料中心中要與阿里雲互連的網段為10.34.0.0/24。

  2. 該公司在阿里雲擁有一個Virtual Private Cloud,VPC網段為192.168.0.0/16,VPC中使用Elastic Compute Service部署了應用服務。

  3. 公司計劃在本機資料中心與雲上VPC之間建立單隧道模式的IPsec-VPN串連,實現資源互訪。

說明

針對單隧道模式,本文僅給出靜態路由方式的配置樣本。

地址規劃

本樣本涉及的網路設定詳情請參見下表。

位置

配置項

樣本值

本地IDC

H3C裝置地址

GE2(公網出口):10.32.0.175/24

出口下一跳:10.32.0.173

映射公網IP:8.XX.XX.3

GE4(私網介面):10.34.0.20/24

伺服器IP

10.34.0.21

阿里雲

VPN網關地址

39.XX.XX.17

VPC網段

192.168.0.0/16

交換器網段

192.168.1.0/24

ECS地址

192.168.1.11

IPsec串連配置規劃

阿里雲側和H3C防火牆側IPsec串連配置需保持相同。

配置項

樣本值

預先共用金鑰

ChangeMe****

IKE

版本

ikev2

協商模式

main

密碼編譯演算法

aes256

認證演算法

sha256

DH分組

group14

SA生存周期(秒)

86400

IPsec

密碼編譯演算法

aes256

認證演算法

sha256

DH分組

group14

SA生存周期(秒)

86400

前提條件

您已在阿里雲側完成建立VPN網關、建立使用者網關、建立IPsec串連、配置VPN網關路由的操作。具體操作,請參見建立VPC到本機資料中心的串連(單隧道模式)

操作步驟

說明

本文使用H3C的vFW1k E1185版本進行配置樣本。不同型號版本的防火牆配置可能存在差別,您可以根據實際使用的版本,參考相應的文檔或諮詢防火牆廠商進行操作配置。

靜態路由方式
步驟一:介面網路設定

分別為H3C裝置的公網介面和私網介面配置IP地址和安全域,並配置路由。

#公網介面
interface GigabitEthernet 2/0
 ip addr 10.32.0.175 24
 quit

#私網介面
interface GigabitEthernet 4/0
 ip addr 10.34.0.10 24
 quit

#介面加入安全域
security-zone name Untrust
 import interface GigabitEthernet 2/0
 quit
security-zone name Trust
 import interface GigabitEthernet 4/0
 quit

#配置對端阿里雲的公網地址路由,下一跳指向公網
ip route-static 39.XX.XX.17 32 10.32.0.173
#配置本端內網網段路由,下一跳指向私網
ip route-static 10.0.0.0 8 10.34.0.253
步驟二:隧道配置

建立1個Tunnel介面,以對接雲端的隧道。

#配置1個tunnel口,應用IPSec安全架構到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 quit

#tunnel介面加入安全域
security-zone name Untrust
 import interface Tunnel 1
 quit
步驟三:IPsec提議和策略配置

進行IPsec和IKE配置,注意和阿里雲側保持一致。

#配置IPsec安全提議
ipsec transform-set to-ali-trans
 encapsulation-mode tunnel
 protocol esp
 esp authentication-algorithm sha256
 esp encryption-algorithm aes-cbc-256
 pfs dh-group14
 quit

#配置IKE安全提議和ike安全性原則
ikev2 proposal to-ali-prop
 dh group14
 encryption aes-cbc-256
 integrity sha256
 prf sha256
 quit
ikev2 policy to-ali-policy
 priority 1
 proposal to-ali-prop
 quit

#配置IKE keychain,peer對應阿里雲的隧道,address是阿里雲上公網ip地址
ikev2 keychain to_ali_key1
 peer to-ali-peer1
  address 39.XX.XX.17 32
  identity address 39.XX.XX.17
  pre-shared-key plaintext ChangeMe****
  quit
 quit

#配置IKE profile,peer對應阿里雲的隧道
ikev2 profile to-ali-profile1
 authentication-method local pre-share
 authentication-method remote pre-share
 keychain to_ali_key1
 identity local address 8.XX.XX.3
 match remote identity address 39.XX.XX.17 32
 sa duration 86400
 dpd interval 30 periodic
 quit

#配置IPsec profile,引用上面建立的ikev2 profile
ipsec profile to-ali-profile1 isakmp
 transform-set to-ali-trans
 ikev2-profile to-ali-profile1
 #建議如下sa duration只使用time-based;如果需要設定traffic-based,請將traffic-based設定為最大值
 sa duration time-based 86400 
 quit
 
#配置tunnel口,應用IPsec策略到tunnel口
interface tunnel 1 mode ipsec
 ip address unnumbered interface GigabitEthernet 2/0
 tunnel protection ipsec profile to-ali-profile1
 source 10.32.0.175
 destination 39.XX.XX.17
 quit

#配置對端內網網段路由指向tunnel介面
ip route-static 192.168.0.0 16 Tunnel 1 preference 10
步驟四:安全性原則配置

配置安全性原則,以允許IKE協議流量和IPsec資料流量的通過。

重要
  • 此處樣本為簡化的配置,請根據實際需要,自行補充細粒度的規則。

  • 如果本地IDC側有多個網段要與VPC互連,建議採用目的路由模式與H3C對接。具體操作,請參見多網段配置方案推薦

#配置安全域,放通IKE協商報文和IPsec資料報文,這裡簡化了配置,如果需要細粒度的規則請自行補充
acl advanced 3001
 rule 0 permit ip
 quit
zone-pair security source any destination any
 packet-filter 3001
 quit
步驟五:結果驗證

在本機資料中心側,設定本機資料中心伺服器到H3C裝置的路由後,您可以開始測試本機資料中心和阿里雲VPC之間的網路連通性。

  1. 登入到VPC內一台無公網IP的ECS執行個體。關於如何登入ECS執行個體,請參見ECS遠端連線方式概述

  2. 執行ping命令,訪問本機資料中心內的一台伺服器,驗證通訊是否正常。

    如果能夠收到回複報文,則證明通訊正常。