將 Google Domains DNS 設定遷移至 Cloud DNS 或其他供應商

如果您使用 Google Domains 做為 DNS 供應商,本頁面說明如何遷移 Google Domains DNS 設定,以及匯出網域和電子郵件轉寄設定。

事前準備

確認你是否使用 Google Domains 做為 DNS 供應商,以及是否已設定網域或電子郵件轉寄。

主控台

  1. 前往 Google Cloud 控制台的「Cloud Domains」頁面。

    前往「Cloud Domains」頁面

    「Registrations」(註冊) 頁面會列出您的註冊項目。

  2. 按一下要取得資訊的網域名稱。

    你可以查看特定網域是否使用 Google Domains 做為 DNS 供應商,或是網域是否已設定網域或電子郵件轉寄。

gcloud

如要查看特定網域的註冊詳細資料,請使用 gcloud domains registrations describe 指令

gcloud domains registrations describe DOMAIN_NAME

DOMAIN_NAME 替換為要查看詳細資料的網域名稱,例如 example.app

如果網域使用 Google Domains 做為 DNS 供應商,輸出內容的 dnsSettings 部分會類似下列範例:

dnsSettings:
    googleDomainsDns:

如果網域使用網域或電子郵件轉寄設定,輸出內容的 dnsSettings 部分會類似下列範例:

dnsSettings:
    ...
    googleDomainsRedirectsDataAvailable: true

將 Google Domains DNS 設定遷移至 Cloud DNS

如要遷移 Google Domains DNS 設定,請按照下列步驟操作。

gcloud

  1. 為網域建立代管公開區域。

    使用 dns managed-zones create 指令

    gcloud dns managed-zones create ZONE_NAME \
        --description=DESCRIPTION \
        --dns-name=DOMAIN_NAME \
        --visibility=public \
        [--labels=LABELS] \
        [--dnssec-state=DNSSEC_STATE]
    

    更改下列內容:

    • ZONE_NAME:可用區名稱
    • DESCRIPTION:區域說明
    • DOMAIN_NAME:您區域的網域名稱,例如 example.com。如要使用網域名稱的 DNS 區域,請務必確認區域中的 DNS 字尾與網域名稱相符。請注意,example.comexample.com. 視為等效。
    • LABELS:以逗號分隔的鍵/值組合清單,例如 dept=marketingproject=project1。這個旗標是選用的。 詳情請參閱 SDK 說明文件
    • DNSSEC_STATE:您區域的 DNSSEC 狀態。詳情請參閱 DNS 安全性擴充功能 (DNSSEC) 總覽。這個旗標是選用的。
  2. 為網域停用 DNSSEC。

    如果已啟用 DNSSEC,請停用並等待 24 小時,讓變更生效。

    使用 gcloud domains registrations configure dns 指令

    gcloud domains registrations configure dns DOMAIN_NAME \
        --disable-dnssec
    

    DOMAIN_NAME 替換為要停用 DNSSEC 的網域名稱

  3. 從 Google Domains DNS 區域擷取 DNS 記錄資訊。

    使用 gcloud domains registrations google-domains-dns export-dns-record-sets 指令

    gcloud domains registrations google-domains-dns export-dns-record-sets DOMAIN_NAME \
        --records-file=RECORDS_FILE \
        --zone-file-format
    

    更改下列內容:

    • DOMAIN_NAME:要擷取 DNS 記錄資訊的網域名稱
    • RECORDS_FILE:要匯出記錄集的檔案,例如 records.zonefile
  4. 將記錄匯入 Cloud DNS 區域。

    使用 dns record-sets import 指令--zone-file-format 標記會將 import 指令設為使用 BIND 區域檔案。如果省略這個標記,import 會使用 YAML 檔案:

    gcloud dns record-sets import RECORDS_FILE \
        --zone=ZONE_NAME \
        --zone-file-format \
        --delete-all-existing
    

    更改下列內容:

    • RECORDS_FILE:要匯入記錄集的檔案,例如 records.zonefile
    • ZONE_NAME:要管理記錄集的代管區域名稱
  5. 開始使用已遷移的 Cloud DNS 區域。

    使用 gcloud domains registrations configure dns 指令:

    gcloud domains registrations configure dns DOMAIN_NAME \
        --cloud-dns-zone=ZONE_NAME
    

    更改下列內容:

    • DOMAIN_NAME:註冊網域名稱,例如 example.app
    • ZONE_NAME:要管理記錄集的代管區域名稱
  6. 監控網域。如果遇到任何 DNS 設定問題,請回溯遷移作業。

    使用 gcloud domains registrations configure dns 指令:

    gcloud domains registrations configure dns DOMAIN_NAME --use-google-domains-dns
    

    DOMAIN_NAME 替換為註冊的網域名稱,例如 example.app

  7. 選用:為網域啟用 DNSSEC。

    1. 完成步驟 5 後,請等待至少 24 小時。
    2. 使用 gcloud domains registrations configure dns 指令:
    gcloud domains registrations configure dns DOMAIN_NAME \
      --cloud-dns-zone=ZONE_NAME \
      --no-disable-dnssec
    

    更改下列內容:

    • DOMAIN_NAME:註冊網域名稱,例如 example.app
    • ZONE_NAME:要停用 DNSSEC 的代管區域名稱

將網域和電子郵件轉寄設定匯出至其他代管服務供應商

gcloud

  1. 為網域停用 DNSSEC。

    如果已啟用 DNSSEC,請先停用,並等待 24 小時,變更才會生效。

    使用 gcloud domains registrations configure dns 指令

    gcloud domains registrations configure dns DOMAIN_NAME \
        --disable-dnssec
    

    更改下列內容:

    • DOMAIN_NAME:要停用 DNSSEC 的網域名稱
  2. 匯出 Google Domains DNS 設定。

    使用 gcloud domains registrations google-domains-dns export-dns-record-sets 指令

    gcloud domains registrations google-domains-dns export-dns-record-sets DOMAIN_NAME \
        --records-file=RECORDS_FILE \
        --zone-file-format
    

    更改下列內容:

    • DOMAIN_NAME:要擷取 DNS 記錄資訊的網域名稱
    • RECORDS_FILE:記錄集必須匯出的檔案,例如 records.zonefile
  3. 擷取 Google Domains 網域和電子郵件轉寄設定。

    使用 gcloud domains registrations google-domains-dns get-forwarding-config 指令

    gcloud domains registrations google-domains-dns get-forwarding-config DOMAIN_NAME
    

    DOMAIN_NAME 替換為註冊的網域名稱,例如 example.app

  4. 將 DNS 記錄和轉寄設定匯入新的代管服務供應商。如需操作說明,請與代管服務供應商聯絡。

  5. 為新的代管服務供應商設定網域和轉寄設定。如需操作說明,請與代管服務供應商聯絡。

    如果您有 MXCNAME 記錄,請務必設定這些記錄,將服務重新導向至新的主機供應商。

  6. 更新網域的名稱伺服器。你可以向新的代管服務供應商索取名稱伺服器資訊。

    使用 gcloud domains registrations configure dns 指令:

    gcloud domains registrations configure dns DOMAIN_NAME \
        --name-servers=NAME_SERVERS_LIST
    

    NAME_SERVERS_LIST 替換為網域的 DNS 名稱伺服器清單。

  7. 監控網域。如果遇到任何 DNS 設定問題,請回溯遷移作業。

    使用 gcloud domains registrations configure dns 指令:

    gcloud domains registrations configure dns DOMAIN_NAME --use-google-domains-dns
    
  8. 選用:在代管服務供應商處為 DNS 區域啟用 DNSSEC。

    1. 為 DNS 區域啟用 DNSSEC 後,請等待 24 小時。
    2. 為網域啟用 DNSSEC。

      使用 gcloud domains registrations configure dns 指令:

      gcloud domains registrations configure dns DOMAIN_NAME \
          --dns-settings-from-file=DNS_SETTINGS_FILE_NAME
      

      更改下列內容:

      • DOMAIN_NAME:註冊網域名稱,例如 example.app
      • DNS_SETTINGS_FILE_NAME:包含必要 DNS 設定的 YAML 檔案。如果指定,其內容會取代註冊資源中使用的值。如果 YAML 檔案缺少部分 dns_settings 欄位,系統會移除這些欄位。

        檔案內容範例:

        customDns:
            nameServers:
            - new.ns1.com
            - new.ns2.com
            dsRecords:
            - keyTag: 24
              algorithm: RSASHA256
              digestType: SHA256
              digest: ab1cfa82b035c26cbbbdae632cea070514eb8b773f616aaeaf668e2f0be8f10d
        

後續步驟