Megosztás a következőn keresztül:


Hálózati forgalom letiltása az Azure Virtual Network Managerrel – Azure PowerShell

Ez a cikk bemutatja, hogyan hozhat létre biztonsági szabályt, amely letiltja a kimenő hálózati forgalmat a 80-443-as porton, amelyet hozzáadhat a szabálygyűjteményekhez. További információ: Biztonsági rendszergazdai szabályok.

Előfeltételek

Mielőtt elkezdené konfigurálni a biztonsági szabályokat, erősítse meg a következő lépéseket:

  • A biztonsági rendszergazdai szabály minden elemét megismerheti.
  • Létrehozott egy Azure Virtual Network Manager-példányt.
  • A szükséges parancsmagok eléréséhez a telepített vagy újabb verzió Az.Network 5.3.0 szükséges.

SecurityAdmin-konfiguráció létrehozása

  1. Hozzon létre egy új SecurityAdmin-konfigurációt a New-AzNetworkManagerSecurityAdminConfiguration használatával.

    $config = @{
        Name = 'SecurityConfig'
        ResourceGroupName = 'myAVNMResourceGroup'
        NetworkManagerName = 'myAVNM'
    }
    $securityconfig = New-AzNetworkManagerSecurityAdminConfiguration @config
    
    
  2. Tárolja a hálózati csoportot egy változóban a Get-AzNetworkManagerGroup használatával.

    $ng = @{
        Name = 'myNetworkGroup'
        ResourceGroupName = 'myAVNMResourceGroup'
        NetworkManagerName = 'myAVNM'
    }
    $networkgroup = Get-AzNetworkManagerGroup @ng   
    
  3. Hozzon létre egy kapcsolatcsoport-elemet, amelybe hálózati csoportot vehet fel a New-AzNetworkManagerSecurityGroupItem használatával.

    $gi = @{
        NetworkGroupId = "$networkgroup.Id"
    }
    
    $groupItem = New-AzNetworkManagerSecurityGroupItem -NetworkGroupId $networkgroup.id
    
  4. Hozzon létre egy konfigurációs csoportot, és adja hozzá a csoportelemet az előző lépésből.

    [System.Collections.Generic.List[Microsoft.Azure.Commands.Network.Models.PSNetworkManagerSecurityGroupItem]]$configGroup = @()  
    $configGroup.Add($groupItem) 
    
    $configGroup = @($groupItem)
    
  5. Hozzon létre egy biztonsági rendszergazdai szabálygyűjteményt a New-AzNetworkManagerSecurityAdminRuleCollection használatával.

    $collection = @{
        Name = 'myRuleCollection'
        ResourceGroupName = 'myAVNMResourceGroup'
        NetworkManager = 'myAVNM'
        ConfigName = 'SecurityConfig'
        AppliesToGroup = "$configGroup"
    }
    $rulecollection = New-AzNetworkManagerSecurityAdminRuleCollection @collection -AppliesToGroup $configGroup
    
  6. Adja meg a forrás- és célcímelőtagok és -portok változóit a New-AzNetworkManagerAddressPrefixItem használatával.

    $sourceip = @{
        AddressPrefix = 'Internet'
        AddressPrefixType = 'ServiceTag'
    }
    $sourceprefix = New-AzNetworkManagerAddressPrefixItem @sourceip
    
    $destinationip = @{
        AddressPrefix = '10.0.0.0/24'
        AddressPrefixType = 'IPPrefix'
    }
    $destinationprefix = New-AzNetworkManagerAddressPrefixItem @destinationip
    
    [System.Collections.Generic.List[string]]$sourcePortList = @() 
    $sourcePortList.Add("65500”) 
    
    [System.Collections.Generic.List[string]]$destinationPortList = @() 
    $destinationPortList.Add("80”)
    $destinationPortList.Add("443”)
    
  7. Hozzon létre egy biztonsági szabályt a New-AzNetworkManagerSecurityAdminRule használatával.

    $rule = @{
        Name = 'Block_HTTP_HTTPS'
        ResourceGroupName = 'myAVNMResourceGroup'
        NetworkManagerName = 'myAVNM'
        SecurityAdminConfigurationName = 'SecurityConfig'
        RuleCollectionName = 'myRuleCollection'
        Protocol = 'TCP'
        Access = 'Deny'
        Priority = '100'
        Direction = 'Outbound'
        SourceAddressPrefix = $sourceprefix
        SourcePortRange = $sourcePortList
        DestinationAddressPrefix = $destinationprefix
        DestinationPortRange = $destinationPortList
    }
    $securityrule = New-AzNetworkManagerSecurityAdminRule @rule
    

Üzembe helyezés véglegesítése

Véglegesítse a biztonsági konfigurációt a célrégiókra a Deploy-AzNetworkManagerCommit használatával.

$regions = @("westus")
$deployment = @{
    Name = 'myAVNM'
    ResourceGroupName = 'myAVNMResourceGroup'
    ConfigurationId = $configIds
    TargetLocation = $regions
    CommitType = 'SecurityAdmin'
}
Deploy-AzNetworkManagerCommit @deployment 

Biztonsági konfiguráció törlése

Ha már nincs szüksége a biztonsági konfigurációra, győződjön meg arról, hogy a következő feltételek teljesülnek, így törölheti magát a biztonsági konfigurációt:

  • Egyetlen régióban sem üzemelnek konfigurációk.
  • Törölje a biztonsági konfigurációhoz társított szabálygyűjtemény összes biztonsági szabályát.

Biztonsági konfiguráció üzembe helyezésének eltávolítása

Távolítsa el a biztonsági üzembe helyezést egy konfiguráció üzembe helyezésével a Deploy-AzNetworkManagerCommit használatával.

[System.Collections.Generic.List[string]]$configIds = @()
[System.Collections.Generic.List[string]]$regions = @()   
$regions.Add("westus")     
$removedeployment = @{
    Name = 'myAVNM'
    ResourceGroupName = 'myAVNMResourceGroup'
    ConfigurationId = $configIds
    TargetLocation = $regions
    CommitType = 'SecurityAdmin'
}
Deploy-AzNetworkManagerCommit @removedeployment

Biztonsági szabályok eltávolítása

Távolítsa el a biztonsági szabályokat a Remove-AzNetworkManagerSecurityAdminRule használatával.

$removerule = @{
    Name = 'Block80'
    ResourceGroupName = 'myAVNMResourceGroup'
    NetworkManagerName = 'myAVNM'
    SecurityAdminConfigurationName = 'SecurityConfig'
}
Remove-AzNetworkManagerSecurityAdminRule @removerule

Biztonsági szabálygyűjtemények eltávolítása

$removecollection = @{
    Name = 'myRuleCollection'
    ResourceGroupName = 'myAVNMResourceGroup'
    NetworkManagerName = 'myAVNM'
    SecurityAdminConfigurationName = 'SecurityConfig'
}
Remove-AzNetworkManagerSecurityAdminRuleCollection @removecollection

Konfiguráció törlése

Törölje a biztonsági konfigurációt a Remove-AzNetworkManagerSecurityAdminConfiguration használatával.

$removeconfig = @{
    Name = 'SecurityConfig'
    ResourceGroupName = 'myAVNMResourceGroup'
    NetworkManagerName = 'myAVNM'
}
Remove-AzNetworkManagerSecurityAdminConfiguration @removeconfig

Következő lépések

További információ a biztonsági rendszergazdai szabályokról.