Casey Crookston
Casey Crookston

Reputation: 13945

Reverse DNS with Static IP while using Azure Resource Manager

I am very much aware that Reverse DNS is possible on Azure Cloud Services. That's not what I'm asking about. I need to know if it's possible when using Azure Resource Manager. I've looked around a lot online, and while I've found some (2+ year) old questions about it, I can't find any answers.

Thanks!

Upvotes: 2

Views: 6797

Answers (4)

Chris seigman
Chris seigman

Reputation: 21

Joe Who's answer worked perfectly for me, and was simpler than creating a temporary IP (I already had an existing one, plus I would have had to mess with my DNS settings for the 3rd time in a week).

mysubscription is your subscription type - in my case, it's "Pay-As-You-Go", which you can find in your Azure portal settings.

myipname is the name of your IP address resource, and myresourcegroupname is the name of the resource group that it's in. for the domain, I just entered "mydomain.com" (with my actual doman, of course).

Aside from the nightmare that was getting Azure PowerShell working, the whole thing took about 5 minutes.

Reverse DNS lookup is now functioning and my emails are no longer getting bounced as spam (there is more to set up of course other than this, but I'd already jumped through those hoops).

Upvotes: 2

Casey Crookston
Casey Crookston

Reputation: 13945

Ok, while the other two answers were helpful, neither got me all the way there. But I finally figured this out. Many shouts to Michael B who has been a HUGE help!

The domain I used to learn and play is woodswild.com. If you want to follow along with these steps, just swap out as needed. Hope this helps save someone some time. It took me WAY WAY too long to figure this out.

One more thing: These steps assume you are NOT using a template.

1: Open Windows Azure Powershell

2: Inside Powershell, log in to your account with this command:

Login-AzureRMAccount

This will prompt you for a log in and password.

3: Create a Resource Group.

You can do this in the UI if you want, or in Powershell. This is the command if you want to do it in Powershell:

$rgName="RG1"
$locName="Central US"
New-AzureRmResourceGroup -Name $rgName -Location $locName

4: Create a Temporary Public IP Address:

The process of creating a Public IP Address with fully qualified Reverse DNS lookup (ReverseFqdn) is wonky. The first thing we have to do is create a temp (throwaway) Public IP Address withOUT a ReverseFqdn. Do that with this command:

$ipName = "tempRG1PIP"
$locName = "Central US"
$rgName = "RG1"
New-AzureRmPublicIpAddress -AllocationMethod Static -ResourceGroupName $rgName -Name $ipName  -Location $locName

In this example, the domain I'm playing with is "woodswild.com". After running this command, go to the UI and under the Configuration for the IP Address you just created, give the IP address a DNS label of "tempwoodswild" (or whatever you want for your domain).

enter image description here

5: Create a CName record

For the domain you are setting up with Reverse DNS, log into your registrar. Go to the section where you manage your DNS records for your domain. Create a CName record with the host of "www" (or mail, if you are setting up a mail server) which points to "tempwoodswild.centralus.cloudapp.azure.com" (or to whatever DNS label you created.)

6. Create Another (Permanent) Public IP Address

Now that we have www.woodswild.com (or mail.woodswild.com) pointing to the temp IP address, we can create a perm one.

$ipName = "RG1PIP"
$locName = "Central US"
$rgName = "RG1"
$rvFqdn = "www.woodswild.com" (or mail...)
$dnLabel = "woodswild"
New-AzureRmPublicIpAddress -Name $ipName -ResourceGroupName $rgName -Location $locName -ReverseFqdn $rvFqdn -AllocationMethod Static -DomainNameLabel $dnLabel

You now have a Static, Public IP Address with a ReverseFqdn!!!

enter image description here

7. Delete the temp IP Address

You can do this in the Azure Portal UI. At this point, in Azure, you should have a Resource Group with only one item in it: Your Public IP Address

enter image description here

8. Edit the CName record, and create an A (Host) Record.

Back in your registrar, edit the CName to be: woodswild.centralus.cloudapp.azure.com

Also, create an A(Host) record as follows:

Host: @
Points To: 40.122.166.144 (which is the IP of the new, perm, Public IP Address)

9. Test the ReverseIP Lookup:

At this point, you should be able to do a reverse lookup on the IP and get the domain:

enter image description here

Tip: At any time, you can see the info from this IP address with this command:

New-AzureRmPublicIpAddress -Name RG1PIP -ResourceGroupName RG1

Creating a Virtual Machine with the Public IP Address

From here, creating a virtual machine that is assigned your public (static) IP with Reverse Lookup capabilities is just a matter of associating the VM with the IP you just created.

Upvotes: 6

Joe Who
Joe Who

Reputation: 269

If you've already created a static public IP and want to add reverse DNS to it:

Using Azure Powershell:

  1. Login to azure subscription using: login-azurermaccount
  2. Select the subscription using: select-azurermsubscription -subscriptionname mysubscription
  3. Get the IP using: $p = get-azurermpublicipaddress -name myipname -resourcegroupname myresourcegroupname
  4. Set the reversedns (ensuring your forward DNS is set first) using: $p.dnssettings.reversefqdn = "mail.mydomain.com"
  5. Finalize the setting using: set-azurermpublicipaddress -publicipaddress $p

Upvotes: 10

Michael B
Michael B

Reputation: 12228

Registering a reverse DNS in Azure is complicated by the fact that you need to have a forward A record pointing into an IP address before you can register the reverse. i.e. you need to register www.example.com to point to an IP address in Azure before you can register the reverse address.

That means that if you are creating via template, you need to pre-configure a forward domain else the template will fail.

So presuming you are using a template there are a few steps you need to perform beforehand.

Create an Azure static address - this needs to be static since we're not going to allocate it to a machine. If we created a dynamic address it wouldn't be available until it was attached.

 $ip = New-AzureRmPublicIpAddress -Name TestIP1 `
                -ResourceGroupName $ResourceGroupName `
                -Location $location -AllocationMethod Static 

Register the address you get above from $ip.IpAddress in DNS

www IN A 123.45.67.89 ;; $ip.IpAddress address 

Run deployment script, if using a template

    "properties": {
    "publicIPAllocationMethod": "Dynamic",
    "dnsSettings": {
        "domainNameLabel": "[variables('PublicDNS2')]",
        "ReverseFqdn": "[concat(parameters('vmName2'), '.', variables('domainname'))]"
    }

Point forward domain to new address (this can be retrieved as an output from a template)

www IN A 123.45.67.90 ;; Deployment IP Address 

Finally delete the temporary IP Address

Remove-AzureRmPublicIpAddress -Name TestIP1 `
         -ResourceGroupName $ResourceGroupName -Force 

Upvotes: 2

Related Questions