

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Resolver 委派規則教學課程
<a name="outbound-delegation-tutorial"></a>

 委派規則允許 VPC Resolver 透過指定的傳出端點到達託管委派區域的名稱伺服器。雖然轉送規則會通知 VPC Resolver 透過傳出端點將 DNS 查詢轉送至符合指定網域的名稱伺服器，但委派規則會通知 VPC Resolver 透過傳回委派 NS 記錄時指定的傳出端點到達委派名稱伺服器。當 DNS 回應中的 NS 記錄符合委派記錄中指定的網域名稱時，VPC Resolver 會將查詢傳送至委派名稱伺服器。

## 使用解析程式端點傳出委派的步驟
<a name="delegation-steps"></a>

1. 在 VPC 中建立解析程式傳出端點，您希望 DNS 查詢從該端點傳到您網路上的解析程式。

   您可以使用下列 API 或 CLI 命令：
   + [`CreateResolverEndpoint` API](https://docs.aws.amazon.com/Route53/latest/APIReference/API_route53resolver_CreateResolverEndpoint.html)
   + [`create-resolver-endpoint` CLI](https://docs.aws.amazon.com/cli/latest/reference/route53resolver/create-resolver-endpoint.html)

1. 建立一或多個委派規則，指定應透過指定傳出端點將查詢委派給網路的網域名稱。

   使用 CLI 建立委派規則的範例：

   ```
   aws route53resolver create-resolver-rule \
   --region REGION \
   --creator-request-id delegateruletest \
   --delegation-record example.com \
   --name delegateruletest \
   --rule-type DELEGATE \
   --resolver-endpoint-id outbound endpoint ID
   ```

1. 將委派規則與您希望委派查詢VPCs 建立關聯。

   您可以使用下列 API 或 CLI 命令：
   + [AssociateResolverRule](https://docs.aws.amazon.com/Route53/latest/APIReference/API_route53resolver_AssociateResolverRule.html) API。
   + [associate-resolver-rules](https://docs.aws.amazon.com/cli/latest/reference/route53resolver/associate-resolver-rule.html) CLI 命令。

## Resolver 傳出端點支援的委派類型
<a name="delegation-types"></a>

VPC Resolver 支援兩種類型的傳出委派：
+ 將 53 個私有託管區域路由至 VPC Resolver 傳出委派：

   使用傳出委派，將子網域從私有託管區域委派給內部部署 DNS 伺服器或網際網路上的公有託管區域。此傳出委派可讓您在私有託管區域與委派區域之間分割 DNS 記錄的管理。您可以根據您的 DNS 設定，在私有託管區域中使用或不使用黏附記錄來完成委派。如需詳細資訊，請參閱 [傳出的私有託管區域](#phz-to-outbound-delegation)。
+ VPC Resolver 傳出至傳出委派：

   使用傳出至傳出委派，將子網域從您的內部部署 DNS 伺服器委派至相同或不同位置的另一個內部部署伺服器。這類似於從私有託管區域委派至傳出端點，您可以在其中委派至內部部署名稱伺服器上託管的區域。如需更多資訊，請參閱[傳出至傳出](#outbound-to-outbound-delegation)。

### 將 53 個私有託管區域路由至 VPC Resolver 傳出委派範例組態
<a name="phz-to-outbound-delegation"></a>

 假設 DNS 設定，其中父託管區域託管在 Amazon VPC 的 Route 53 私有託管區域中，而子網域委派給在歐洲、亞洲和北美洲託管的伺服器。所有 DNS 查詢都會透過 VPC Resolver 傳遞。

請依照範例步驟來設定私有託管區域和 VPC Resolver。

**設定用於傳出委派的私有託管區域**

1. 對於私有託管區域設定：

   父託管區域： `hr.example.com`

   ```
   $TTL    86400 ; 24 hours
   $ORIGIN hr.example.com
   @  1D  IN     SOA @    root (20200322001 3H 15 1w 3h)
   @  1D  IN  NS @
   eu.hr.example.com IN NS ns1.eu.hr.example.com.
   apac.hr.example.com IN NS ns2.apac.hr.example.com.
   na.hr.example.com IN NS ns3.na.hr.example.net. # Out of Zone Delegation
   
   ns1.eu.hr.example.com IN A 10.0.0.30 # Glue Record
   ns2.apac.hr.example.com IN A 10.0.0.40 # Glue Record
   ```

1. 對於歐洲內部部署區域中的內部部署名稱伺服器：
   + 託管區域：`eu.hr.example.com`NS IP： `10.0.0.30`

   ```
   $TTL    86400 ; 24 hours
   $ORIGIN eu.hr.example.com
   @  1D  IN     SOA @    root (20200322001 3H 15 1w 3h)
   @  1D  IN  NS @
   
   test.eu.hr.example.com IN A 1.2.3.4
   ```

1. 對於亞洲內部部署區域中的內部部署名稱伺服器：

   託管區域：`apac.hr.example.com`、 `10.0.0.40`

   apac 名稱伺服器可以將子網域委派給其他名稱伺服器。

   ```
   $TTL    86400 ; 24 hours
   $ORIGIN apac.hr.example.com
   @  1D  IN     SOA @    root (20200322001 3H 15 1w 3h)
   @  1D  IN  NS @
   
   test.apac.hr.example.com IN A 5.6.7.8
   engineering.apac.hr.example.com IN NS ns1.engineering.apac.hr.example.com
   sales.apac.hr.example.com IN NS ns2.sales.apac.hr.example.com
   ns1.engineering.apac.hr.example.com IN A 10.0.0.80
   ns2.sales.apac.hr.example.com IN A 10.0.0.90
   ```

   託管區域：`engineering.apac.hr.example.com`、 `10.0.0.80`

   ```
   $TTL 86400 ; 24 hours
   $ORIGIN engineering.apac.hr.example.com
   @ 1D IN SOA @ root (20200322001 3H 15 1w 3h)
   @ 1D IN NS @
   test.engineering.apac.hr.example.com IN A 1.1.1.1
   ```

1. 對於北美內部部署區域中的內部部署名稱伺服器：

   託管區域：`na.hr.example.net`NS IP： `10.0.0.50`

   ```
   $TTL    86400 ; 24 hours
   $ORIGIN na.hr.example.net
   @  1D  IN     SOA @    root (20200322001 3H 15 1w 3h)
   @  1D  IN  NS @
   ns3.na.hr.example.net. IN A 10.0.0.50
   test.na.hr.example.com  IN A 9.10.11.12
   ```

**VPC 解析程式設定**
+ 對於 VPC Resolver，您需要設定一個轉送規則和兩個委派規則：

  **轉送規則**

  1. 若要轉送out-of-zone委派記錄，Route 53 VPC Resolver 會知道委派 NS 的 IP 來轉送初始請求。

     domain-name：`hr.example.net`target-ips： `10.0.0.50`

  **委派規則**

  1. 區域內委派的委派規則：

     委派記錄： `hr.example.com`

  1. 區域外委派的委派規則：

     委派記錄： `hr.example.net`

### 傳出至傳出委派範例組態
<a name="outbound-to-outbound-delegation"></a>

 假設父託管區域位於中央內部部署位置，且子網域正委派給在歐洲、亞洲和北美洲託管的名稱伺服器，而不是在 Amazon VPC 中擁有父託管區域。所有 DNS 查詢都會透過 VPC Resolver 傳遞。

請依照範例步驟來設定您的現場部署 DNS 和 VPC Resolver。

**設定內部部署 DNS**

1. 對於中央內部部署區域中的內部部署名稱伺服器：
   + **父託管區域：** `hr.example.com`

     託管區域 `hr.example.com`，NS IP： `10.0.0.20`

   ```
   $TTL    86400 ; 24 hours
   $ORIGIN hr.example.com
   @  1D  IN     SOA @    root (20200322001 3H 15 1w 3h)
   @  1D  IN  NS @
   eu.hr.example.com IN NS ns1.eu.hr.example.com.
   apac.hr.example.com IN NS ns2.apac.hr.example.com.
   na.hr.example.com IN NS ns3.na.hr.example.net. # Out of zone delegation
   
   ns1.eu.hr.example.com IN A 10.0.0.30 # Glue record
   ns2.apac.hr.example.com IN A 10.0.0.40 # Glue record
   ```

1.  對於歐洲內部部署區域中的內部部署名稱伺服器 （歐洲、亞洲和北美洲名稱伺服器的組態與私有託管區域對傳出委派的組態相同）：
   + 託管區域：`eu.hr.example.com`NS IP： `10.0.0.30`

   ```
   $TTL    86400 ; 24 hours
   $ORIGIN eu.hr.example.com
   @  1D  IN     SOA @    root (20200322001 3H 15 1w 3h)
   @  1D  IN  NS @
   
   test.eu.hr.example.com IN A 1.2.3.4
   ```

1. 對於亞洲內部部署區域中的內部部署名稱伺服器：

   託管區域：`apac.hr.example.com`、 `10.0.0.40`

   apac 名稱伺服器可以將子網域委派給其他名稱伺服器。

   ```
   $TTL    86400 ; 24 hours
   $ORIGIN apac.hr.example.com
   @  1D  IN     SOA @    root (20200322001 3H 15 1w 3h)
   @  1D  IN  NS @
   
   test.apac.hr.example.com IN A 5.6.7.8
   engineering.apac.hr.example.com IN NS ns1.engineering.apac.hr.example.com
   sales.apac.hr.example.com IN NS ns2.sales.apac.hr.example.com
   ns1.engineering.apac.hr.example.com IN A 10.0.0.80
   ns2.sales.apac.hr.example.com IN A 10.0.0.90
   ```

   託管區域：`engineering.apac.hr.example.com`、 `10.0.0.80`

   ```
   $TTL 86400 ; 24 hours
   $ORIGIN engineering.apac.hr.example.com
   @ 1D IN SOA @ root (20200322001 3H 15 1w 3h)
   @ 1D IN NS @
   test.engineering.apac.hr.example.com IN A 1.1.1.1
   ```

1. 對於北美內部部署區域中的內部部署名稱伺服器：

   託管區域：`na.hr.example.net`NS IP： `10.0.0.50`

   ```
   $TTL    86400 ; 24 hours
   $ORIGIN na.hr.example.net
   @  1D  IN     SOA @    root (20200322001 3H 15 1w 3h)
   @  1D  IN  NS @
   ns3.na.hr.example.net. IN A 10.0.0.50
   test.na.hr.example.com  IN A 9.10.11.12
   ```

**VPC 解析程式設定**
+ 對於 VPC 解析程式，您需要設定轉送規則和委派規則：

  **轉送規則**

  1. 若要轉送初始請求，將查詢轉送至`hr.example.com`中央位置的父託管區域：

     domain-name：`hr.example.com`target-ips： `10.0.0.20`

  1. 若要轉送out-of-zone委派記錄，VPC Resolver 會知道委派名稱伺服器的 IP 地址，以轉送初始請求：

     domain-name：`hr.example.net`target-ips： `10.0.0.50`

  **委派規則**

  1. 區域內委派的委派規則：

     委派記錄： `hr.example.com`

  1. 區域外委派的委派規則：

     委派記錄： `hr.example.net`