華為云計(jì)算 云知識(shí) 更新VPN連接UpdateVpnConnection
更新VPN連接UpdateVpnConnection

 

功能介紹

根據(jù)連接ID,更新指定的VPN連接的參數(shù)

URI

PUT /v5/{project_id}/vpn-connection/{vpn_connection_id}

表1 參數(shù)說(shuō)明

名稱

類型

是否必選

說(shuō)明

project_id

String

項(xiàng)目ID,可以通過(guò)獲取項(xiàng)目ID獲取項(xiàng)目ID。

vpn_connection_id

String

VPN連接ID

請(qǐng)求消息

  • 請(qǐng)求參數(shù)
    表2 請(qǐng)求參數(shù)

    名稱

    類型

    是否必選

    描述

    vpn_connection

    UpdateVpnConnectionRequestBodyContent object

    vpn_connection對(duì)象

    表3 UpdateVpnConnectionRequestBodyContent

    名稱

    類型

    是否必選

    描述

    name

    String

    • 功能說(shuō)明:VPN連接名稱
    • 取值范圍:1-64個(gè)字符,支持?jǐn)?shù)字、英文字母、中文(\u4e00 - \u9fa5)、_(下劃線)、-(中劃線)。

    cgw_id

    String

    • 功能說(shuō)明:對(duì)端網(wǎng)關(guān)ID
    • 約束:36位UUID

    peer_subnets

    Array of String

    • 功能說(shuō)明:對(duì)端子網(wǎng)
    • 約束:

      VPN網(wǎng)關(guān)的關(guān)聯(lián)模式為er并且style字段為policy或bgp時(shí)不填,其他場(chǎng)景必填。

      部分網(wǎng)段是VPC預(yù)留網(wǎng)段,不能作為對(duì)端子網(wǎng),比如100.64.0.0/10,214.0.0.0/8。

      每個(gè)VPN連接最多填寫50個(gè)對(duì)端子網(wǎng)。

    tunnel_local_address

    String

    • 功能說(shuō)明:路由模式下配置在VPN網(wǎng)關(guān)上的tunnel接口地址。例如:169.254.76.1/30。
    • 約束:

      前16位必須是169.254,不能使用169.254.195.xxx;

      掩碼長(zhǎng)度必須是30。必須和tunnel_peer_address在同一個(gè)30掩碼范圍。

      應(yīng)填寫網(wǎng)段中的主機(jī)地址。

    tunnel_peer_address

    String

    • 功能說(shuō)明:路由模式下配置在用戶側(cè)設(shè)備上的tunnel接口地址。例如:169.254.76.1/30。
    • 約束:

      前16位必須是169.254,不能使用169.254.195.xxx;

      掩碼長(zhǎng)度必須是30。必須和tunnel_local_address在同一個(gè)30掩碼范圍。

      應(yīng)填寫網(wǎng)段中的主機(jī)地址。

    psk

    String

    • 功能說(shuō)明:預(yù)共享密鑰。ike版本為v2時(shí),只修改該字段不生效。
    • 約束:8-128個(gè)字符,只能包含大寫字母、小寫字母、數(shù)字和特殊字符(~!@#$%^()-_+={ },./:;)且至少包含四種字符的三種。

    policy_rules

    Array of PolicyRule objects

    • 功能說(shuō)明:策略模式的策略規(guī)則組
    • 約束:最多填寫5個(gè)。style為policy時(shí)填寫,為static或bgp時(shí)不填。

    可以通過(guò)查詢VPN連接查看VPN連接的style。

    ikepolicy

    UpdateIkePolicy object

    ike策略對(duì)象

    ipsecpolicy

    UpdateIpsecPolicy object

    ipsec策略對(duì)象

    表4 PolicyRule

    名稱

    類型

    是否必選

    描述

    rule_index

    Integer

    • 功能說(shuō)明:規(guī)則ID,用于區(qū)分配置的策略規(guī)則順序。建議不填。
    • 取值范圍:0-50
    • 約束:不能與其他PolicyRule下的rule_index相同,ResponseVpnConnection中的rule_index可能與該值不同,因?yàn)関pn服務(wù)會(huì)將多個(gè)destination拆成不同rule。

    source

    String

    • 功能說(shuō)明:源地址網(wǎng)段。
    • 約束:不能與其他PolicyRule下的source相同。

    destination

    Array of String

    • 功能說(shuō)明:目的地址網(wǎng)段。

      單個(gè)網(wǎng)段格式示例:192.168.52.0/24。

    • 約束:每個(gè)PolicyRule最多填寫50個(gè)。
    表5 UpdateIkePolicy

    名稱

    類型

    是否必選

    描述

    ike_version

    String

    • 功能說(shuō)明:IKE版本號(hào)
    • 取值范圍:

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),取值范圍為v1;

      其他場(chǎng)景下取值范圍為v1,v2。

    • 默認(rèn)值:

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),默認(rèn)值為v1;

      其他場(chǎng)景下,默認(rèn)值為v2。

    phase1_negotiation_mode

    String

    • 功能說(shuō)明:協(xié)商模式
    • 取值范圍:

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),取值范圍為main;

      其他場(chǎng)景下取值范圍為main,aggressive。

      main:主模式,協(xié)商過(guò)程安全性高。

      aggressive:野蠻模式,協(xié)商快速且協(xié)商成功率高。

    • 約束:ike版本為v2時(shí)忽略此字段,IKE版本為v1時(shí)生效。

    authentication_algorithm

    String

    • 功能說(shuō)明:認(rèn)證算法。修改該字段后需要等SA協(xié)商一階段老化后生效。
    • 取值范圍:

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),取值范圍為sm3;

      其他場(chǎng)景下取值范圍為sha2-512,sha2-384,sha2-256,sha1,md5。

      其中,sha1和md5安全性較低,請(qǐng)慎用。

    encryption_algorithm

    String

    • 功能說(shuō)明:加密算法。修改該字段后需要等SA協(xié)商一階段老化后生效。
    • 取值范圍:

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),取值范圍為sm4;

      其他場(chǎng)景下取值范圍為aes-256-gcm-16,aes-128-gcm-16,aes-256,aes-192,aes-128,3des。

      其中,3des安全性較低,請(qǐng)慎用。

    dh_group

    String

    • 功能說(shuō)明:第一階段密鑰交換使用的DH組。修改該字段后需要等協(xié)商一階段老化后生效。

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),該字段無(wú)法修改。

    • 取值范圍:group1,group2,group5,group14,group15,group16,group19,group20,group21。

      其中,group1,group2,group5,group14安全性較低,請(qǐng)慎用。

    lifetime_seconds

    Integer

    • 功能說(shuō)明:表示SA的生存周期,當(dāng)該生存周期超時(shí)后IKE SA將自動(dòng)更新。修改該字段后需要等協(xié)商一階段老化后生效。
    • 取值范圍:60-604800,單位:秒

    local_id_type

    String

    • 功能說(shuō)明:本端ID類型

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),該字段無(wú)法修改。

    • 取值范圍:ip,fqdn。

    local_id

    String

    • 功能說(shuō)明:本端ID

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),該字段無(wú)法修改。

    • 約束:最大長(zhǎng)度255個(gè)字符,只能由大小寫字母、數(shù)字和特殊符號(hào)組成,不支持以下特殊字符:&、<、>、[、]、\、空格、?,區(qū)分大小寫。當(dāng)local_id_type為fqdn時(shí)填寫,需要和對(duì)端設(shè)備的peer_id一致。

    peer_id_type

    String

    • 功能說(shuō)明:對(duì)端ID類型

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),該字段無(wú)法修改。

    • 取值范圍:ip,fqdn。

    peer_id

    String

    • 功能說(shuō)明:對(duì)端ID

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),該字段無(wú)法修改。

    • 約束:最大長(zhǎng)度255個(gè)字符,只能由大小寫字母、數(shù)字和特殊符號(hào)組成,不支持以下特殊字符:&、<、>、[、]、\、空格、?,區(qū)分大小寫。當(dāng)peer_id_type為fqdn時(shí)填寫,需要和對(duì)端設(shè)備的local_id一致。

    dpd

    UpdateDpd object

    對(duì)等體存活檢測(cè)對(duì)象

    表6 UpdateDpd

    名稱

    類型

    是否必選

    描述

    timeout

    Integer

    • 功能說(shuō)明:對(duì)等體存活檢測(cè)報(bào)文重傳間隔
    • 取值范圍:2-60,單位:秒,不填時(shí)默認(rèn)為15。

    interval

    Integer

    • 功能說(shuō)明:對(duì)等體存活檢測(cè)空閑時(shí)間
    • 取值范圍:10-3600,單位:秒,不填時(shí)默認(rèn)為30。

    msg

    String

    • 功能說(shuō)明:對(duì)等體存活檢測(cè)報(bào)文格式
    • 取值范圍:

      seq-hash-notify:指定DPD報(bào)文中的載荷順序是hash-notify。

      seq-notify-hash:指定DPD報(bào)文中的載荷順序是notify-hash。

      默認(rèn)為seq-hash-notify

    表7 UpdateIpsecPolicy

    名稱

    類型

    是否必選

    描述

    authentication_algorithm

    String

    • 功能說(shuō)明:認(rèn)證算法。SHA1和MD5安全性較低,請(qǐng)慎用。修改該字段后需要等協(xié)商二階段老化后生效。
    • 取值范圍:

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),取值范圍為sm3;

      其他場(chǎng)景下取值范圍為sha2-512,sha2-384,sha2-256,sha1,md5。

    encryption_algorithm

    String

    • 功能說(shuō)明:加密算法。3DES安全性較低,請(qǐng)慎用。修改該字段后需要等協(xié)商二階段老化后生效。
    • 取值范圍:

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),取值范圍為sm4;

      其他場(chǎng)景下取值范圍為aes-256-gcm-16,aes-128-gcm-16,aes-256,aes-192,aes-128,3des。

    pfs

    String

    • 功能說(shuō)明:PFS使用的DH密鑰組

      當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時(shí),該字段不生效,無(wú)法修改。

    • 取值范圍:group1,group2,group5,group14,group15,group16,group19,group20,group21,disable,默認(rèn)為group15。

      其中,group1,group2,group5,group14安全性較低,請(qǐng)慎用。

    transform_protocol

    String

    • 功能說(shuō)明:傳輸協(xié)議
    • 取值范圍:

      esp:封裝安全協(xié)議

      默認(rèn)為esp

    lifetime_seconds

    Integer

    • 功能說(shuō)明:表示配置IPSec連接建立的隧道以時(shí)間為基準(zhǔn)的生存周期。修改該字段后需要等協(xié)商二階段老化后生效。
    • 取值范圍:30-604800,單位:秒,默認(rèn)為3600。

    encapsulation_mode

    String

    • 功能說(shuō)明:報(bào)文封裝模式
    • 取值范圍:

      tunnel:隧道模式

      默認(rèn)為tunnel

  • 請(qǐng)求樣例
    1. 更新對(duì)端子網(wǎng)。
      PUT https://{Endpoint}/v5/{project_id}/vpn-connection/{vpn_connection_id}
      
      {
          "vpn_connection": {
              "peer_subnets": [
                  "192.168.1.0/24"
              ]
          }
      }
    2. 更新策略規(guī)則。
      PUT https://{Endpoint}/v5/{project_id}/vpn-connection/{vpn_connection_id}
      
      {
          "vpn_connection": {
              "policy_rules": [{
                  "rule_index": 1,
                  "source": "10.0.0.0/24",
                  "destination": [
                      "192.168.1.0/24"
                  ]
              }]
          }
      }
    3. 更新生命周期。
      PUT https://{Endpoint}/v5/{project_id}/vpn-connection/{vpn_connection_id}
      
      {
          "vpn_connection": {
              "ikepolicy": {
                  "lifetime_seconds": 3600
              },
              "ipsecpolicy": {
                  "lifetime_seconds": 3600
              }
          }
      }
    4. 更新連接名稱。
      PUT https://{Endpoint}/v5/{project_id}/vpn-connection/{vpn_connection_id}
      
      {
          "vpn_connection": {
              "name": "vpn_connection_name"
          }
      }

響應(yīng)消息

  • 響應(yīng)參數(shù)

    返回狀態(tài)碼為 200: successful operation

    表8 響應(yīng)Body參數(shù)列表

    名稱

    類型

    描述

    vpn_connection

    ResponseVpnConnection object

    vpn_connection對(duì)象

    request_id

    String

    請(qǐng)求ID

    表9 ResponseVpnConnection

    名稱

    類型

    描述

    id

    String

    • 功能說(shuō)明:VPN連接ID
    • 格式:36位UUID

    name

    String

    • 功能說(shuō)明:VPN連接名稱,不填時(shí)會(huì)自動(dòng)生成。
    • 取值范圍:1-64個(gè)字符,支持?jǐn)?shù)字、英文字母、中文(\u4e00 - \u9fa5)、_(下劃線)、-(中劃線)。

    vgw_id

    String

    • 功能說(shuō)明:VPN網(wǎng)關(guān)ID
    • 格式:36位UUID

    vgw_ip

    String

    • 功能說(shuō)明: VPN網(wǎng)關(guān)EIP的ID或接入私網(wǎng)IP
    • 格式:36位UUID或點(diǎn)分十進(jìn)制IPv4地址(如192.168.45.7)

    style

    String

    • 功能說(shuō)明:連接模式
    • 取值范圍:

      POLICY: 策略模式

      STATIC: 靜態(tài)路由模式

      BGP: bgp路由模式

    cgw_id

    String

    • 功能說(shuō)明:對(duì)端網(wǎng)關(guān)ID
    • 格式:36位UUID

    peer_subnets

    Array of String

    對(duì)端子網(wǎng)。當(dāng)VPN網(wǎng)關(guān)的關(guān)聯(lián)模式為ER并且style字段為BGP或POLICY時(shí)不返回。

    tunnel_local_address

    String

    路由模式下配置在VPN網(wǎng)關(guān)上的tunnel接口地址。僅當(dāng)style為STATIC或BGP時(shí)有效。

    tunnel_peer_address

    String

    路由模式下配置在用戶側(cè)設(shè)備上的tunnel接口地址。僅當(dāng)style為STATIC或BGP時(shí)有效。

    enable_nqa

    Boolean

    • 功能說(shuō)明:開啟NQA檢測(cè)。僅當(dāng)style為STATIC時(shí)返回。
    • 取值范圍:true,false。

    policy_rules

    Array of PolicyRule objects

    策略模式的策略規(guī)則組。當(dāng)style為POLICY時(shí)返回實(shí)際的策略規(guī)則組,當(dāng)style為STATIC或BGP時(shí)不返回。

    ikepolicy

    IkePolicy object

    ike策略對(duì)象

    ipsecpolicy

    IpsecPolicy object

    ipsec策略對(duì)象

    created_at

    String

    創(chuàng)建時(shí)間

    updated_at

    String

    最后一次更新時(shí)間

    enterprise_project_id

    String

    • 功能說(shuō)明:企業(yè)項(xiàng)目ID
    • 格式:36位UUID。與vgw_id所標(biāo)識(shí)VPN網(wǎng)關(guān)的企業(yè)項(xiàng)目ID一致。

    connection_monitor_id

    String

    • 功能說(shuō)明:VPN連接監(jiān)控ID
    • 格式:36位UUID

    ha_role

    String

    • 功能說(shuō)明:主備模式VPN網(wǎng)關(guān)下的連接時(shí),'master'表示主連接,'slave'表示備連接。雙活模式下的連接ha_role都是'master'。
    • 默認(rèn)值:master
    表10 PolicyRule

    名稱

    類型

    描述

    rule_index

    Integer

    • 功能說(shuō)明:規(guī)則ID
    • 取值范圍:0-50

    source

    String

    源地址網(wǎng)段

    destination

    Array of String

    目的地址網(wǎng)段。單個(gè)網(wǎng)段格式示例:192.168.52.0/24。每個(gè)PolicyRule最多返回50個(gè)。

    表11 IkePolicy

    名稱

    類型

    描述

    ike_version

    String

    • 功能說(shuō)明:IKE版本號(hào)
    • 取值范圍:v1, v2。

    phase1_negotiation_mode

    String

    • 功能說(shuō)明:協(xié)商模式。僅當(dāng)IKE版本為v1時(shí)返回。
    • 取值范圍:

      main:主模式,協(xié)商過(guò)程安全性高。

      aggressive:野蠻模式,協(xié)商快速且協(xié)商成功率高。

    authentication_algorithm

    String

    • 功能說(shuō)明:認(rèn)證算法
    • 取值范圍:sha2-512,sha2-384,sha2-256,sha1,md5,sm3。

    encryption_algorithm

    String

    • 功能說(shuō)明:加密算法
    • 取值范圍:aes-256-gcm-16,aes-128-gcm-16,aes-256,aes-192,aes-128,3des,sm4。

    dh_group

    String

    • 功能說(shuō)明:第一階段密鑰交換使用的DH組,當(dāng)VPN網(wǎng)關(guān)flavor為GM時(shí)不返回。
    • 取值范圍:group1,group2,group5,group14,group15,group16,group19,group20,group21。

    authentication_method

    String

    • 功能說(shuō)明:ike協(xié)商時(shí)的認(rèn)證方法
    • 取值范圍:

      pre-share:預(yù)共享密鑰

      digital-envelope-v2:國(guó)密數(shù)字信封

    lifetime_seconds

    Integer

    • 功能說(shuō)明:表示SA的生存周期,當(dāng)該生存周期超時(shí)后IKE SA將自動(dòng)更新。
    • 取值范圍:60-604800,單位:秒。

    local_id_type

    String

    • 功能說(shuō)明:本端ID類型,當(dāng)VPN網(wǎng)關(guān)flavor為GM時(shí)不返回。
    • 取值范圍:ip,fqdn。

    local_id

    String

    本端ID。當(dāng)local_id_type為ip時(shí)返回VPN連接所使用的網(wǎng)關(guān)IP;當(dāng)local_id_type為fqdn時(shí)返回創(chuàng)建或更新VPN連接時(shí)指定的本端ID。

    當(dāng)VPN網(wǎng)關(guān)flavor為GM時(shí)不返回。

    peer_id_type

    String

    • 功能說(shuō)明:對(duì)端ID類型,當(dāng)VPN網(wǎng)關(guān)flavor為GM時(shí)不返回。
    • 取值范圍:ip,fqdn,any。

    peer_id

    String

    對(duì)端ID。當(dāng)peer_id_type為ip時(shí)返回對(duì)端網(wǎng)關(guān)的IP;當(dāng)peer_id_type為fqdn時(shí)返回創(chuàng)建或更新VPN連接時(shí)指定的對(duì)端ID;當(dāng)peer_id_type為any時(shí)不返回。

    當(dāng)VPN網(wǎng)關(guān)flavor為GM時(shí)不返回。

    dpd

    Dpd object

    對(duì)等體存活檢測(cè)對(duì)象

    表12 Dpd

    名稱

    類型

    描述

    timeout

    Integer

    • 功能說(shuō)明:對(duì)等體存活檢測(cè)報(bào)文重傳間隔
    • 取值范圍:2-60,單位:秒。

    interval

    Integer

    • 功能說(shuō)明:對(duì)等體存活檢測(cè)空閑時(shí)間
    • 取值范圍:10-3600,單位:秒。

    msg

    String

    • 功能說(shuō)明:對(duì)等體存活檢測(cè)報(bào)文格式
    • 取值范圍:

      seq-hash-notify:指定DPD報(bào)文中的載荷順序是hash-notify。

      seq-notify-hash:指定DPD報(bào)文中的載荷順序是notify-hash。

    表13 IpsecPolicy

    名稱

    類型

    描述

    authentication_algorithm

    String

    • 功能說(shuō)明:認(rèn)證算法
    • 取值范圍:sha2-512,sha2-384,sha2-256,sha1,md5,sm3。

    encryption_algorithm

    String

    • 功能說(shuō)明:加密算法
    • 取值范圍:aes-256-gcm-16,aes-128-gcm-16,aes-256,aes-192,aes-128,3des,sm4。

    pfs

    String

    • 功能說(shuō)明:PFS使用的DH密鑰組,當(dāng)VPN網(wǎng)關(guān)flavor為GM時(shí)不返回。
    • 取值范圍:group1,group2,group5,group14,group15,group16,group19,group20,group21,disable。

    transform_protocol

    String

    • 功能說(shuō)明:傳輸協(xié)議
    • 取值范圍:

      esp:封裝安全協(xié)議

    lifetime_seconds

    Integer

    • 功能說(shuō)明:表示配置IPSec連接建立的隧道以時(shí)間為基準(zhǔn)的生存周期。
    • 取值范圍:30-604800,單位:秒

    encapsulation_mode

    String

    • 功能說(shuō)明:報(bào)文封裝模式
    • 取值范圍:

      tunnel:隧道模式

  • 響應(yīng)樣例
    1. 更新VPN連接的響應(yīng)。
      {
          "vpn_connection": {
              "id": "98c5af8a-****-****-****-ae2280a6f4c3",
              "name": "vpn-1655",
              "vgw_id": "b32d91a4-****-****-****-e907174eb11d",
              "vgw_ip": "0c464dad-****-****-****-c22bb0eb0bde",
              "style": "POLICY",
              "cgw_id": "5247ae10-****-****-****-dd36659a7f5d",
              "peer_subnets": ["192.168.1.0/24"],
              "tunnel_local_address": "169.254.56.225/30",
              "tunnel_peer_address": "169.254.56.226/30",
              "policy_rules": [{
                  "rule_index": 1,
                  "source": "10.0.0.0/24",
                  "destination": [
                      "192.168.1.0/24"
                  ]
              }],
              "ikepolicy": {
                  "ike_version": "v2",
                  "authentication_algorithm": "sha2-256",
                  "encryption_algorithm": "aes-128",
                  "dh_group": "group15",
                  "authentication_method": "pre-share",
                  "lifetime_seconds": 86400,
                  "local_id_type": "ip",
                  "local_id": "10.***.***.134",
                  "peer_id_type": "ip",
                  "peer_id": "88.***.***.164",
                  "dpd": {
                      "timeout": 15,
                      "interval": 30,
                      "msg": "seq-hash-notify"
                  }
              },
              "ipsecpolicy": {
                  "authentication_algorithm": "sha2-256",
                  "encryption_algorithm": "aes-128",
                  "pfs": "group15",
                  "transform_protocol": "esp",
                  "lifetime_seconds": 3600,
                  "encapsulation_mode": "tunnel"
              },
              "created_at": "2022-11-26T13:41:34.626Z",
              "updated_at": "2022-11-26T13:41:34.626Z",
              "enterprise_project_id": "0",
              "ha_role": "master"
          },
          "request_id": "f91082d4-6d49-479c-ad1d-4e552a9f5cae"
      }
    2. 凍結(jié)場(chǎng)景下更新失敗。
      {
          "error_code": "VPN.0001",
          "error_msg": "invalid request: ILLEGAL not allowed update vpnConnection",
          "request_id": "8c833634-4560-7897-7740-a7462f5bcbd4"
      }

狀態(tài)碼

請(qǐng)參見狀態(tài)碼