快速入門導覽課程:使用 Cloud DNS 設定網域名稱的 DNS 記錄

本頁面說明如何為您的網域名稱設定 Cloud DNS 代管區域及資源記錄,其中提供的範例將說明如何建立代管區域,然後設定網域的位址 (A) 和正式名稱 (CNAME) 記錄。


如要直接在 Google Cloud 控制台按照逐步指南操作,請按一下「Guide me」(逐步引導)

逐步引導


詳情請參閱下列資源:

需求條件

本快速入門導覽課程假設您已具備下列條件:

事前準備

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Make sure that you have the following role or roles on the project: Service Usage Admin, DNS Administrator

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      前往「IAM」頁面
    2. 選取專案。
    3. 按一下「授予存取權」
    4. 在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。

    5. 在「Select a role」(選取角色) 清單中,選取角色。
    6. 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
    7. 按一下 [Save]
  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Make sure that you have the following role or roles on the project: Service Usage Admin, DNS Administrator

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      前往「IAM」頁面
    2. 選取專案。
    3. 按一下「授予存取權」
    4. 在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。

    5. 在「Select a role」(選取角色) 清單中,選取角色。
    6. 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
    7. 按一下 [Save]
  8. Enable the DNS API.

    Enable the API

在 Cloud DNS 中建立代管的公開可用區

  1. 前往 Google Cloud 控制台的「建立 DNS 區域」頁面。

    前往「建立 DNS 區域」

  2. 如要建立公開 DNS 可用區,請按一下「Create zone」(建立可用區)

  3. 在「Zone type」(可用區類型) 中選擇「Public」(公開)

  4. 「Zone name」(可用區名稱) 欄位中輸入 my-new-zone

  5. 「DNS name」(DNS 名稱) 欄位中輸入您購買的網域名稱。您只需要輸入網域名稱,例如:

    example.com
    
  6. 「DNSSEC」下拉式清單中選取「Off」(停用)

  7. 按一下「Create」(建立)

隨即會顯示「Zone details」(區域詳細資料) 頁面,系統已為您建立預設的 NS 和 SOA 記錄。

如要編輯記錄,請在「區域詳細資料」頁面中,找出要編輯的記錄,然後按一下該列末端的「編輯」

建立記錄,將網域指向外部 IP 位址

如果 IP 位址的格式為 #.#.#.#,則您使用的是 IPv4 位址,必須建立 A 記錄。

如果 IP 位址的格式為 #:#:#:#:#:#:#:#,則您使用的是 IPv6 位址,必須建立 AAAA 記錄。

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

    前往 Cloud DNS

  2. 按一下您要新增記錄集的區域。

  3. 按一下「新增標準」

  4. 在「Resource Record Type」(資源記錄類型) 部分,選取 A 即可建立 A 記錄。如要建立 AAAA 記錄,請選取 AAAA

  5. 在「IPv4 Address」(IPv4 位址) 或「IPv6 Address」(IPv6 位址) 欄位中,輸入要與這個網域搭配使用的 IP 位址。

  6. 點選「建立」

www 子網域建立 CNAME 記錄

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

    前往 Cloud DNS

  2. 按一下您要新增記錄集的區域。

  3. 按一下「新增標準」

  4. 在「DNS Name」(DNS 名稱) 中,輸入 www

  5. 在「Resource Record Type」(資源記錄類型) 部分選取 CNAME

  6. 在「Canonical name」(正規名稱) 中輸入網域名稱,後面加上半形句號 (例如 example.com.)。

  7. 點選「建立」

記錄更新需要一些時間才能傳播完畢,實際的時間長度取決於記錄的存留時間 (TTL) 值。如要驗證 DNS 記錄是否正常運作,請造訪網域名稱,並確認網域是否解析為您的 IP 位址。

為發布網域而更新網域名稱伺服器

最後,您必須更新網域的名稱伺服器以使用 Cloud DNS,才能將新記錄發布至網際網路。

您已成功使用 Cloud DNS 設定 DNS 記錄。

清除所用資源

如要避免系統向您的 Google Cloud 帳戶收取本頁所用資源的費用,請按照下列步驟操作。

  1. 前往 Google Cloud 控制台的「Cloud DNS 區域」頁面。

    前往 Cloud DNS 區域

  2. 按一下區域名稱 (my-new-zone) 前往「Zone details」(區域詳細資料) 頁面。

  3. 選取您建立的 A 和 CNAME 記錄。

  4. 按一下「刪除記錄集」

  5. 前往「Cloud DNS 區域」頁面。

    前往 Cloud DNS 區域

  6. 如要刪除區域,請選取 my-new-zone 核取方塊,然後按一下資料列尾端的「刪除區域」

後續步驟