

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

# 在 Amazon EC2 上建立電子郵件的反向 DNS 記錄
<a name="Using_Elastic_Addressing_Reverse_DNS"></a>

如果您打算從 EC2 執行個體傳送電子郵件給第三方，我們建議您佈建一或多個彈性 IP 位址，並將靜態反向 DNS 紀錄指派給用於傳送電子郵件的彈性 IP 位址。這可協助您避免某些反垃圾郵件組織將您的電子郵件標記為垃圾郵件。 會與 ISPs和網際網路反垃圾郵件組織 AWS 合作，以減少從這些地址傳送的電子郵件被標記為垃圾郵件的機會。

**考量事項**
+ 建立反向 DNS 紀錄之前，您必須設定對應的轉寄 DNS 紀錄 (紀錄類型 A)，並指向您的彈性 IP 位址。
+ 如果反向 DNS 記錄與彈性 IP 位址相關聯，該彈性 IP 位址會鎖定到您的帳戶，而且在移除記錄之前都無法從您的帳戶釋放。
+ 如果您聯絡 支援 為彈性 IP 地址設定反向 DNS，您可以移除反向 DNS，但無法釋出彈性 IP 地址，因為它已被 鎖定 支援。若要解除彈性 IP 位址的鎖定，請聯絡 [AWS 支援](https://console.aws.amazon.com/support/home#/)。彈性 IP 位址解除鎖定後，您可以將其釋放。
+ 您無法使用主控台或AWS GovCloud (US) Region建立反向 DNS 記錄。 AWS 必須為您指派靜態反向 DNS 記錄。開啟支援案例以移除反向 DNS 和電子郵件傳送限制。必須提供彈性 IP 位址和反向 DNS 記錄。

## 建立反向 DNS 記錄
<a name="eip-create-rdns-record"></a>

您可以建立彈性 IP 位址的反向 DNS 紀錄，如下所示。

------
#### [ Console ]

**若要建立反向 DNS 記錄**

1. 前往 [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/) 開啟 Amazon EC2 主控台。

1. 在導覽窗格中，選擇 **Elastic IPs** (彈性 IP)。

1. 選取彈性 IP 位址，然後選取 **Actions** (動作)、**Update reverse DNS** (更新反向 DNS)。

1. 針對 **Reverse DNS domain name** (反向 DNS 網域名稱)，輸入網域名稱。

1. 輸入 **update** 以確認。

1. 選擇 **Update** (更新)。

------
#### [ AWS CLI ]

**若要建立反向 DNS 記錄**  
使用 [https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-address-attribute.html](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-address-attribute.html) 命令。

```
aws ec2 modify-address-attribute \
    --allocation-id eipalloc-abcdef01234567890 \
    --domain-name example.com
```

以下為範例輸出。

```
{
    "Addresses": [
        {
            "PublicIp": "192.0.2.0",
            "AllocationId": "eipalloc-abcdef01234567890",
            "PtrRecord": "example.net.",
            "PtrRecordUpdate": {
                "Value": "example.com.",
                "Status": "PENDING"
            }
        }
    ]
}
```

------
#### [ PowerShell ]

**若要建立反向 DNS 記錄**  
使用 [https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2AddressAttribute.html](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2AddressAttribute.html) cmdlet。

```
Edit-EC2AddressAttribute `
    -AllocationId 'eipalloc-abcdef01234567890' `
    -DomainName 'example.com' |
Format-List `
    AllocationId, PtrRecord, PublicIp,
    @{Name='PtrRecordUpdate';Expression={$_.PtrRecordUpdate | Format-List | Out-String}}
```

以下為範例輸出。

```
AllocationId    : eipalloc-abcdef01234567890
PtrRecord       : example.net.
PublicIp        : 192.0.2.0
PtrRecordUpdate : 
                  Reason :
                  Status : PENDING
                  Value  : example.com.
```

------

## 移除反向 DNS 記錄
<a name="eip-remove-rdns-record"></a>

您可以從彈性 IP 位址移除反向 DNS 記錄，如下所示。

如果您收到下列錯誤，您可以向 提交[移除電子郵件傳送限制的請求](https://repost.aws/knowledge-center/ec2-port-25-throttle) 支援 ，以尋求協助。

```
The address cannot be released because it is locked to your account.
```

------
#### [ Console ]

**若要移除反向 DNS 記錄**

1. 前往 [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/) 開啟 Amazon EC2 主控台。

1. 在導覽窗格中，選擇 **Elastic IPs** (彈性 IP)。

1. 選取彈性 IP 位址，然後選取 **Actions** (動作)、**Update reverse DNS** (更新反向 DNS)。

1. 針對 **Reverse DNS domain name** (反向 DNS 網域名稱)，清除相應的網域名稱。

1. 輸入 **update** 以確認。

1. 選擇 **Update** (更新)。

------
#### [ AWS CLI ]

**若要移除反向 DNS 記錄**  
使用 [https://docs.aws.amazon.com/cli/latest/reference/ec2/reset-address-attribute.html](https://docs.aws.amazon.com/cli/latest/reference/ec2/reset-address-attribute.html) 命令。

```
aws ec2 reset-address-attribute \
    --allocation-id eipalloc-abcdef01234567890 \
    --attribute domain-name
```

以下為範例輸出。

```
{
    "Addresses": [
        {
            "PublicIp": "192.0.2.0",
            "AllocationId": "eipalloc-abcdef01234567890",
            "PtrRecord": "example.com.",
            "PtrRecordUpdate": {
                "Value": "example.net.",
                "Status": "PENDING"
            }
        }
    ]
}
```

------
#### [ PowerShell ]

**若要移除反向 DNS 記錄**  
使用 [https://docs.aws.amazon.com/powershell/latest/reference/items/Reset-EC2AddressAttribute.html](https://docs.aws.amazon.com/powershell/latest/reference/items/Reset-EC2AddressAttribute.html) cmdlet。

```
Reset-EC2AddressAttribute `
    -AllocationId 'eipalloc-abcdef01234567890' `
    -Attribute domain-name |
Format-List `
    AllocationId, PtrRecord, PublicIp,
    @{Name='PtrRecordUpdate';Expression={$_.PtrRecordUpdate | Format-List | Out-String}}
```

以下為範例輸出。

```
AllocationId    : eipalloc-abcdef01234567890
PtrRecord       : example.com.
PublicIp        : 192.0.2.0
PtrRecordUpdate : 
                  Reason :
                  Status : PENDING
                  Value  : example.net.
```

------