你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
使用 Azure Bastion 时,可以使用网络安全组 (NSG)。 有关详细信息,请参阅安全组。
在此图中:
- Bastion 主机部署到虚拟网络中。
- 用户使用任何 HTML5 浏览器连接到 Azure 门户。
- 用户导航到虚拟机,以便进行 RDP/SSH 操作。
- 连接集成 - 在浏览器中单击“RDP/SSH 会话”
- Azure VM 无需公共 IP。
网络安全组
本部分介绍用户与 Azure Bastion 之间的网络流量,以及到虚拟网络中的目标 VM 的网络流量:
重要
如果选择在 Azure Bastion 资源中使用 NSG,则必须创建以下所有入口和出口流量规则。 在 NSG 中省略以下任何规则将阻止 Azure Bastion 资源在将来接收必要的更新,使资源受到未来安全漏洞的威胁。
AzureBastionSubnet
Azure Bastion 将专门部署到 AzureBastionSubnet。
入口流量:
- 来自公共 Internet 的入口流量: Azure Bastion 将创建一个公共 IP,需要在该公共 IP 上启用端口 443,用于入口流量。 不需要在 AzureBastionSubnet 上打开端口 3389/22。 请注意,源可以是 Internet 或你指定的一组公共 IP 地址。
- 来自 Azure Bastion 控制平面的入口流量: 对于控制平面连接,请启用从 GatewayManager 服务标记进行的端口 443 入站。 这使控制平面(即网关管理器)能够与 Azure Bastion 通信。
- 来自 Azure Bastion 数据平面的入口流量: 对于 Azure Bastion 基础组件之间的数据平面通信,启用端口 8080、5701 从 VirtualNetwork 服务标记到 VirtualNetwork 服务标记入站 。 这使得 Azure Bastion 的组件能够彼此通信。
- 来自 Azure 负载均衡器的入口流量: 对于运行状况探测,请从 AzureLoadBalancer 服务标记启用端口 443 入站。 这使得 Azure 负载均衡器能够检测连接性
出口流量:
- 流向目标 VM 的出口流量: Azure Bastion 将通过专用 IP 到达目标 VM。 NSG 需要允许端口 3389 和 22 的出口流量流向其他目标 VM 子网。 如果使用标准 SKU 中的自定义端口功能,请确保 NSG 允许出站流量发到作为目标的服务标记 VirtualNetwork。
- 流向 Azure Bastion 数据平面的出口流量: 对于 Azure Bastion 基础组件之间的数据平面通信,启用端口 8080、5701 从 VirtualNetwork 服务标记到 VirtualNetwork 服务标记出站 。 这使得 Azure Bastion 的组件能够彼此通信。
- 流向 Azure 中其他公共终结点的出口流量: Azure Bastion 需要能够连接到 Azure 中的各种公共终结点,以便执行相应操作(例如,存储诊断日志和计量日志)。 因此,Azure Bastion 需要出站到 443,再到 AzureCloud 服务标记。
- 流向 Internet 的出口流量:若要进行会话、Bastion 可共享链接和证书验证,Azure Bastion 需要能与 Internet 进行通信。 为此,建议你启用到 Internet 的出站端口 80。
用于创建上述入口和出口流量规则的 Powershell 脚本
# Connect to Azure Account
Connect-AzAccount
# Get the Network Security Group details
$resourceGroupName = Read-Host ("Enter the name of the Resource Group")
$nsgName = Read-Host ("Enter the name of the Network Security Group")
# Ingress and Egress rules
$rules = @(
@{
Name = "AllowHttpsInbound"
Priority = 120
Direction = "Inbound"
Access = "Allow"
SourceAddressPrefix = "Internet"
SourcePortRange = "*"
DestinationAddressPrefix = "*"
DestinationPortRange = "443"
Protocol = "TCP"
},
@{
Name = "AllowGatewayManagerInbound"
Priority = 130
Direction = "Inbound"
Access = "Allow"
SourceAddressPrefix = "GatewayManager"
SourcePortRange = "*"
DestinationAddressPrefix = "*"
DestinationPortRange = "443"
Protocol = "TCP"
},
@{
Name = "AllowAzureLoadBalancerInbound"
Priority = 140
Direction = "Inbound"
Access = "Allow"
SourceAddressPrefix = "AzureLoadBalancer"
SourcePortRange = "*"
DestinationAddressPrefix = "*"
DestinationPortRange = "443"
Protocol = "TCP"
},
@{
Name = "AllowBastionHostCommunication"
Priority = 150
Direction = "Inbound"
Access = "Allow"
SourceAddressPrefix = "VirtualNetwork"
SourcePortRange = "*"
DestinationAddressPrefix = "VirtualNetwork"
DestinationPortRange = 8080,5701
Protocol = "Ah"
}
@{
Name = "AllowSshRdpOutbound"
Priority = 100
Direction = "Outbound"
Access = "Allow"
SourceAddressPrefix = "*"
SourcePortRange = "*"
DestinationAddressPrefix = "VirtualNetwork"
DestinationPortRange = 22,3389
Protocol = "Ah"
},
@{
Name = "AllowAzureCloudOutbound"
Priority = 110
Direction = "Outbound"
Access = "Allow"
SourceAddressPrefix = "*"
SourcePortRange = "*"
DestinationAddressPrefix = "AzureCloud"
DestinationPortRange = "443"
Protocol = "TCP"
},
@{
Name = "AllowBastionCommunication"
Priority = 120
Direction = "Outbound"
Access = "Allow"
SourceAddressPrefix = "VirtualNetwork"
SourcePortRange = "*"
DestinationAddressPrefix = "VirtualNetwork"
DestinationPortRange = 8080,5701
Protocol = "Ah"
},
@{
Name = "AllowHttpOutbound"
Priority = 130
Direction = "Outbound"
Access = "Allow"
SourceAddressPrefix = "*"
SourcePortRange = "*"
DestinationAddressPrefix = "Internet"
DestinationPortRange = "80"
Protocol = "Ah"
}
)
foreach ($rule in $rules) {
$nsgRule = New-AzNetworkSecurityRuleConfig -Name $rule.Name `
-Priority $rule.Priority `
-Direction $rule.Direction `
-Access $rule.Access `
-SourceAddressPrefix $rule.SourceAddressPrefix `
-SourcePortRange $rule.SourcePortRange `
-DestinationAddressPrefix $rule.DestinationAddressPrefix `
-DestinationPortRange $rule.DestinationPortRange `
-Protocol $rule.Protocol
# Get the details of the Network Security Group and Add rules to the group
$nsg = Get-AzNetworkSecurityGroup -ResourceGroupName $resourceGroupName -Name $nsgName
$nsg.SecurityRules.Add($nsgRule)
Set-AzNetworkSecurityGroup -NetworkSecurityGroup $nsg
}
目标 VM 子网
此子网包含要通过 RDP/SSH 连接到的目标虚拟机。
- 来自 Azure Bastion 的入口流量: Azure Bastion 将通过专用 IP 到达目标 VM。 RDP/SSH 端口(如果你使用自定义端口功能作为标准 SKU 或高级 SKU 的一部分,则分别为端口 3389/22 或自定义端口值)需要通过专用 IP 在目标 VM 端打开。 最佳做法是,可以在此规则中添加 Azure Bastion 子网 IP 地址范围,仅允许 Bastion 在目标 VM 子网中的目标 VM 上打开这些端口。
后续步骤
有关 Azure Bastion 的详细信息,请参阅常见问题解答。