虚拟私有云 VPC-示例四:配置云服务器高可用的IPv6虚拟IP功能:操作步骤

时间:2023-11-01 16:25:20

操作步骤

  1. 创建IPv6虚拟IP。
    1. 发送“POST https://VPC的Endpoint/v2.0/ports”。
    2. 在Request Header中增加“X-Auth-Token”。
    3. 在Request Body中传入参数如下,其中vip所在子网需与ECS同子网,subnet_id需要指定为IPv6的subnets对应ID。
      {    "port":{        "network_id":"b0ad9b80-bb16-4550-8ce0-514f949e35ee",        "device_owner":"neutron:VIP_PORT",        "name":"ipv6_vip_port_test",        "fixed_ips":[            {                "subnet_id":"33ce2628-6246-4e3a-859f-99cd753ff704"            }        ]    }}
    4. 查看请求响应结果。
      • 请求成功时,响应参数如下:
        {    "port": {        "id": "d92cfee7-9ebe-4483-85c1-00ffb1e45cd8",        "name": "ipv6_vip_port_test",        "status": "DOWN",        "admin_state_up": true,        "fixed_ips": [            {                "subnet_id": "33ce2628-6246-4e3a-859f-99cd753ff704",                "ip_address": "2001:db8:a583:21d:2e25:9403:6f3d:4664"            }        ],        "mac_address": "fa:16:3e:99:2e:92",        "network_id": "b0ad9b80-bb16-4550-8ce0-514f949e35ee",        "tenant_id": "060576782980d5762f9ec014dd2f1148",        "project_id": "060576782980d5762f9ec014dd2f1148",        "device_id": "",        "device_owner": "neutron:VIP_PORT",        "security_groups": [],        "extra_dhcp_opts": [],        "allowed_address_pairs": [],        "binding:vnic_type": "normal",        "binding:vif_details": {},        "binding:profile": {},        "port_security_enabled": true,        "created_at": "2020-12-15T03:01:07",        "updated_at": "2020-12-15T03:01:07"    }}
      • 请求异常时,错误码请参见错误码
  2. 通过云服务器的ID查询网卡信息,fixed_ips中存在IPv4地址和IPv6地址。
    1. 发送“GET https://VPC的Endpoint/v2.0/ports?device_id={ecs_id}&network_id={network_id}”
    2. 在Request Header中增加“X-Auth-Token”。
    3. 查看请求响应结果。
      • 请求成功时,响应参数如下:
        {      "ports": [{            "id": "47b4cd46-cfe5-415d-957f-5068189dce94",            "name": "",            "status": "ACTIVE",            "admin_state_up": true,            "fixed_ips": [                {                    "subnet_id": "0dd17989-1c23-4501-8dc1-40e4085f793f",                    "ip_address": "172.16.0.191"                },                {                    "subnet_id": "33ce2628-6246-4e3a-859f-99cd753ff704",                    "ip_address": "2001:db8:a583:21d:dfc0:d452:e9ab:65cf"                }            ],            "mac_address": "fa:16:3e:1e:f7:9a",            "network_id": "b0ad9b80-bb16-4550-8ce0-514f949e35ee",            "tenant_id": "060576782980d5762f9ec014dd2f1148",            "project_id": "060576782980d5762f9ec014dd2f1148",            "device_id": "ab7ca781-66bf-48a8-814b-1568cb393a38",            "device_owner": "compute:xxx",            "security_groups": [                "0552091e-b83a-49dd-88a7-4a5c86fd9ec3"            ],            "extra_dhcp_opts": [],            "allowed_address_pairs": [],            "binding:vnic_type": "normal",            "binding:vif_details": {                "primary_interface": true            },            "binding:profile": {},            "port_security_enabled": true,            "dns_assignment": [                {                    "hostname": "ip-172-16-0-191",                    "ip_address": "172.16.0.191",                    "fqdn": "ip-172-16-0-191.br-iaas-odin1.compute.internal."                }            ],            "dns_name": "ip-172-16-0-191",            "created_at": "2020-11-19T13:32:37",            "updated_at": "2020-11-19T13:33:50"        }]  }
      • 请求异常时,错误码请参见错误码
  3. 将云服务器与虚拟IP绑定。
    1. 发送“PUT https://VPC的Endpoint/v2.0/ports/{port_id}”。port_id为上面创建的IPv6虚拟IP对应的port_id。
    2. 在Request Header中增加“X-Auth-Token”。
    3. 在Request Body中传入参数如下,ip_address为2查询出的云服务器的网卡的IPv6 ip。
      {      "port": {          "allowed_address_pairs": [{              "ip_address": "2001:db8:a583:21d:dfc0:d452:e9ab:65cf"          }]      }  }
    4. 查看请求响应结果。
      • 请求成功时,响应参数如下:
        {    "port": {        "id": "d92cfee7-9ebe-4483-85c1-00ffb1e45cd8",        "name": "ipv6_vip_port_test",        "status": "DOWN",        "admin_state_up": true,        "fixed_ips": [            {                "subnet_id": "33ce2628-6246-4e3a-859f-99cd753ff704",                "ip_address": "2001:db8:a583:21d:2e25:9403:6f3d:4664"            }        ],        "mac_address": "fa:16:3e:99:2e:92",        "network_id": "b0ad9b80-bb16-4550-8ce0-514f949e35ee",        "tenant_id": "060576782980d5762f9ec014dd2f1148",        "project_id": "060576782980d5762f9ec014dd2f1148",        "device_id": "",        "device_owner": "neutron:VIP_PORT",        "security_groups": [],        "extra_dhcp_opts": [],        "allowed_address_pairs": [{              "ip_address": "2001:db8:a583:21d:dfc0:d452:e9ab:65cf "          }],        "binding:vnic_type": "normal",        "binding:vif_details": {},        "binding:profile": {},        "port_security_enabled": true,        "created_at": "2020-12-15T03:01:07",        "updated_at": "2020-12-15T03:01:07"    }}
      • 请求异常时,错误码请参见错误码
  4. 关闭云服务器网卡的源/目的检查。
    1. 发送“PUT https://VPC的Endpoint/v2.0/ports/{port_id}”。port_id为2查询到的网卡ID。
    2. 在Request Header中增加“X-Auth-Token”。
    3. 在Request Body中传入参数如下:ip_address为1.1.1.1/0查询出的云服务器的网卡ip。
      {"port": {"allowed_address_pairs": [{"ip_address": "1.1.1.1/0"}]}}
    4. 查看请求响应结果。
      • 请求成功时,响应参数如下:
        {      "port": { "id": "47b4cd46-cfe5-415d-957f-5068189dce94",            "name": "",            "status": "ACTIVE",            "admin_state_up": true,            "fixed_ips": [                {                    "subnet_id": "0dd17989-1c23-4501-8dc1-40e4085f793f",                    "ip_address": "172.16.0.191"                },                {                    "subnet_id": "33ce2628-6246-4e3a-859f-99cd753ff704",                    "ip_address": "2001:db8:a583:21d:dfc0:d452:e9ab:65cf"                }            ],            "mac_address": "fa:16:3e:1e:f7:9a",            "network_id": "b0ad9b80-bb16-4550-8ce0-514f949e35ee",            "tenant_id": "060576782980d5762f9ec014dd2f1148",            "project_id": "060576782980d5762f9ec014dd2f1148",            "device_id": "ab7ca781-66bf-48a8-814b-1568cb393a38",            "device_owner": "compute:xxx",            "security_groups": [                "0552091e-b83a-49dd-88a7-4a5c86fd9ec3"            ],            "extra_dhcp_opts": [],            "allowed_address_pairs": [{              "ip_address": "1.1.1.1/0"          }],            "binding:vnic_type": "normal",            "binding:vif_details": {                "primary_interface": true            },            "binding:profile": {},            "port_security_enabled": true,            "dns_assignment": [                {                    "hostname": "ip-172-16-0-191",                    "ip_address": "172.16.0.191",                    "fqdn": "ip-172-16-0-191.br-iaas-odin1.compute.internal."                }            ],            "dns_name": "ip-172-16-0-191",            "created_at": "2020-11-19T13:32:37",            "updated_at": "2020-11-19T13:33:50"     }  }
      • 请求异常时,错误码请参见错误码
support.huaweicloud.com/api-vpc/vpc_apieg_0006.html