动态 IP 无法使用 Azure 反向 DNS?

Azure Reverse DNS not possible for dynamic IPs?

我是 运行 Azure 免费套餐下的业余邮件服务器。

一个要求是让 IP 的反向 DNS 与主机名匹配,否则积极的反垃圾邮件服务器将拒绝来自我的邮件服务器(例如 gmail)的邮件。

来自 https://docs.microsoft.com/en-us/azure/dns/dns-reverse-dns-for-azure-services 它指出(我的重点)

The DNS name for the PublicIpAddress, contosoapp1.northus.cloudapp.azure.com
The DNS name for a different PublicIpAddress in the same subscription, such as contosoapp2.westus.cloudapp.azure.com
A vanity DNS name, such as app1.contoso.com, so long as this name is first configured as a CNAME to contosoapp1.northus.cloudapp.azure.com, or to a different PublicIpAddress in the same subscription.
A vanity DNS name, such as app1.contoso.com, **so long as this name is first configured as an A record** to the IP address 23.96.52.53, or to the IP address of a different PublicIpAddress in the same subscription.

我验证了 A 记录通过 nslookup 正确地将 FQDN 解析为有问题的 IP。

然而,当按照说明操作时 - 我收到以下错误消息:

ErrorMessage: 
ReverseFqdn [[mydomain]]. that PublicIPAddress [[IP resource name]] is trying to use does not belong to subscription [[removed]]. 
One of the following conditions need to be met to establish ownership: 
1) ReverseFqdn matches fqdn of any public ip resource under the subscription; 
2) ReverseFqdn resolves to the fqdn (through CName records chain) of any public ip resource under the subcription; 
3) It resolves to the ip address (through CName and A records chain) of a static public ip resource under the subscription.

请注意,错误消息与文档略有不同 - 即“A”记录方法仅适用于涉及静态 IP 的情况。我还尝试将 IP 设置为 'static',它确实开始工作了。但是,静态 IP 是收费的,因此这会破坏业余邮件服务器的目的,因此不是持续基础的选择。

是 MS 文档有误还是我遗漏了设置反向 DNS 的步骤?


补充信息

重现错误消息的步骤

1。验证 A 记录是否正确

nslookup [我想要的域名]

输出 - 显示我的 VM 的 IP

因此“A”记录正确解析。

2。尝试设置时反向DNS

(这基本上就是上面文档link中的步骤)

$pip = Get-AzPublicIpAddress -ResourceGroupName "Mail_in_a_Box"
$pip.DnsSettings = New-Object -TypeName "Microsoft.Azure.Commands.Network.Models.PSPublicIpAddressDnsSettings"
$pip.DnsSettings.DomainNameLabel = "mydomainlabel"
$pip.DnsSettings.ReverseFqdn = "mydomainname"
Set-AzPublicIpAddress -PublicIpAddress $pip

  1. 正在将 IP 类型更改为静态

将以下行添加到上面的块将允许设置反向 DNS(但不是我想要的!)

$pip.PublicIpAllocationMethod = "Static"

经过我的验证,您不需要将IP分配方式改为静态。正确的命令如下:

$pip = Get-AzPublicIpAddress -Name "PublicIp" -ResourceGroupName "MyResourceGroup"
$pip.DnsSettings = New-Object -TypeName "Microsoft.Azure.Commands.Network.Models.PSPublicIpAddressDnsSettings"
$pip.DnsSettings.DomainNameLabel = "contosoapp1"
$pip.DnsSettings.ReverseFqdn = "contosoapp1.westus.cloudapp.azure.com."
Set-AzPublicIpAddress -PublicIpAddress $pip

请注意,您只能在 FQDN 中 select DomainNameLabel。当 public IP 地址分配给 Azure 门户中的网络接口时,它属于一个区域。 FQDN 应匹配 Public IP 资源的区域,如 somednslabel.region.cloudapp.azure.com.

如果我随便输入 ReverseFqdn,它会重现错误消息。请检查您是否输入了正确的 ReverseFqdn.

更新

经过我的验证,您可以使用CNAME记录作为错误消息中的条件2。如果你使用A记录,它需要一个静态public IP资源。

2) ReverseFqdn resolves to the fqdn (through CName records chain) of any public IP resource under the subscription; 

步骤:

  1. 按照上述命令创建 public IP 地址的默认 azure 提供的 FQDN,如 qaz.eastus.cloudapp.azure.com.

  2. 创建一个 CNAME 记录,将您的自定义主机名指向您 DNS 区域中的这个 FQDN。我在示例中使用 Azure DNS 区域。

  3. ReverseFqdn中添加自定义主机名。

    $pip = Get-AzPublicIpAddress -Name "ubun-pip" -ResourceGroupName "nancytest"

    $pip.DnsSettings.ReverseFqdn = "nancytest.domain.com"

    Set-AzPublicIpAddress -PublicIpAddress $pip