Help Center/ Cloud Data Center / API Reference/ API/ iMetal Instance Management/ Changing the IP Address of an Instance
Updated on 2025-12-12 GMT+08:00

Changing the IP Address of an Instance

Function

This API is used to select a specified iMetal instance and change its IP address.

The iMetal instance must be ready (commissioned successfully) or the IP address fails to be changed and the iMetal instance is powered off.

Calling Method

For details, see Calling APIs.

URI

PUT /v1/{project_id}/instances/{id}/ip

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID.

Constraints

N/A

Range

Project ID of the account.

Default Value

N/A

id

Yes

String

Definition

Instance ID, which is returned in the response to the CreateInstance request.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

Requests for calling an API can be authenticated using a token. If token-based authentication is used, this parameter is mandatory and must be set to a user token.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

vpc_id

No

String

Definition

ID of the VPC which the network interface to be created belongs to. You can query the ID using the VPC API: https://support.huaweicloud.com/intl/en-us/api-vpc/vpc_api01_0003.html.

Constraints

N/A

Range

VPC ID

Default Value

N/A

nics

No

Array of Nic objects

Definition

NIC information.

Constraints

N/A

Table 4 Nic

Parameter

Mandatory

Type

Description

subnet_id

Yes

String

Definition

ID of the CloudDCN subnet which the created network interface belongs to. You can query the ID using the CloudDCN API: https://support.huaweicloud.com/intl/en-us/api-vpc/vpc_subnet01_0003.html.

Constraints

N/A

Range

ID of the CloudDCN subnet.

Default Value

N/A

ip_address

No

String

Definition

Static IP address specified during network interface creation. This parameter is invalid during batch installation. If this parameter is left blank or set to "", an unused IP address in the subnet is automatically assigned. If this parameter is specified, its value must be an unused IP address in the CIDR block of the subnet.

Constraints

N/A

Range

Static IP address of the subnet.

Default Value

N/A

Response Parameters

Status code: 202

The IP address of the instance has been changed.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

error_msg

String

Definition

Error description.

Status code: 401

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

error_msg

String

Definition

Error description.

Status code: 429

Table 7 Response body parameters

Parameter

Type

Description

-

String

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

error_msg

String

Definition

Error description.

Example Requests

Changing the IP address of an instance

PUT https://{endpoint}/v1/{project_id}/instances/{id}/ip

Example Responses

None

Status Codes

Status Code

Description

202

The IP address of the instance has been changed.

400

Invalid request parameter.

401

The request is not authenticated.

429

The request is overloaded.

500

Internal server error.

Error Codes

See Error Codes.