通过PowerShell创建nsg时出错 [英] Error when creating nsg through PowerShell
本文介绍了通过PowerShell创建nsg时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从门户网站,我们可以创建具有多个端口或IP的NSG规则,例如(
Hello,
From the Portal we can create NSG rule with multiple ports or IPs like (80,443) but not with Powershell :
New-AzureRmNetworkSecurityGroup:安全规则的端口范围无效.提供的价值:80,443.值应为整数或带有'-'分隔符的整数范围.有效范围
0-65535.
New-AzureRmNetworkSecurityGroup : Security rule has invalid Port range. Value provided: 80,443. Value should be an integer OR integer range with '-' delimiter. Valid range
0-65535.
请解决吗?
推荐答案
创建一个资源组. (如果已经创建,请跳过此步骤)
New-AzureRmResourceGroup -Name TestRG -Location westus
创建一个安全规则,允许从Internet访问端口443.
rule1 = New-AzureRmNetworkSecurityRuleConfig-名称rdp-rule-说明允许RDP"; -允许访问 -协议Tcp-方向入站-优先级100-SourceAddressPrefix互联网-SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 443
rule1 = New-AzureRmNetworkSecurityRuleConfig -Name rdp-rule -Description "Allow RDP" -Access Allow -Protocol Tcp -Direction Inbound -Priority 100 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 443
创建一个安全规则,允许从Internet访问端口80.
rule2 = New-AzureRmNetworkSecurityRuleConfig-名称web-rule-说明允许HTTP"; -允许访问 -协议Tcp-方向入站-优先级101-SourceAddressPrefix互联网-SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 80
rule2 = New-AzureRmNetworkSecurityRuleConfig -Name web-rule -Description "Allow HTTP" -Access Allow -Protocol Tcp -Direction Inbound -Priority 101 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 80
添加规则创建到名为NSG-FrontEnd的新NSG.
这篇关于通过PowerShell创建nsg时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文