How to ssh to Azure VM using private IP address from internet - azure

I'm new to Azure. Just deployed an Ubuntu VM but thought I'd only create a private IP address, no public IP.
How do I ssh from my laptop at home to the Azure VM using the 10.x.x.x IP address?
I've tried:
Using the Azure Cloud Shell but connection just times out
Using ssh on my laptop, but its looking for the VM on my LAN and times out.

You can't SSH from your local machine to your VM with a private IP because your machine isn't in the same network as the VM. You would only be able to SSH to the VM from another VM on the same virtual network.
In order to SSH to your VM from outside of the vnet you will need a NIC attached with a Public IP and the default port of 22 open on your Network Security Group.
Edit: because I couldn't find a relevant document for this I wrote a blog post. https://medium.com/#joelatwar/how-to-ssh-to-your-azure-linux-vms-with-username-and-password-from-windows-linux-or-mac-df7d07ea3be1

I have found some other way working.
Temporarily attach the VM with private ip address under a public azure lb, configure a nat rule for ssh in the load balancer.make sure you have allowed the ssh from inside vnet in the nsg where the vm is attached.
SSH into the public load balancer ip and you will be able to access the internal machine via azure load balancer ip.

In the meanwhile there exists Azure Bastion which could help you.

Related

Connect to Azure Resource under VPN P2S

I'm trying to setup a Point-to-Site (P2S) VPN from my Windows 10 machine to my Azure Server and, even successfull connect to the VPN, I cannot connect to the server.
My Azure server has 2 network interfaces:
1st has private IP 10.0.0.5/24 (and an associated Public IP, that allow me to connect with Remote Desktop normally, but off the VPN).
2nd has private IP 10.0.0.4/24, without Public IP. (the other public IP is used with the virtual network gateway to use the VPN).
I've added the net/subnet "172.16.10.0/24" as addresses pool in my virtual network gateway.
* When I connect, an IP /32 address is assignet to my local machine, like 172.16.10.3 / 255.255.255.255, and I can ping 172.16.10.0
(no code to be displayed)
The certificate setting is ok, the connection to the VPN is OK. I only cannot connect to my Azure Server on my second interface 10.0.0.4.
Any idea that I've forgot to do?
Thank you.
The solution: My Private IP range on Azure local network Gateway has been wrong on setup. I've fixed specifying my correct local IP range, but, not only this, a new route table was created, associating this with the GatewaySubnet (in the Virtual Network).
Thanks to Nancy Xiong and msrini-MSIT for help.

Virtual Machine Scale Sets

I have a test azure subscription, I have created a Virtual Machine Scale Sets.
There are no errors in the scale set.
How do I connect to VM's and make my server to put in a load?
Can I connect with RDP to my Scale set VM's ? is this allowed?
If you create VMSS via Azure portal Marketplace, we can't add inbound NAT rules to use RDP to login the VMSS instances, we can't RDP them directly.
So if you want to login those instances, we can create a new VM in the same Vnet(same Vnet can connect by the private IP address), and use the private IP to RDP.
How do I connect to VM's and make my server to put in a load?
By default, we can use load balancer public IP address and NAT port to RDP VMs behind the VMss.
Can I connect with RDP to my Scale set VM's ? is this allowed?
You can create a windows VM in the same Virtual Network, this VM work as a jumpbox, then use this vm to RDP those instances via private IP address.
Another way, modify template to add NAT rules.
More information about VMss and NAT rules, please refer to this link.

Azure VM shows different IPs

I have Windows Azure VM and public IP (40.115.16.153) assigned to it. However when I execute ipconfig /all command inside VM, it shows me different IP address. I'm wondering why?
When you launch a VM in Azure you do not have a public IP Address attached directly to the Nic.
With a v1 (classic) VM you either connect through the Cloud Service IP, or through a Public IP attached to the VM.
In a v2 VM, all VMs need to exist within a virtual network, to which you attach a Network Interface. That interface will have an IP Address that is local to the virtual network it is a member of. Optionally you can attach a Public IP to that interface.
In both cases the external IP address is mapped to the internal address of your VM through whatever firewalling you have configured.
This is the reason that your VM does not have the same IP as the external IP.

Azure Virtual Network Custom DNS Server

I created a virtual network and put 2 VMs in one subnet. But they were not able to ping each other using their hostnames. I need a DNS Server implemented so that hostnames in the subnet can be resolved to IP addresses. How do I do that? Any help will be appreciated. :)
the simplest scenario is to add your hostnames and ips to your localhost file if you are on Windows or you /etc/resolv.conf if you are on Linux. Deploy your VMs with fixed private IPs to avoid changes if they are rebooted or shutdown.
However, if the scenario is more complex with more than two machines, the best way is to deploy a DNS Server inside your VNET. The steps are the following ones:
First you need to add to your virtual network a DNS. You can do it through the management portal in the section NETWORKS > {Your Network Name} > CONFIGURE > dns servers. Fill it with a name and an IP.
Deploy a new VM inside the Virtual Network and set it's IP to the same IP you have defined inside the portal. You can do it through PowerShell (https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-reserved-private-ip/#how-to-add-a-static-internal-ip-to-an-existing-vm)
Configure your DNS server with the records for the VMs and set the forwarders if you want to be able to resolve names outside the virtual network.
You can reboot your virtual machines to get the new configuration through DHCP.
An example: http://www.ytechie.com/2013/06/setting-up-a-dns-server-in-azure-iaasvms/

Unable to ping VM outside windows Azure

I followed the following link to create the azure instance
http://michaelwasham.com/2013/09/03/connecting-clouds-site-to-site-aws-azure/
I am able to ssh to the VM from my local machine, however I am not able to ssh or ping from the VM to any public servers (www.google.com, www.yahoo.com).That is the communication is happening only between VMs within the Windows azure Cloud.
Please let me know how to enable outbound traffic to public servers from Windows Azure VM.
ICMP is blocked by default (see this SO post: ping google.com or 8.8.8.8 fails) for the Virtual IP Address
But with the new instance level public-ip address, you will get an ip address per virtual server:
https://azure.microsoft.com/documentation/articles/virtual-networks-instance-level-public-ip/
Now ping works (ping 8.8.8.8) after a reboot of the VM in my case.

Resources