Reverse DNS with Static IP while using Azure Resource Manager - azure

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!

If you've already created a static public IP and want to add reverse DNS to it:
Using Azure Powershell:
Login to azure subscription using:
login-azurermaccount
Select the subscription using:
select-azurermsubscription -subscriptionname mysubscription
Get the IP using:
$p = get-azurermpublicipaddress -name myipname -resourcegroupname myresourcegroupname
Set the reversedns (ensuring your forward DNS is set first) using:
$p.dnssettings.reversefqdn = "mail.mydomain.com"
Finalize the setting using:
set-azurermpublicipaddress -publicipaddress $p

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).
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!!!
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
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:
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.

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

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).

Related

traffic manager Azure endpoint public IP address

We have 2 IP addresses with DNS name but in different Azure subscription. Currently we want to add both Public IP address in one traffic manager endpoint.
But when we start to select public IP address, it only display candidate IP address in current subscription, while can't see IP address in other subscripion.
Is there any way that can add Public IP address in other subscription to this traffic manager endpoint?
Thanks.
We can make this through PowerShell CLI:
New-AzTrafficManagerEndpoint -EndpointStatus Enabled -Name "EndpointName" -ProfileName "TrafficManagerProfileName" -ResourceGroupName "ResourceGroupName" -Type AzureEndpoints -Priority -TargetResourceId ""

Azure VM public static outbound IP

I have written a small service to grab files from one ftp server, edit them, and then send them to another ftp server. The catch being the ftp server being sent to requires a white-list of IP's. Now I chose to host this service on a Azure VM set up with a virtual public reserved IP address, thinking it would create a static IP that I could use for the white-list.
Unfortunately even though the VM states the virtual public reserved IP is connected to the VM, when opening up a browser and going to whatismyip.com I get a completely different IP and of course Azure shuts all VMs down once every 2-3 months for maintenance (which I assume flushes the IP).
Now I understand that the IP received from whatismyip.com is probably connected to the Azure load balancer but I can't figure out for the life of me why that would be the one that shows up for outbound connections.
My questions are:
Is it possible to obtain a static public IP for outbound connections for that whitelist?
Is there some obvious workaround I'm missing?
Will Azure scheduled maintenance shutdowns save IP information?
Is Azure just not a good platform for this kind of work? If so what is?
Now it is indeed possible. Please see https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-reserved-public-ip/ for details.
The powershell code is as follows:
New-AzureReservedIP –ReservedIPName MyReservedIP –Location "Central US"
$image = Get-AzureVMImage|?{$_.ImageName -like "*RightImage-Windows-2012R2-x64*"}
New-AzureVMConfig -Name TestVM -InstanceSize Small -ImageName $image.ImageName `
| Add-AzureProvisioningConfig -Windows -AdminUsername adminuser -Password MyP#ssw0rd!! `
| New-AzureVM -ServiceName TestService -ReservedIPName MyReservedIP -Location "Central US"
Besides, now outbound connections only use a handful IPs by default. You can see them in new portal: https://portal.azure.com in site's Settings → Properties

azure existing vpn and gateway, add address space

I have an existing side-to-side connectivity azure gateway with one local network having three different address spaces to connect to the intranet of a customer. This is up and running, working like a charm.
Now I have the necessity for a fourth address space. I did add it, closed the gateways' connection and created it again. It doesn't look like the new address space is being considered.
Is it really necessary to remove and recreate the whole gateway, pass over the newly created key to the customer to make this working? I couldnt find anything in the documentation of Azure here.
Thanks for any hints.
If you have a gateway connection and want to add or remove the IP address prefixes contained in your local network gateway, you need to do the following steps, in order. This results in some downtime for your VPN connection. When modifying IP address prefixes, you don't need to delete the VPN gateway. You only need to remove the connection.
To modify local network gateway IP address prefixes - existing gateway connection
Remove the connection.
Remove-AzureRmVirtualNetworkGatewayConnection -Name MyGWConnectionName -ResourceGroupName MyRGName
Modify the address prefixes for your local network gateway.
Set the variable for the LocalNetworkGateway
$local = Get-AzureRmLocalNetworkGateway -Name MyLocalNetworkGWName -ResourceGroupName MyRGName
Modify the prefixes.
Set-AzureRmLocalNetworkGateway -LocalNetworkGateway $local `
-AddressPrefix #('10.0.0.0/24','20.0.0.0/24','30.0.0.0/24')
Create the connection. In this example, we configure an IPsec connection type. When you recreate your connection, use the connection type that is specified for your configuration. For additional connection types, see the PowerShell cmdlet page.
Set the variable for the VirtualNetworkGateway.
$gateway1 = Get-AzureRmVirtualNetworkGateway -Name RMGateway -ResourceGroupName MyRGName
Create the connection. This example uses the variable $local that you set in step 2.
New-AzureRmVirtualNetworkGatewayConnection -Name MyGWConnectionName `
-ResourceGroupName MyRGName -Location 'West US' `
-VirtualNetworkGateway1 $gateway1 -LocalNetworkGateway2 $local `
-ConnectionType IPsec `
-RoutingWeight 10 -SharedKey 'abc123'
Two things:
The gateway needs to recreated, just close/ recreate connection does not help. For recreation of the gateway the new preshared key has to be passed over to the owner of the network again.
the user interface of the address spaces is implemented in a strange way. It only allows the last address to be edited. To edit a previous one, the other(s) have to be removed.

Azure VM: Adding a Reserved IP address to an existing VM

What I have read so far on the web is that there is no way to add a reserved IP to an existing VM (unless I recreate the VM which I am trying to avoid). However, I have noticed that external IP of my VM and the cloud service is same.
Reserved IP Addresses page explains how to "To use a Reserved IP with Cloud Services". I have looked everywhere in the Azure Management Portal but couldn't find a configuration setting for Service Configuration Schema.
I am using the Azure scheduler to turn-off the VMs at night and on the weekends. From the following I understand is that there is something that I need to write in the scheduler script to re-assign the Reserved IP when the VM starts in the morning. Did I get it right?
Shutdown VM - Previously, when all the Virtual Machine instances in a
cloud service were moved to the Shutdown state (stop/deallocated), the
public IP would be released and a new public IP would be assigned when
one of the Virtual Machines instances was started. However, with this
release, if the VM uses a Reserved IP, then the Reserved IP can be
used when re-deploying the VMs.
P.S. Is Stack Overflow the best place to ask this sort of questions relating to Azure or shall I use Server Fault in the future? I have seen Azure questions in both websites.
At Build 2015 they announced this is now possible and VERY easy.
Simply open Azure powershell and run this:
New-AzureReservedIP -ReservedIPName "ipname" -Location "West US" -ServiceName "somevm"
If you run this it will reserve an IP named "ipname" and associate it with the already deployed instance "somevm.cloudapp.net"
In order to assign existing reserved IP to an existing VM, you can use the following command:
Set-AzureReservedIPAssociation -ReservedIPName MyReservedIP -ServiceName TestService
Step by step to create Reserved IP and using it on Azure VM. Here you can go
Reserved IP Creation
I have done the Elastic IP Automatic scheduling on AWS.Here is the reference link Elastic IP Automation on AWS script.
Between needs to check about How can I write a script for automating the reserved IP for Azure.If you had done it earlier, Kindly share the script this will be very useful. Thanks.
At this point, we don't support the capability to associate a Reserved IP to an already existing VM.
We are currently working on the capability to reserve the IP of an existing VM.
Ref: http://azure.microsoft.com/blog/2014/05/14/reserved-ip-addresses/
http://www.petri.com/how-to-reserve-public-virtual-ip-addresses-in-microsoft-azure.htm
Girish Prajwal
For new VMs (with resource manager) you should do the following:
Create new static IP address:
$ip = New-AzureRmPublicIpAddress -Name "<ip-name>" -ResourceGroupName <group-name> -Location eastus -AllocationMethod Static
Get information about VM Network Interface:
Get-AzureRmVM -ResourceGroupName <group-name> -Name <vm-name> | Select -ExpandProperty NetworkProfile
Get corresponding network interface and set new ip and update NIC:
$netInt = Get-AzureRmNetworkInterface -ResourceGroupName "group-name" -Name <nic-name>
$netInt.IpConfigurations[0].PublicIpAddress = $ip
Set-AzureRmNetworkInterface -NetworkInterface $netInt
I read all of the previous entries and did not come away with a clear picture of how to proceed with assigning a reserved IP address to my existing Azure classic VM, so I opened a support ticket. I got excellent clear guidance from "Sruthi Saranya K", a support engineer in Azure Networking. Sruthi stated "in classic deployment model it is not possible to have a static public IP assigned to a VM", which I had read elsewhere, but she clarified that you simply assign the IP address to the cloud service and not the VM directly, then the VM will automatically pick up on the change. I outline all of the commands here for your convenience, starting from an Azure PowerShell prompt. The critical command was specified in the top response here, but not all of the steps. Also, that example also includes specifying the service, but it does not appear to be a supported parameter for that command, instead there is a second command to associate the IP with the service.
add-azureaccount (to log in to Azure from PowerShell)
New-AzureReservedIP -ReservedIPName "ipname" -Location "East US"
get-azurereservedip (just to see what the reserved IP address is)
Set-AzureReservedIPAssociation -ReservedIPName "ipname" -ServiceName "your cloud service name"
Also, depending on the use, you may want to look up the IP address on mxtoolbox.com to make sure it is not already blacklisted. My reserved IP was for a web site, but the default # DNS entry for the domain meant our domain was generally going to be associated with that IP address, and previously our mail has been blacklisted because our web server IP address was sullied by some other Azure tenant. If you get a blacklisted address, you can remove it and get a new one, also a suggestion from Sruthi. Here are the commands to remove the reserved IP, and to remove the cloud service association if needed:
remove-azurereservedip
Remove-AzureReservedIPAssociation
My sincere thanks to Sruthi for making it so simple and preventing an unnecessary redeployment of our company's public web server.
Add Public IP to an Existing VM
Log into the portal
Find the Resource Group (RG) where your VM is Located
Confirm your VM has a network interface - if not, create one (it should have one)
Create a Public IP Address (static or dynamic, doesn't matter) by adding one to your RG from the marketplace (do this first so it is creating while you make your NSG).
Create a Network Service Group by adding one to your RG from the marketplace and associating it with your VM.
Once the NSG has deployed, go back to the Overview of your PIP and click the "Associate" button in the info section of the blade.
Select the Network Interface of your VM you validated in step 3.
Get a cup of coffee or something, it will be a minute, but otherwise you're done.
New-AzureReservedIP -ReservedIPName "nameIP" -Location "East US" -ServiceName "azureA2vm"
Get this:
New-AzureReservedIP : A parameter cannot be found that matches parameter name 'ServiceName'.
At line:1 char:70
+ New-AzureReservedIP -ReservedIPName "nameIP" -Location "East US" -ServiceNam ...
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-AzureReservedIP], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.NewAzureReservedIPCmdlet
Check PowerShell version. Update to latest version.

Static IP address for Role in Windows Azure?

Does anyone knows if obtaining a static IP address for a Web or Worker Role on Windows Azure is possible (possibly only in private beta)?
A few years later, Azure now lets you reserve IP addresses for VMs and cloud services (Web and Worker roles). However, it is only accessible from PowerShell for the time being (this will change in the future, apparently).
The first five static IP addresses are free. To create an IP you will need to make sure you have the latest version of the Azure PowerShell command-line interface and also have your Azure account linked to Azure PowerShell (outside the scope of this post but not hard).
To Create a new IP in PowerShell:
$ReservedIP = New-AzureReservedIP -ReservedIPName "FirewallIP" -Label "WebAppFirewallIP" -Location "Japan West"
To associate it with a VM:
New-AzureVMConfig -Name "WebAppVM" -InstanceSize Small -ImageName $images[60].ImageName | Add-AzureProvisioningConfig -Windows -AdminUsername cloudguy -Password Abc123 | New-AzureVM -ServiceName "WebApp" –ReservedIPName $ReservedIP -Location "Japan West"
To insert your new IP into a Web or Worker Role (if the worker role has an external endpoint), add the following to ServiceConfiguration.Cloud.cscfg:
<ServiceConfiguration>
<NetworkConfiguration>
<AddressAssignments>
<ReservedIPs>
<ReservedIP name="<reserved-ip-name>"/>
</ReservedIPs>
</AddressAssignments>
</NetworkConfiguration>
</ServiceConfiguration>
To view an IP at any time:
Get-AzureReservedIP -ReservedIPName "FirewallIP"
Source: Documentation
There's an update to this story. Back in October 2011, Microsoft announced improved in-place updates to existing deployed services (announcement here). You can now update your deployment in several ways without having the assigned IP address changed. For example:
Grow/shrink Role size
Increase local storage size
Change endpoints
Add / remove roles
Once you deploy: As long as you don't delete your deployment, your IP address will stay as-is.
Unfortunately, this is not possible for the time being... If you need to do IP-based access control, you could open a support call and request the current IP address range for a given datacenter, but there is no real guarantee it won't change over time.

Resources