有没有办法在 Azure Pipeline 虚拟机上打开 ICMP?

is there a way to open ICMP on an Azure Pipeline vm?

有没有办法在 Azure Pipeline 虚拟机上打开 ICMP?我的 CI 单元测试预计会向 google DNS (8.8.8.8)

发送 ping 请求

根据您的描述,您正在尝试使用 Ping 通过 Azure VM 终结点访问一个外部 IP。 这是不允许的

请感谢我们的 Azure VM 团队工程师撰写的官方博客:HOW TO ALLOW PING FUNCTIONALITY TO WINDOWS AZURE MACHINES?

The Ping functionality on Windows Azure VM is blocked by default for security reasons.

众所周知,Ping使用的ICMP协议可以测量本地机器和远程机器之间的连接延迟。任何超过默认延迟的连接都被视为不可用。请参见下图,与该 Azure 虚拟机的唯一可能连接是通过 Internet。任何试图进入虚拟网络的 Internet 流量都必须通过 负载平衡器 ,并且此平衡器 正在过滤 ICMP 流量 ,允许 UDPTCP 流量。

By default, Azure denies and blocks all public inbound traffic to an Azure virtual machine, includes ICMP traffic. This is a good thing because it can improve security by reducing the attack surface.

注意:此限制仅适用于通过配置端点通过外部 IP 的网络流量。但是,如果网络流量发生在同一虚拟网络或同一云服务中的 VM 的内部 IP 之间,则 ICMP 将被允许。

此限制并非永久限制。我们可以设置 firefallazure security group 来允许这个。但是,不幸的是,对于 Azure Devops Pipeline,托管代理正在使用 VM DS2_V2DS3_V2,这些都不能 configured\modified 与外部用户的 firefall 和安全组。如果build\release和private agent,ICMP不会被限制。你可以设置一个private agent,在里面执行ping测试。

(有时,可以使用 VPNExpressRoute 来跳过负载均衡器过滤器和限制。但我不'推荐使用这种方式)


由于 Ping 是一种非常方便且重要的连接故障排除工具,我们正在审查并考虑在 Azure VM 中扩展此功能。在我们的 uservoice 论坛中提出了这样的建议票:Enable ICMP traffic to Azure VMs over the Internet。您也可以为它投票,以将其更快地推入开发队列。