Windows Azure 虚拟机 - 打开端口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21083782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:15:24  来源:igfitidea点击:

Windows Azure Virtual Machine - Opening a port

windowsazureportvirtual-machine

提问by Irina

I am trying to open a port in a Windows Azure virtual machine. I have a game listening on that port, and I am able to access it via localhost, so the game is running.

我正在尝试在 Windows Azure 虚拟机中打开一个端口。我有一个游戏正在监听那个端口,我可以通过 localhost 访问它,所以游戏正在运行。

I have also opened the port in the firewall and created an endpoint in the virtual machine, but the port doesn't seem to be open to the outside world. I have tried accessing it both via the IP address and the DNS with the same results.

我也在防火墙中打开了端口,并在虚拟机中创建了一个端点,但是该端口似乎没有对外开放。我尝试通过 IP 地址和 DNS 访问它,结果相同。

Is there anything else I should do? I have looked up several tutorials online and can't figure out what I am doing wrong.

还有什么我应该做的吗?我在网上查了几个教程,但不知道我做错了什么。

采纳答案by Leo

Irina, make sure you have configured your endpoint properly by setting the private and public port. Here's a documentation that explains the steps to accomplish this...

Irina,确保您通过设置私有和公共端口正确配置了您的端点。这是一个文档,解释了完成此操作的步骤...

http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-set-up-endpoints/

http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-set-up-endpoints/

回答by Mr Heelis

this has changed to this

这已经变成了这个

enter image description here

在此处输入图片说明

I would recommend ignoring 100% of what is on google at the moment

我建议暂时忽略 100% 的谷歌内容

回答by Will

Microsoft Azure'shell from here

Microsoft Azure'shell 从这里

It's easy via Azure CLI, for example , open port 80

通过 Azure CLI 很容易,例如,打开端口 80

$ az vm open-port -g MyResourceGroup -n MyVm --port 80

$ az vm open-port -g MyResourceGroup -n MyVm --port 80

Open multiple ports at the same time

同时打开多个端口

az vm open-port -g MyResourceGroup -n MyVm --port 80-100 --priority 100

az vm open-port -g MyResourceGroup -n MyVm --port 80-100 --priority 100

Open all..

全部打开..

az vm open-port -g MyResourceGroup -n MyVm --port '*'

az vm open-port -g MyResourceGroup -n MyVm --port '*'

Pay special attention to this parameter,Must be unique for each rule

特别注意这个参数,每个规则必须是唯一的

--priority : Rule priority, between 100 (highest priority) and 4096 (lowest priority). Must be unique for each rule in the collection. Default: 900.

--priority :规则优先级,介于 100(最高优先级)和 4096(最低优先级)之间。集合中的每个规则都必须是唯一的。默认值:900。

回答by Yosef Dinerstein

In addition to described, you may need to create inbound rule in VM firewall. The settings in portal create forwarding from public IP towards VM. VM itself should allow applications to listen on the port. This may explain why this didn't work for Irina on some ports and worked on other ports.

除了描述之外,您可能需要在 VM 防火墙中创建入站规则。门户中的设置创建从公共 IP 到 VM 的转发。VM 本身应该允许应用程序侦听端口。这可能解释了为什么这在某些端口上对 Irina 不起作用而在其他端口上起作用。

回答by Rod

For future reference, if you're trying to listen to 3000 or that range it simply does not work.

为了将来参考,如果您想听 3000 或那个范围,它根本不起作用。

Go to the 8080's range, make the inbound rule and you're up and running.

转到 8080 的范围,制定入站规则,然后您就可以开始运行了。

回答by mohi

Probably this is the latest solution at a time of writing this answer:

可能这是撰写此答案时的最新解决方案:

You need to create a Network Security Group (or use an existing one). The easiest way is to search for Network Security Groups in the search resources bar. If there is an existing NSG, click on it and find inbound security rules from the settings. Then add an inbound rule with your desired port.For example, I opened port 8080 on my VM with settings shown in picture below.

您需要创建一个网络安全组(或使用现有的)。最简单的方法是在搜索资源栏中搜索网络安全组。如果存在现有 NSG,请单击它并从设置中查找入站安全规则。然后用你想要的端口添加一个入站规则。例如,我在我的虚拟机上打开了端口 8080,设置如下图所示。

More info: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-nsg-quickstart-portal/

更多信息:https: //azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-nsg-quickstart-portal/

Azure inbound security rule example

Azure 入站安全规则示例