Updated on 2023-12-06 GMT+08:00

Updating the DNS Server List

Function

This API is used to update the DNS server list.

Debugging

You can debug this API through automatic authentication in or use the SDK sample code generated by API Explorer.

URI

PUT /v1/{project_id}/dns/servers

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

fw_instance_id

No

String

Firewall instance ID, which is automatically generated after a CFW instance is created. You can obtain the ID by calling the API used for querying a firewall instance. For details, see the API Explorer and Help Center FAQ.By default, if fw_instance_Id is not specified, information about the first firewall under the account is returned. If fw_instance_Id is specified, information about the firewall with this fw_instance_Id is returned.If object_Id is specified, information about the firewall with this object_Id is returned by default. If both fw_instance_Id and object_Id are specified, the specified object_Id must belong to the specified firewall.

enterprise_project_id

No

String

Enterprise project id, the id generated by the enterprise project after the user supports the enterprise project.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is a token.

Table 4 Request body parameters

Parameter

Mandatory

Type

Description

dns_server

No

Array of dns_server objects

DNS server

Table 5 dns_server

Parameter

Mandatory

Type

Description

server_ip

No

String

DNS server IP address

is_customized

No

Integer

Indicates whether the DNS server is user-defined. 0: no; 1: yes

is_applied

No

Integer

Indicates whether to apply. 0: no; 1: yes

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

data

Array of strings

Domain name server list

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code

Minimum: 8

Maximum: 36

error_msg

String

Description

Minimum: 2

Maximum: 512

Example Requests

Update the settings of the DNS resolver whose project ID is 2349ba469daf4b7daf268bb0261d18b0. Set server 8.8.8.8 to the default server and put it in use. Set server IP address 192.168.0.2 to a user-defined server and do not put it in use.

https://{Endpoint}/v1/2349ba469daf4b7daf268bb0261d18b0/dns/servers

{
  "dns_server" : [ {
    "server_ip" : "8.8.8.8",
    "is_customized" : 0,
    "is_applied" : 1
  }, {
    "server_ip" : "192.168.0.2",
    "is_customized" : 1,
    "is_applied" : 0
  } ]
}

Example Responses

Status code: 200

Response to the request for updating the DNS server list

{
  "data" : [ "100.95.150.83", "114.114.114.114", "223.5.5.5", "223.6.6.6", "119.29.29.29", "8.8.8.8", "100.79.1.250", "100.79.1.240" ]
}

Status code: 400

Bad Request

{
  "error_code" : "CFW.01000001",
  "error_msg" : "Duplicate DNS server IP address"
}

Status Codes

Status Code

Description

200

Response to the request for updating the DNS server list

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.