IBM Cloud Docs
管理 DNS 記錄

管理 DNS 記錄

DNS 記錄會在人類可讀名稱與 IP 位址之間建立連線。 我們涵蓋下列區段中如何管理 DNS 記錄。 使用 UI、CLI 或 API 管理 DNS 記錄。

在主控台中新增 DNS 記錄

  1. 從 DNS 區域表格中,按一下您要新增記錄的區域名稱。 即會出現所選取區域的更多詳細資料。
  2. 按一下 新增記錄,以顯示您可以在其中建立記錄的畫面。

您可以使用類型功能表選擇要建立的記錄類型。 每一筆 DNS 記錄類型都具有相關聯的「名稱」及「存活時間 (TTL)」。

當您在名稱欄位中輸入名稱時,如果您未手動新增網域名稱,則會自動附加網域名稱。 例如,如果您在「名稱」欄位中鍵入 wwwwww.example.com,則 API 會將這兩個項目處理為 www.example.com。 如果您在名稱欄位中輸入確切的網域名稱,則它不會附加至本身 (例如,example.com 會處理為 example.com)。 不過,DNS 記錄清單只會顯示名稱,而不會新增網域名稱。 因此,www.example.com 會顯示為 www,而 example.com 會顯示為 example.com

支援的 TTL 值下限為 1 min,而上限為 12 hours。 TTL 的預設值為 15 min,但使用者可以變更它。

在主控台中新增 A 類型記錄

若要新增此記錄類型,名稱IPv4 位址欄位中必須要有有效值。 從清單功能表中指定 TTL 值,預設值為 15 min

必要欄位

  • 名稱
  • IPv4 位址
  • TTL (預設值為 15 分鐘)

在主控台中新增 AAAA 類型記錄

若要新增此記錄類型,名稱IPv6 位址欄位中必須要有有效值。 從清單功能表中指定 TTL 值,預設值為 15 min

必要欄位

  • 名稱
  • IPv4 位址
  • TTL (預設值為 15 分鐘)

在主控台中新增 CNAME 類型記錄

若要新增此記錄類型,Name 欄位中必須存在有效值,且 Target (FQDN) 欄位中必須有完全合格的網域名稱。 也可以從清單功能表指定 TTL,預設值為 15 min

必要欄位

  • 名稱
  • 目標 (適用於 CNAME)
  • TTL (預設值為 15 分鐘)

在主控台中新增 MX 類型記錄

若要新增此記錄類型,名稱 欄位中必須存在有效值,郵件伺服器 (FQDN) 欄位中必須存在完整網域名稱,優先順序 欄位中必須存在有效數字。 從清單功能表中指定 TTL 值,預設值為 15 min

必要欄位

  • 名稱
  • 郵件伺服器
  • TTL (預設值為 15 分鐘)
  • 優先順序 (預設值為 1)

在主控台中新增 PTR 類型記錄

若要新增此記錄類型,您必須具有尚未與另一個 PTR 記錄相關聯的現有 A 或 AAAA 記錄。 從清單選單中選擇現有記錄。 從清單功能表中指定 TTL 值,預設值為 15 min

必要欄位

  • 選取現有記錄
  • TTL (預設值為 15 分鐘)

在主控台中新增 SRV 類型記錄

若要新增此記錄類型,「名稱」、「服務名稱」和「目標」欄位必須存在有效值。 使用清單功能表選擇通訊協定,預設為 UDP 通訊協定。 此外,您可以指定優先順序權重。 這三個欄位預設為 1 值。 從清單功能表中指定 TTL 值,預設值為 15 min

必要欄位

  • 名稱
  • 服務名稱
  • 目標
  • TTL (預設值為 15 分鐘)
  • 通訊協定 (預設值為 UDP)
  • 優先順序 (預設值為 1)
  • 重量 (預設值為 1)
  • 連接埠(預設值為 1)

在主控台中新增 TXT 類型的記錄

若要新增此記錄類型,名稱內容欄位中必須要有有效值。 從清單功能表中指定 TTL 值,預設值為 15 min

基於安全及隱私權理由,建議您不要對機密資料使用 TXT 類型記錄。

必要欄位

  • 名稱
  • 内容
  • TTL (預設值為 15 分鐘)

在主控台中更新 DNS 記錄

在每一個記錄列中,按一下 編輯 圖示以開啟一個畫面,您可以在其中更新記錄。

在主控台中刪除 DNS 記錄

在每一個記錄列中,按一下 刪除 圖示以開啟一個畫面,您可以在其中確認刪除處理程序。

在主控台中匯入資源記錄

若要匯入資源記錄,請採取下列步驟:

  1. 從 DNS Services 實例中,選取您要匯入記錄的區域

  2. 按一下區域詳細資料區段中的 選取記錄動作,然後選擇 匯入記錄

  3. 您可以將匯入檔案拖放至出現的畫面,或按一下要從電腦上傳的鏈結

    匯入檔案必須是純文字格式,且不能超過 8 MB

  4. 按一下 匯入記錄

您的匯入檔案應該遵循下列範例格式:

www.test.com.  900 IN  A   127.0.0.1
www.test.com.  900 IN  AAAA    ::1
w3.test.com.   900 IN  CNAME   mydomain.com.
www.test.com.  900 IN  MX  1 mail.example.com.
_service._tcp.www.sample.com.   900 IN  SRV 1 1 1 mydomain.com.
www.test.com.  900 IN  TXT "my content"

匯入記錄之後,您可以檢閱匯入狀態的詳細資料,包括順利上傳的檔案數目以及無法上傳哪些記錄。 如果您需要上傳其他檔案,請按一下 上傳其他檔案,然後重複匯入步驟。 按一下畫面右上方的 X 圖示,以關閉匯入畫面。

在主控台中輸出資源記錄

若要匯出資源記錄,請採取下列步驟:

  1. 從 DNS Services 實例中,選取您要從中匯出記錄的區域
  2. 按一下區域詳細資料區段中的 選取記錄動作,然後選擇 匯出記錄
  3. 輸入匯出檔的名稱,或接受預設名稱 records.txt
  4. 按一下下載

匯出的檔案會下載至瀏覽器指定的預設下載位置。

從 CLI 管理 DNS 記錄

首先,請使用 ibmcloud dns instance-target 指令來設定目標作業 DNS Services 實例。

$ ibmcloud dns instances
Retrieving service instances for service 'dns-svcs' ...
OK

Name                 ID                                     Location   State    Service Name
DNS Services-km      ffffffff-b042-41fd-885e-000000000000   global     active   dns-svcs

$ ibmcloud dns instance-target "DNS Services-km"

將區域 ID 儲存在變數中,以便您可以在下列指令中使用它,而不必每次都鍵入它。 例如,若要將區域 ID 儲存在變數中,請執行此指令:

DNS_ZONE_ID="example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae"

從 CLI 建立類型 A 資源記錄

搭配使用 ibmcloud dns resource-record-create 指令與 --type A 選項,以建立類型 A 資源記錄。--name--ipv4 是必要選項。

$ ibmcloud dns resource-record-create $DNS_ZONE_ID --type A --name www --ipv4 192.168.1.100
Creating resource record in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

ID            A:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6
Name          www.example.com
Type          A
Created On    2020-04-10 09:12:07.858707275 +0000 UTC
Modified On   2020-04-10 09:12:07.858707275 +0000 UTC
TTL           900
Data
    ip        192.168.1.100

從 CLI 建立類型「SRV」資源記錄

搭配使用 ibmcloud dns resource-record-create 指令與 --type SRV 選項,以建立類型 SRV 資源記錄。--name--service--protocol--target 是必要選項。

$ ibmcloud dns resource-record-create $DNS_ZONE_ID --type SRV --name video --service _sip --protocol tcp --priority 10 --weight 10 --port 953 --target media.example.com
Creating resource record in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

ID             SRV:c7c8938b-87c7-4aee-95fa-63f28452c8d4
Name           _sip._tcp.video.example.com
Type           SRV
Created On     2020-04-10 09:15:56.940189115 +0000 UTC
Modified On    2020-04-10 09:15:56.940189115 +0000 UTC
TTL            900
Data
    port       953
    priority   10
    target     media.example.com
    weight     10

從 CLI 建立類型“TXT”資源記錄

搭配使用 ibmcloud dns resource-record-create 指令與 --type TXT 選項,以建立類型 TXT 資源記錄。--name--text 是必要選項。

$ ibmcloud dns resource-record-create $DNS_ZONE_ID --type TXT --name text --text "This is a text record."
Creating resource record in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

ID            TXT:92648285-c7e5-49ef-bf8b-a5be91d5c5d3
Name          text.example.com
Type          TXT
Created On    2020-04-10 09:16:50.169135062 +0000 UTC
Modified On   2020-04-10 09:16:50.169135062 +0000 UTC
TTL           900
Data
    text      This is a text record.

從 CLI 建立類型「MX」資源記錄

搭配使用 ibmcloud dns resource-record-create 指令與 --type MX 選項,以建立類型 MX 資源記錄。--name--exchange 是必要選項。

$ ibmcloud dns resource-record-create $DNS_ZONE_ID --type MX --name mail --preference 10 --exchange exchange.example.com
Creating resource record in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

ID               MX:900750bf-881d-402f-a482-20447f2e64a2
Name             mail.example.com
Type             MX
Created On       2020-04-10 09:18:08.299278244 +0000 UTC
Modified On      2020-04-10 09:18:08.299278244 +0000 UTC
TTL              900
Data
    preference   10
    exchange     exchange.example.com

從 CLI 建立類型「PTR」資源記錄

搭配使用 ibmcloud dns resource-record-create 指令與 --type PTR 選項,以建立類型 PTR 資源記錄。--name--ptrdname 是必要選項。

$ ibmcloud dns resource-record-create $DNS_ZONE_ID --type PTR --name 192.168.1.100 --ptrdname www.example.com
Creating resource record in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

ID             PTR:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6
Name           192.168.1.100
Type           PTR
Created On     2020-04-10 09:34:49.722454606 +0000 UTC
Modified On    2020-04-10 09:34:49.722454606 +0000 UTC
TTL            900
Data
    ptrdname   www.example.com

從 CLI 建立類型「CNAME」資源記錄

搭配使用 ibmcloud dns resource-record-create 指令與 --type CNAME 選項,以建立類型 CNAME 資源記錄。--name--cname 是必要選項。

$ ibmcloud dns resource-record-create $DNS_ZONE_ID --type CNAME --name web --cname www.example.com
Creating resource record in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

ID            CNAME:6e80f079-effd-409a-a520-b8c1b10f6e6e
Name          web.example.com
Type          CNAME
Created On    2020-04-10 09:36:13.186040793 +0000 UTC
Modified On   2020-04-10 09:36:13.186040793 +0000 UTC
TTL           900
Data
    cname     www.example.com

從 CLI 建立類型「AAAA」資源記錄

搭配使用 ibmcloud dns resource-record-create 指令與 --type AAAA 選項,以建立類型 AAAA 資源記錄。--name--ipv6 是必要選項。

$ ibmcloud dns resource-record-create $DNS_ZONE_ID --type AAAA --name www --ipv6 2019::2020
Creating resource record in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

ID            AAAA:37e1e701-e549-4ca1-8c22-86574bf4aaed
Name          www.example.com
Type          AAAA
Created On    2020-04-10 09:37:15.063814601 +0000 UTC
Modified On   2020-04-10 09:37:15.063814601 +0000 UTC
TTL           900
Data
    ip        2019::2020

從 CLI 取得資源記錄

使用後面接著區域 ID 及資源記錄 ID 的 ibmcloud dns resource-record 指令,以取得資源記錄的詳細資料。

$ ibmcloud dns resource-record $DNS_ZONE_ID A:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6
Getting resource record 'A:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6' in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

ID            A:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6
Name          www.example.com
Type          A
Created On    2020-04-10 09:12:07.858707275 +0000 UTC
Modified On   2020-04-10 09:34:49.986883927 +0000 UTC
TTL           900
Data
    ip        192.168.1.100

從 CLI 列出資源記錄

使用 ibmcloud dns resource-records 指令後接區域 ID,以列出所有資源記錄。

$ ibmcloud dns resource-records $DNS_ZONE_ID
Listing resource records in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK
ID                                           Name                          Type    TTL
AAAA:37e1e701-e549-4ca1-8c22-86574bf4aaed    www.example.com               AAAA    900
CNAME:6e80f079-effd-409a-a520-b8c1b10f6e6e   web.example.com               CNAME   900
MX:900750bf-881d-402f-a482-20447f2e64a2      mail.example.com              MX      900
TXT:92648285-c7e5-49ef-bf8b-a5be91d5c5d3     text.example.com              TXT     900
SRV:c7c8938b-87c7-4aee-95fa-63f28452c8d4     _sip._tcp.video.example.com   SRV     900
A:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6       www.example.com               A       900
PTR:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6     192.168.1.100                 PTR     900

從 CLI 更新資源記錄

使用 ibmcloud dns resource-record-update 指令,後面接著區域 ID 及資源記錄 ID,以更新資源記錄。

$ ibmcloud dns resource-record-update $DNS_ZONE_ID A:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6 --name www --ipv4 10.10.1.1
Updating resource record 'A:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6' in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

ID            A:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6
Name          www.example.com
Type          A
Created On    2020-04-10 09:12:07.858707275 +0000 UTC
Modified On   2020-04-10 09:40:55.204076727 +0000 UTC
TTL           900
Data
    ip        10.10.1.1

從 CLI 中刪除資源記錄

使用後面接著區域 ID 和資源記錄 ID 的 ibmcloud dns resource-record-delete 指令來刪除資源記錄。

$ ibmcloud dns resource-record-delete $DNS_ZONE_ID PTR:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6
Really delete resource record 'PTR:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6' in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km'? [y/N]> y
Deleting resource record 'PTR:f20cfe91-b936-4bad-a8d1-f7afa4ac32a6' in zone 'example.com:f7f40364-a5e6-48f7-9fc9-387434c579ae' for service instance 'DNS Services-km' ...
OK

使用 API 管理 DNS 記錄

首先將 API 端點儲存在變數中,這樣您就可以在 API 請求中使用它,而不必輸入完整的 URL。 例如,若要將生產端點儲存於變數中,請執行此指令:

DNSSVCS_ENDPOINT=https://api.dns-svcs.cloud.ibm.com

要驗證這個變數是否已儲存,請執行 echo $DNSSVCS_ENDPOINT,並確保回應不是空的。

使用 API 建立類型 A 資源記錄

要求

curl -X POST \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records \
  -H "Authorization: $TOKEN" \
  -d '{
    "name":"www.example.com",
    "type":"A",
    "rdata": {
            "ip":"1.2.6.7"
        },
    "ttl":300
}'

回應

{
    "id": "fa57d5d0-7729-4770-af27-6d7f8dce860c",
    "created_on": "2019-08-12 08:03:03.910471016 +0000 UTC",
    "modified_on": "2019-08-12 08:03:03.910471016 +0000 UTC",
    "rtype": "A",
    "ttl": 300,
    "name": "www.example.com",
    "id": "A:fa57d5d0-7729-4770-af27-6d7f8dce860c",
    "rdata": {
        "ip": "1.2.6.7"
    }
}

使用 API 建立類型「SRV」資源記錄

要求

curl -X POST \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records \
  -H "Authorization: $TOKEN" \
  -d '{
    "type": "SRV",
    "name": "example.com",
    "service": "srv",
    "protocol": "udp",
    "rdata": {
        "priority": 100,
        "weight": 100,
        "port": 8000,
        "target": "siphost.com"
    }
}'

回應

{
    "created_on": "2019-08-16 08:07:41.113606 +0000 UTC",
    "modified_on": "2019-08-16 08:07:41.113606 +0000 UTC",
    "rtype": "SRV",
    "ttl": 60,
    "name": "example.com",
    "id": "SRV:7562b1f9-1a6a-4189-b794-dd84c91d6a28",
    "rdata": {
        "priority": 100,
        "weight": 100,
        "port": 8000,
        "target": "siphost.com"
    },
    "service": "srv",
    "protocol": "udp"
}

使用 API 建立類型“TXT”資源記錄

要求

curl -X POST \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records \
  -H "Authorization: $TOKEN" \
  -d '{
    "type": "TXT",
    "name": "txt.example.com",
    "rdata": {
        "txtdata": "txt strings"
    }
}'

回應

{
    "created_on": "2019-08-16 08:15:53.360664 +0000 UTC",
    "modified_on": "2019-08-16 08:15:53.360664 +0000 UTC",
    "rtype": "TXT",
    "ttl": 60,
    "name": "txt.example.com",
    "id": "TXT:c6221d5f-69d7-4717-9951-4f69b2680fd4",
    "rdata": {
        "txtdata": "txt strings"
    }
}

使用 API 建立類型“MX”資源記錄

要求

curl -X POST \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records \
  -H "Authorization: $TOKEN" \
  -d '{
    "type": "MX",
    "name": "mx1.example.com",
    "rdata": {
        "exchange": "mailserver.example.com",
        "preference": 10
    }
}'

回應

{
    "created_on": "2019-08-16 08:21:20.308716 +0000 UTC",
    "modified_on": "2019-08-16 08:21:20.308716 +0000 UTC",
    "rtype": "MX",
    "ttl": 60,
    "name": "mx1.example.com",
    "id": "MX:8e1b201e-00dd-46a0-a3ec-46573f908870",
    "rdata": {
        "preference": 10,
        "exchange": "mailserver.example.com"
    }
}

使用 API 建立類型“PTR”資源記錄

要求

curl -X POST \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records \
  -H "Authorization: $TOKEN" \
  -d '{
    "type": "PTR",
    "name": "192.168.10.100",
    "rdata": {
       "ptrdname": "www1.example.com"
    }
}'

回應

{
    "created_on": "2019-08-30 06:48:16.971764628 +0000 UTC",
    "modified_on": "2019-08-30 06:48:16.971764628 +0000 UTC",
    "rtype": "PTR",
    "ttl": 60,
    "name": "100.10.168.192.in-addr.arpa",
    "id": "PTR:a47dd63a-e65a-4280-8f53-3cdb433cc78a",
    "rdata": {
        "ptrdname": "www1.example.com"
    }
}

使用 API 建立類型“CNAME”資源記錄

要求

curl -X POST \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records \
  -H "Authorization: $TOKEN" \
  -d '{
    "type": "CNAME",
    "name": "cname.example.com",
    "rdata": {
       "cname": "clientinterface.com"
    }
}'

回應

{
    "created_on": "2019-08-16 08:29:36.710416 +0000 UTC",
    "modified_on": "2019-08-16 08:29:36.710416 +0000 UTC",
    "rtype": "CNAME",
    "ttl": 60,
    "name": "cname.example.com",
    "id": "CNAME:c95916ba-5504-499a-943a-21f5befe92b5",
    "rdata": {
        "cname": "clientinterface.com"
    }
}

使用 API 建立類型「AAAA」資源記錄

要求

curl -X POST \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records \
  -H "Authorization: $TOKEN" \
  -d '{
    "type": "AAAA",
    "name": "test.example.com",
    "rdata": {
       "ip": "8000::2000"
    }
}'

回應

{
    "created_on": "2019-08-16 08:34:38.311539 +0000 UTC",
    "modified_on": "2019-08-16 08:34:38.311539 +0000 UTC",
    "rtype": "AAAA",
    "ttl": 60,
    "name": "test.example.com",
    "id": "AAAA:894e165b-f066-434d-9b58-4afc2dca62c9",
    "rdata": {
        "ip": "8000::2000"
    }
}

使用API取得資源記錄

要求

curl -X GET \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records/$RECORD_ID \
  -H "Authorization: $TOKEN"

回應

{
    "created_on": "2019-08-12 08:03:03.910471016 +0000 UTC",
    "modified_on": "2019-08-12 08:03:32.875065176 +0000 UTC",
    "rtype": "A",
    "ttl": 300,
    "name": "www.example.com",
    "id": "A:fa57d5d0-7729-4770-af27-6d7f8dce860c",
    "rdata": {
        "ip": "9.4.6.7"
    }
}

使用 API 列出資源記錄

要求

curl -X GET \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records?limit=50&offset=0 \
  -H "Authorization: $TOKEN"

回應

{
    "offset": 0,
    "limit": 50,
    "total_count": 1,
    "first": {
      "href": "https://api.dns-svcs.cloud.ibm.com/v1/instances/ec0c4ee2-5d1f-4066-bcf2-dc9f3122c638/dnszones/example.com:4759caa4-d4fa-4fb9-7848-f463de19b392/resource_records?limit=50"
    },
    "resource_records": [
        {
            "created_on": "2019-08-30 04:10:25.092468565 +0000 UTC",
            "modified_on": "2019-08-30 04:10:25.092468565 +0000 UTC",
            "rtype": "A",
            "ttl": 60,
            "name": "www.example.com",
            "id": "A:ec0c4ee2-5d1f-4066-bcf2-dc9f3122c639",
            "rdata": {
                "ip": "192.168.10.100"
            }
        }
    ]
}

使用 API 更新資源記錄

要求

curl -X PUT \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records/$RECORD_ID \
  -H "Authorization: $TOKEN" \
  -d '{
    "name":"www",
    "rdata": {
            "ip":"7.7.7.7"
        },
    "ttl":300
}'

回應

{
    "created_on":"2019-09-10 20:03:25.249355942 +0000 UTC",
    "modified_on":"2019-09-11 16:13:17.350043736 +0000 UTC",
    "rtype":"A",
    "ttl":300,
    "name":"www",
    "id":"A:139eb9f3-c646-4eb6-92fa-3ddabfb1b84f",
    "rdata":{
        "ip":"7.7.7.7"
    }
}

使用 API 刪除資源記錄

要求

curl -X DELETE \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/resource_records/$RECORD_ID \
  -H "Authorization: $TOKEN"

回應

HTTP 204 is returned, no content in response.

使用 API 從 DNS 區域檔案匯入批次資源記錄

要求

curl -X POST \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/import_resource_records --form "file=@./bind.cfg" \
  -H "Authorization: $TOKEN"

回應

{
    "total_records_parsed": 17,
    "records_added": 17,
    "records_failed": 0,
    "records_added_by_type": {
        "A": 10,
        "AAAA": 2,
        "CNAME": 4,
        "SRV": 0,
        "TXT": 0,
        "MX": 0,
        "PTR": 1
    },
    "records_failed_by_type": {
        "A": 0,
        "AAAA": 0,
        "CNAME": 0,
        "SRV": 0,
        "TXT": 0,
        "MX": 0,
        "PTR": 0
    },
    "message": null,
    "errors": null
}

使用 API 將批次資源記錄匯出到 DNS 區域文件

要求

curl -X GET \
  $DNSSVCS_ENDPOINT/v1/instances/$INSTANCE_ID/dnszones/$DNSZONE_ID/export_resource_records -o dns_records.cfg \
  -H "Authorization: $TOKEN"

回應

HTTP 200 is returned with zone file content in byte format