Azure Virtual Network / VM's Setup to Share One Public IP - azure

I've recently setup a point to site VPN on Azure. In doing so I have created:
Azure Virtual Network
Azure Virtual Network Gateway
Azure Virtual Network Gateway IP (static)
Azure VM
I was under the impression that any VM set to use the above said Virtual Network would all share the same public IP? However it appears that the Azure VM i setup is instead using its own dynamic public IP.
Is there a way to route any VM on the Custom Virtual Network I created through one public IP? IF so - how can I do this?
According to your description, you have create a point-to-side VPN. in this scenario, we can remove the public IP addresses from VMs, then you can access your VMs with private IP addresses via VPN.
You are correct - I have the VPN working correctly. My only concern is this, it'd be great that if any of those VM's in that private network shared the same static IP - that way I could grant access to that IP in my firewall to other systems i have in other hosting platforms (as they are all typically locked down by ip).
It sounds like your reference to availablity sets may be the phrase i was looking for to further google.. i will check it out and let me know
please let me know if anything I added above changes your answer/recommendations :)

I was under the impression that any VM set to use the above said
Virtual Network would all share the same public IP?
You are talking about Azure ASM module (classic). In ASM module, VMs can use the same public IP address(NAT).
However it appears that the Azure VM i setup is instead using its own
dynamic public IP.
In Azure resource module, we can create Azure VMs with different Public IP addresses.
Is there a way to route any VM on the Custom Virtual Network I created
through one public IP?
According to your description, you have create a point-to-side VPN. in this scenario, we can remove the public IP addresses from VMs, then you can access your VMs with private IP addresses via VPN.
If you want to access those VMs from Internet and use one public IP address, we can create VMs in the same availability set, and deploy a Internet facing load balancer, then add NAT rules to them, in this way, we can access those VMs use the same public IP address and different ports.

Related

Azure: Multiple VMs behind same public IP?

What is the correct process for getting multiple VMs to report their public IP as the same address in Microsoft Azure? I have them in the same subnet on the same VNet already, and there is a gateway on that VNet with a dedicated public IP however all machines are reporting unique public IPs.
In general each Azure VM have their own IP (Public or Private or both).
However you can keep one IP at front and VM behind by -
Option 1 : Place a azure public loadbalancer and keep the VMs behind this and route the traffic by creating rules.
Option 2 : Easy Option if the VMs are identical (same OS, Size etc) you can use the Azure Dev test Lab with shared IP option for multiple VM. This option is there in the advance setting part of create VM dialog, here you can define the instance count as well.
Link for DevTestLab - https://learn.microsoft.com/en-us/azure/devtest-labs/tutorial-create-custom-lab

Azure virtual machine scale set agents public IP

I was following this article - Azure virtual machine scale set agents. Everything is good and I am able to run my custom images to perform builds and deployments.
One thing that is missing there - what if agent needs to access some IP restricted resource? Previously (with a simple VM running as agent) it was easy to whitelist public IP of a given agent. With those scale sets (and --load-balancer "") I am not sure how to get them to use a static IP (preferably only 1 outgoing public IP for all VMs in a set)
Any suggestions?
When you use a Load Balancer in front of the VMSS with only one static public IP address, then all the VMSS instances only can access outside through that one static public IP address. It's easy to achieve it, you just need to configure the public IP address as static. Then you put that public IP address in the whitelist for the restricted resource.
In this way, all the instances access the restricted resource via the static public IP address and it's in the whitelist.

How Do I Resolve A Public DNS Name To An Internal IP On Azure?

I have an azure network set up with the default Azure DNS.
All the VMs are ubuntu.
When I try to access another VM on the network via the public DNS name it resolves to the public IP.
How do I make it resolve to the internal IP when I request it from the virtual network (and obviously still resolve to the public IP when requested externally).
I'm interested in cli answers as well as configurations through the portal.
Azure DNS for IaaS and PaaS solutions
Please see this article for more information on Azure's own DNS service associated with virtual networks. In short
When role instances and VMs hosted in Azure need to resolve domain
names to internal IP addresses, they can use one of two methods:
Azure-provided name resolution
Name resolution that uses your own DNS server (which might forward queries to the Azure-provided DNS servers)
The type of name resolution you use depends on how your VMs and role
instances need to communicate with each other.
Azure DNS Private Zones (in preview)
There's also a relatively new service called, Azure DNS Private Zones that allow you to set up a private DNS service to be used with, for example virtual networks.
This service allows you to set up a private domain and private IPs for your machines. See this page for more information and some common usage scenarios.
Also, see this this feature suggestion:
Enable split DNS for providing both public and internal name resolution to VMs in the VNET

Azure Reserved IP Address Inconsistency

I had a need to add additional public IP addresses to an Azure VM and found a working solution here:
Azure VM: More than one Public IP
Essentially this creates a reserved IP in Azure and then adds the reserved IP to a cloud service. Once it's bound to a cloud service it can be mapped to a VM endpoint.
This all works great but there is one bit I don't understand - The IP address of the reserved IP and the resultant VM endpoint don't match. I have to set up DNS to point to the IP address of the endpoint to make this work. Is there something I am not doing right, or is this just the way reserved VMs work?
It looks like this unanswered question is the same issue:
azure reserved IP for VM is diffrent than the given
Thanks!
The "Azure Cloud Service" is a container that provides internet connectivity to "Azure VMs". Thus, you assign the Internet facing Public IP to the Cloud Service. This article is relatively good at explaining the relationship: Azure Cloud Services
From above link:
Here’s a definition of an Azure IaaS cloud service that will make it easy for you to understand what it is in the context of Azure Infrastructure Services:
A cloud service is a network container where you can place virtual machines.
All virtual machines in that container can communicate with each other directly through Azure (and therefore don’t have to go out to the Internet to communicate with each other).
This container is also assigned a DNS name that is reachable from the Internet.
A rudimentary DNS server is created and can provide name resolution for all virtual machines within the same cloud service container (note that name resolution provided by the DNS server is only available to the virtual machines that are located within the cloud service).
One or more Virtual IP Addresses (VIPs) are assigned to the container and these IP addresses can be used to allow inbound connections from the Internet to the virtual machines.
Certain services (like FTP) may require your vm have a public IP: Azure VM Public IP
(IaaS v1) An Azure cloud service comes with a permanent DNS name - something.cloudapp.net - and has a single VIP allocated whenever there are VMs deployed in it OR whenever a reserved IP address is associated with it. Traffic is either load balanced or NATted (port forwarded) to the VM from the Azure Load Balancer sitting on the VIP. You can also associate a public instance-level IP address (PIP) with a VM, which gives it an additional IP address. The VIP always has a DNS name (something.cloudapp.net) while the PIP has one only if you specifically add it, I did a post which goes into these differences.
(IaaS v2) VMs are not deployed into cloud services and only have a public IP address if one is specifically added - either by configuring a PIP on the NIC of the VM (and optionally giving it a cloudapp.azure.com DNS name) or by configuring a load balancer and either load balancing or NATting traffic to it. This load balancer is configured with a public IP address and can optionally have a cloudapp.azure.com DNS name associated with it. (Ignoring internal load balancers in this discussion.)

2 vms in one cloud service only one IP?

I created 2 vms, one for centos and another one for azure, I used the same cloud service, but both have the same public IP Address, why>? can I change it?
Or they have to be in different separate cloud services?
By default, they are behind a single IP address which load balances the private IP addresses. Until recently, there was no way to get a public IP for a virtual machine.
Now, it's possible to assign a public IP to a virtual machine:
With Instance-level Public IPs for VMs, you can now assign public IP addresses to your virtual machines, so they become directly addressable without having to map an endpoint through a VIP. This feature will enable scenarios like easily running FTP servers in Azure and monitoring virtual machines directly using their IPs.
We are making this new capability available in preview form today. This feature is available only with new deployments and new virtual networks and can be enabled via PowerShell.
Typically, the load balancer is fine, but there are options if you absolutely need access to individual machines.
Since they're in the same cloud service, they're probably behind the same load balancer, and a load balancer would only have one public IP.
So, yes, I would use different cloud services as you mentioned.

Resources