Import-Module -Name Az UnauthorizedAccess
Login-AzAccount =Connect-AzAccount
AzureRm -> Az
Select-AzSubscription -Tenant 'da910980-928b-449c-88b9-7777777777777777'
# 구독 선택
$subscriptionId = (Get-AzSubscription | Out-GridView -Title 'Azure 구독 선택 :' -PassThru )
Select-AzSubscription -SubscriptionId $subscriptionId.Id
# 리소스 그룹 선택
$rgName = '20190625rg'
#혹은 요게 좋네
$resourceGroup = Get-AzResourceGroup -Name '20190625rg'
# NSG 이름 및 Azure 지역 설정
$nsgName = "Trusted-Nsg01"
$location = $resourceGroup.Location
$source1 = "8.8.8.8/32"
$source2 ="8.8.4.4/32"
$source3 ="*"
$dest1 ="3389"
$dest2 ="443"
$dest3 ="80"
$tag = "블로그"
$rule1 = New-azNetworkSecurityRuleConfig -Name rdp-rule -Description "Allow RDP" ` -Access Allow -Protocol Tcp -Direction Inbound -Priority 100 ` -SourceAddressPrefix $source1 -SourcePortRange * ` -DestinationAddressPrefix * -DestinationPortRange $dest1
$rule2 = New-azNetworkSecurityRuleConfig -Name web-rule2 -Description "Allow Port" ` -Access Allow -Protocol Tcp -Direction Inbound -Priority 101 ` -SourceAddressPrefix $source2 -SourcePortRange * -DestinationAddressPrefix * ` -DestinationPortRange $dest2
$rule3 = New-azNetworkSecurityRuleConfig -Name web-rule3 -Description "Allow Port" ` -Access Allow -Protocol Tcp -Direction Inbound -Priority 103 ` -SourceAddressPrefix $source3 -SourcePortRange * -DestinationAddressPrefix * ` -DestinationPortRange $dest3
$rule4 = New-azNetworkSecurityRuleConfig -Name web-rule4 -Description "Allow Port" ` -Access Allow -Protocol Tcp -Direction Inbound -Priority 104 ` -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * ` -DestinationPortRange 88
#applying the Rules
$nsg = New-azNetworkSecurityGroup -ResourceGroupName $rgName -Location $location -Name $nsgName -SecurityRules $rule1,$rule2,$rule3,$rule4
# Display default and security rules for NSG
(Get-azNetworkSecurityGroup -Name $nsgName -ResourceGroupName $rgName).SecurityRules | Select-Object * | Out-GridView (Get-azNetworkSecurityGroup -Name $nsgName -ResourceGroupName $rgName).DefaultSecurityRules | Select-Object * | Out-GridView
#Remove NSG
Remove-azNetworkSecurityGroup -Name $nsgName -ResourceGroupName $rgName
'기술(Azure 만...) > [MS]Azure기본' 카테고리의 다른 글
AAD 단계별 배포전략 요건정의 (0) | 2020.08.03 |
---|---|
azure 백업 일반/프로세스 (0) | 2020.06.18 |
가용성집합 VM 생성 파워셸 (0) | 2020.06.07 |
azure VM 기초, 과금구조 등 (0) | 2020.05.29 |
azure기초 RBAC (0) | 2020.05.28 |