虚拟专用网络 VPN-示例一:创建VPN网关:操作步骤

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

操作步骤

  1. 创建关联VPC的VPN网关。
    1. 发送“POST https://{endpoint}/v5/{project_id}/vpn-gateways”,project_id为项目ID。
    2. 在Request Header中增加“X-Auth-Token”。
    3. 在Request Body中传入参数如下。
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      {
          "vpn_gateway": {
              "vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c",
              "local_subnets": [
                  "192.168.0.0/24", "192.168.1.0/24"
              ],
              "connect_subnet": "f5741286-demo-a8df-va86-2c82bd9ee114",
              "eip1": {
                  "id": "cff40e5e-demo-a8df-va86-7366077bf097"
              },
              "eip2": {
                  "id": "d290f1ee-demo-a8df-va86-d701748f0851"
              }
          }
      }
      
    4. 查看请求响应结果。
      • 请求成功时,响应参数如下,id就是VPN网关的ID。
        {
            "vpn_gateway": {
                "id": "620d99b8-demo-a8df-va86-200b868f2d7d",
                "name": "vpngw-3caf",
                "network_type": "public",
                "attachment_type": "vpc",
                "vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c",
                "local_subnets": ["192.168.0.0/24", "192.168.1.0/24"],
                "connect_subnet": "f5741286-demo-a8df-va86-2c82bd9ee114",
                "bgp_asn": 64512,
                "access_vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c",
                "access_subnet_id": "f5741286-demo-a8df-va86-2c82bd9ee114",
                "flavor": "Professional1",
                "used_connection_number": 0,
                "used_connection_group": 0,
                "enterprise_project_id": "0"
            },
            "request_id": "4a739f5c-edb7-4122-b31f-b77fb1b94857"
        }
  2. 查询VPN网关详情。
    1. 发送“GET https://{endpoint}/v5/{project_id}/vpn-gateways/{vgw_id}”,project_id为项目ID。
    2. 在Request Header中增加“X-Auth-Token”。
    3. 查看请求响应结果。
      • 请求成功时,响应参数如下,id就是VPN网关的ID。
        {
            "vpn_gateway": {
                "id": "620d99b8-demo-a8df-va86-200b868f2d7d",
                "name": "vpngw-3caf",
                "network_type": "public",
                "status": "ACTIVE",
                "attachment_type": "vpc",
                "vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c",
                "local_subnets": [
                    "192.168.0.0/24", "192.168.1.0/24"
                ],
                "connect_subnet": "f5741286-demo-a8df-va86-2c82bd9ee114",
                "access_vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c",
                "access_subnet_id": "f5741286-demo-a8df-va86-2c82bd9ee114",
                "bgp_asn": 64512,
                "flavor": "Professional1",
                "availability_zone_ids": [
                    "cn-south-1f", "cn-south-1e"
                ],
                "used_connection_number": 0,
                "used_connection_group": 0,
                "enterprise_project_id": "0",
                "eip1": {
                    "id": "cff40e5e-demo-a8df-va86-7366077bf097",
                    "ip_version": 4,
                    "type": "5_bgp",
                    "ip_address": "88.***.***.8",
                    "charge_mode": "bandwidth",
                    "bandwidth_id": "593a1a79-demo-a8df-va86-64ec45fb23f6",
                    "bandwidth_size": 300,
                    "bandwidth_name": "vpngw-bandwidth-1391"
                },
                "eip2": {
                    "id": "d290f1ee-demo-a8df-va86-d701748f0851",
                    "ip_version": 4,
                    "type": "5_bgp",
                    "ip_address": "88.***.***.6",
                    "charge_mode": "bandwidth",
                    "bandwidth_id": "0abb9d55-demo-a8df-va86-b7500ac2a338",
                    "bandwidth_size": 300,
                    "bandwidth_name": "vpngw-bandwidth-1392"
                },
                "created_at": "2022-09-15T08:56:09.386Z",
                "updated_at": "2022-09-15T11:13:13.677Z"
            },
            "request_id": "d099a7dc-ea71-45a6-a75b-dccbfe17d438"
        }        
support.huaweicloud.com/api-vpn/vpn_api_0040.html