Azure – How to run a client-server program on two virtual machines at different locations in Azure

azureazure-networkingclient-serverconnection

I created two virtual machines in Azure. One of them is in Australia South and the other is in Central India. I ran client program in one machine and server program in other machine. There are not able to connect to each other. After a little google search, I created Network Security Group in both VMs and added the following inbound and outbound rule.

Source – Any

Destination – Any

Service – Custom (Any/32000-32200)

Action – Allow

I am connecting to ports in between 32000-32200 in my program, but still the machines are not connecting to each other. I am using Ubuntu Server 16.04 and classic deployment model. I kindly request you to help me out..
I am attaching screenshots of my network security group and output of netstat command.

Network Security Group

netstat

Best Answer

Two Vnets in different regions's communication is just like on-premise to Azure. As Sam said, there is no directly connectivity between the two VNet. According to your description, you use Public IP for VM's communication. I suggest you could check as the following ways:

1.Please use you could connect port 32000-32200 from one Azure VM to another VM, you could use telnet to test.

2.Check the result netstat -ant|grep 32000(Linux), please ensure your port is listening on tcp and 0.0.0.0.

3.Open ports on Azure NSG, according to your said, you have added it. Please pay attention to Azure NSG could be associated to VM's NIC or Vnet's subnet.

4.Check your VMs's firewall. If your VM's are Windows OS, you need open ports on Windows Firewall(Inbound rules).

Update:

For a classic VM, you should open ports on Endpoint, more information please refer to this link.

Related Topic