Kelly Trinh
Kelly Trinh

Reputation: 363

Azure Reverse DNS not possible for dynamic IPs?

I am running a hobby mail server under the Azure Free Tier.

One requirement is to have the reverse DNS of the IP matching the hostname otherwise aggressive anti spam mail servers will reject messages from my mail server (eg gmail).

From https://learn.microsoft.com/en-us/azure/dns/dns-reverse-dns-for-azure-services it states that (my emphasis)

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.

I verified the A records are correctly resolving the FQDN to the IP in question via an nslookup.

However when following the instructions - I get following error message:

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.

Note the error message is slightly different from the documentation - That is the "A" records method is only possible where a static IP is involved. I have also tried setting the IP to 'static' and it does start working. However, a static IP is chargeable so this would defeat the purpose of the hobby mail server so not an option for ongoing basis.

Is the MS documentation wrong or am I missing a step for setting up the up the reverse DNS?


Supplementary Info

Steps to reproduce the error message

1. Verify A records correct

nslookup [domain I want]

output - shows the IP of my VM

So "A" records resolve correctly.

2. Try to set when the reverse DNS

(this is basically the steps in the documentation link above)

$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. Changing IP type to static

Adding the following line to the block above will allow the reverse DNS to be set (but not what I want!)

$pip.PublicIpAllocationMethod = "Static"

Upvotes: 1

Views: 802

Answers (1)

Nancy Xiong
Nancy Xiong

Reputation: 28224

After my validation, you don't need to change the IP allocation method to static. The correct command is as below:

$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

Please note that you only could select the DomainNameLabel in the FQDN. When the public IP address is assigned to your network interface in the Azure portal, it belongs to a region. The FQDN should match the region of Public IP resources like somednslabel.region.cloudapp.azure.com.

If I just arbitrarily type the ReverseFqdn, it will reproduce the error message. Please check if you have typed the correct ReverseFqdn.

enter image description here

Update

After my validation, you could use the CNAME record as condition 2 in the error message. If you use A record, it needs a static public IP resource.

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

Steps:

  1. Create default azure provided FQDN like qaz.eastus.cloudapp.azure.com. of the public IP address as the above commands.

  2. Create a CNAME record pointing your custom hostname to this FQDN in your DNS zone. I use Azure DNS zone in my example. enter image description here

  3. Add the custom hostname in the ReverseFqdn.

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

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

    Set-AzPublicIpAddress -PublicIpAddress $pip

    enter image description here

Upvotes: 1

Related Questions