虚拟专用网络 VPN-示例三:创建VPN连接:操作步骤

时间:2024-04-19 17:53:23

操作步骤

  1. 基于关联VPC的VPN网关,创建静态路由模式的VPN连接。
    1. 发送“POST https://{endpoint}/v5/{project_id}/vpn-connection”,project_id为项目ID。
    2. 在Request Header中增加“X-Auth-Token”。
    3. 在Request Body中传入参数如下。
      {
          "vpn_connection": {
              "vgw_id": "b32d91a4-demo-a8df-va86-e907174eb11d",
              "vgw_ip": "0c464dad-demo-a8df-va86-c22bb0eb0bde",
              "cgw_id": "5247ae10-demo-a8df-va86-dd36659a7f5d",
              "peer_subnets": [
                  "192.168.44.0/24"
              ],
              "psk": "abcd****"
          }
      }
    4. 查看请求响应结果。
      • 请求成功时,响应参数如下,id就是VPN连接的ID。
        {
            "vpn_connection": {
                "id": "98c5af8a-demo-a8df-va86-ae2280a6f4c3",
                "name": "vpn-1655",
                "vgw_id": "b32d91a4-demo-a8df-va86-e907174eb11d",
                "vgw_ip": "0c464dad-demo-a8df-va86-c22bb0eb0bde",
                "style": "STATIC",
                "cgw_id": "5247ae10-demo-a8df-va86-dd36659a7f5d",
                "peer_subnets": ["192.168.44.0/24"],
                "tunnel_local_address": "169.254.56.225/30",
                "tunnel_peer_address": "169.254.56.226/30",
                "enable_nqa": false,
                "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",
            },
            "request_id": "f74da97d-aa27-4f62-a87c-a33b5706964b"
        }
  2. 查询VPN连接详情。
    1. 发送“GET https://{endpoint}/v5/{project_id}/vpn-connection/{vpn_connection_id}”,project_id为项目ID。
    2. 在Request Header中增加“X-Auth-Token”。
    3. 查看请求响应结果。
      • 请求成功时,响应参数如下,id就是VPN连接的ID。
        {
            "vpn_connection": {
                "id": "98c5af8a-demo-a8df-va86-ae2280a6f4c3",
                "name": "vpn-1655",
                "status": "DOWN",
                "vgw_id": "b32d91a4-demo-a8df-va86-e907174eb11d",
                "vgw_ip": "0c464dad-demo-a8df-va86-c22bb0eb0bde",
                "style": "STATIC",
                "cgw_id": "5247ae10-demo-a8df-va86-dd36659a7f5d",
                "peer_subnets": ["192.168.44.0/24"],
                "tunnel_local_address": "169.254.56.225/30",
                "tunnel_peer_address": "169.254.56.226/30",
                "enable_nqa": false,
                "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",
            },
            "request_id": "104c5608-b68b-462c-af17-ead2fb5ccee4"
        }
support.huaweicloud.com/api-vpn/vpn_api_0042.html