You are planning a strategy to deploy numerous web servers and database servers to Azure.
This strategy should allow for connection types between the web servers and database servers to be controlled.
Solution: You include a local network gateway in your strategy.
Does the solution meet the goal?
提供答案和解答。
Azure 网络内部,应该使用 NSGs 网络安全策略。
好的,这是一个关于 Azure 网络策略的问题。
答案 / Answer:
不,该解决方案无法达成目标。
No, the solution does not meet the goal.
解答 / Explanation:
为什么这个解决方案是错误的? (Why the solution is incorrect?)
- 本地网络网关 (Local Network Gateway) 的主要作用是代表您本地(on-premises)的网络。它用于在您的 Azure 虚拟网络 (VNet) 和您的本地数据中心之间建立站点到站点 (Site-to-Site) VPN 或 ExpressRoute 连接。
- 它的功能是处理 Azure 与外部网络之间的通信,而不是控制 Azure 内部资源(如 Web 服务器和数据库服务器)之间的连接。
在这个场景中,Web 服务器和数据库服务器都部署在 Azure 内部,因此它们之间的通信是 Azure 内部流量。本地网络网关与控制这种内部流量无关。
A Local Network Gateway is an Azure resource that represents your on-premises network. Its purpose is to establish a Site-to-Site VPN or an ExpressRoute connection between your Azure Virtual Network (VNet) and your on-premises data center.
Its function is to handle traffic between Azure and an external network, not to control connections inside Azure between resources like web servers and database servers.
In this scenario, both the web servers and database servers are deployed within Azure, so the traffic between them is internal Azure traffic. A Local Network Gateway is not involved in controlling this type of traffic.
正确的解决方案是什么? (What is the correct solution?)
要控制 Azure 中 Web 服务器和数据库服务器之间的连接类型,您应该使用以下一个或多个 Azure 服务:
To control the connection types between web servers and database servers within Azure, you should use one or more of the following Azure services:
-
网络安全组 (Network Security Groups - NSGs): 这是最核心、最直接的解决方案。
- 您可以创建 NSG 规则,明确允许或拒绝基于源/目标 IP 地址、端口和协议的流量。
- 最佳实践 (Best Practice): 将 Web 服务器和数据库服务器放置在不同的子网 (Subnets) 中。然后将一个 NSG 关联到数据库子网,创建一个规则,只允许来自 Web 服务器子网的流量访问数据库端口(例如,SQL Server 的 1433 端口),并拒绝所有其他流量。
-
应用程序安全组 (Application Security Groups - ASGs): 这是对 NSG 的一种增强。
- 您可以将具有相似功能的虚拟机(例如,所有 Web 服务器)分组到一个 ASG 中。
- 然后,您可以在 NSG 规则中使用 ASG 作为源或目标,而不是管理具体的 IP 地址列表。这使得规则的管理和扩展变得更加容易。
- 示例 (Example): 创建一条 NSG 规则,允许从名为
WebAppASG 的应用程序安全组到名为 DatabaseASG 的应用程序安全组的 TCP 端口 1433 流量。
-
Azure 防火墙 (Azure Firewall): 对于更复杂或需要集中管理网络策略的场景,您可以使用 Azure 防火墙。它提供更高级的功能,如基于 FQDN 的过滤和威胁情报。
总结 / Summary:
- 错误工具 (Incorrect Tool): 本地网络网关 (Local Network Gateway) → 用于连接 Azure 和本地网络。
- 正确工具 (Correct Tool): 网络安全组 (Network Security Groups - NSGs) → 用于过滤 Azure 虚拟网络内部和外部的流量。