Quantcast
Channel: Azure Virtual Machines forum
Viewing all articles
Browse latest Browse all 12545

How can I connect remote server from a specified local tcp port on a VM?

$
0
0

Hi,

I tried to connect to remote server from an azure VM with a specified local port as mentioned below, but I failed:

1. I added a public IP to cloud service of the VM, so the cloud service has two VIPs, one is default, one is added by me.

2. I created an EndPoint at the VM, with private port2111 and public port2111, then I associated the EndPoint with the added VIP.

2. I connected remote server with C# TcpClient, so I specified the port of local endpoint as2111 when constructed the TcpClient object.

3. Then I checked network traffic on the VM by a sniffer tool, and the tool showed the connection connected the remote server on local port2111.

4. In remote server side, I output client endpoint when a client connected in. Unfortunately, the output showed that the client IP is VM's default VIPbut not the added VIP, and the client's port is NOT the port 2111 I specified before, but is 1068 which looks like a random assigned port.

In my understanding, The end point of VM like a service, which will be:

1. Listening at port internally speicified by private port setting and listening at port specified by public port setting externally.

2. Forwarding all inbound traffic arrived at external Public Port to internal Private Port, and forwarding all outbound traffic submitted to internal Private Port to its target via externally Public Port

So, I did not why it happen and how can I connect remote server from specified local port and VIP as I expected?

Many thanks, 

Ji



Viewing all articles
Browse latest Browse all 12545

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>