Azure Virtual Network: VNet Flow Logs Naar Log Analytics

💼 Management Samenvatting

VNet Flow Logs zijn een relatief nieuwe Azure feature (2024) die network traffic logging op VNet-level biedt als alternatief voor NSG Flow Logs. Deze feature is optioneel omdat NSG Flow Logs typically voldoende network visibility bieden, maar VNet Flow Logs kunnen relevant zijn voor VNets zonder NSGs of voor simplified flow logging architecture.

Aanbeveling
OPTIONEEL - NSG FLOW LOGS VOLDOENDE
Risico zonder
Low
Risk Score
4/10
Implementatie
2u (tech: 2u)
Van toepassing op:
Azure

NSG Flow Logs (de gevestigde feature) loggen traffic op NSG-level wat granulaire control biedt per subnet of NIC, maar vereisen dat elke NSG individueel wordt geconfigureerd voor flow logging. VNet Flow Logs bieden een alternatieve approach waarbij logging op VNet-level wordt ingeschakeld, wat automatisch ALL traffic binnen het entire VNet logt zonder per-NSG configuration. Dit kan voordelen hebben voor VNets met vele subnets waar bulk NSG flow log configuration complex is, VNets zonder NSGs attached (mogelijk in specific architecturen), of organizational preference voor simplified configuration waarbij één VNet-level setting voldoende is. De trade-off is dat VNet Flow Logs minder granular zijn omdat filtering per subnet niet mogelijk is zoals bij NSG Flow Logs, de feature is relatief nieuw (2024) en less mature dan NSG Flow Logs, en additional costs ontstaan bovenop potential existing NSG Flow Logs. Voor most scenarios zijn NSG Flow Logs voldoende en VNet Flow Logs zijn optional/redundant.

PowerShell Modules Vereist
Primary API: Azure API
Connection: Connect-AzAccount
Required Modules: Az.Network

Implementatie

Deze maatregel configureert VNet Flow Logs voor Virtual Networks door flow logging op VNet-level te enableren met destination naar Log Analytics Workspace. De implementation is vergelijkbaar met NSG Flow Logs maar target is het VNet in plaats van individual NSGs. De costs zijn comparable met NSG Flow Logs (€1-3 per VNet per maand). Deze feature is Nice-to-Have priority omdat NSG Flow Logs typically sufficient zijn en VNet Flow Logs optional redundancy bieden of relevant zijn voor specific VNet architectures zonder NSGs. Dit kan ondersteunen BIO 12.04 network logging in specific scenarios.

Vereisten

Implementatie

Gebruik PowerShell-script vnet-flow-logs-log-analytics.ps1 (functie Invoke-Implementation) – Implementeren.

Compliance en Auditing

Monitoring

Gebruik PowerShell-script vnet-flow-logs-log-analytics.ps1 (functie Invoke-Monitoring) – Controleren.

Remediatie

Gebruik PowerShell-script vnet-flow-logs-log-analytics.ps1 (functie Invoke-Remediation) – Herstellen.

Compliance & Frameworks

Automation

Gebruik het onderstaande PowerShell script om deze security control te monitoren en te implementeren. Het script bevat functies voor zowel monitoring (-Monitoring) als remediation (-Remediation).

PowerShell
<# ================================================================================ AZURE POWERSHELL SCRIPT - Nederlandse Baseline voor Veilige Cloud ================================================================================ .SYNOPSIS VNet Flow Logs Log Analytics .DESCRIPTION CIS Azure Foundations Benchmark - Control 5.33 Controleert of VNet flow logs naar Log Analytics worden gestuurd. .NOTES Filename: vnet-flow-logs-log-analytics.ps1 Author: Nederlandse Baseline voor Veilige Cloud Version: 1.0 CIS Control: 5.33 #> #Requires -Version 5.1 #Requires -Modules Az.Accounts, Az.Network [CmdletBinding()] param([Parameter()][switch]$Monitoring) $ErrorActionPreference = 'Stop' $PolicyName = "VNet Flow Logs Log Analytics" function Connect-RequiredServices { if (-not (Get-AzContext)) { Connect-AzAccount | Out-Null } } function Test-Compliance { $networkWatchers = Get-AzNetworkWatcher -ErrorAction SilentlyContinue $result = @{ TotalFlowLogs = 0; WithLogAnalytics = 0 } foreach ($watcher in $networkWatchers) { $flowLogs = Get-AzNetworkWatcherFlowLog -NetworkWatcher $watcher -ErrorAction SilentlyContinue foreach ($log in $flowLogs) { $result.TotalFlowLogs++ if ($log.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceId) { $result.WithLogAnalytics++ } } } return $result } try { Connect-RequiredServices if ($Monitoring) { $r = Test-Compliance Write-Host "`n========================================" -ForegroundColor Cyan Write-Host "$PolicyName" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "Total Flow Logs: $($r.TotalFlowLogs)" -ForegroundColor White Write-Host "With Log Analytics: $($r.WithLogAnalytics)" -ForegroundColor $(if ($r.WithLogAnalytics -eq $r.TotalFlowLogs) { 'Green' } else { 'Yellow' }) if ($r.WithLogAnalytics -lt $r.TotalFlowLogs) { Write-Host "`n⚠️ Configureer Log Analytics voor alle flow logs" -ForegroundColor Yellow } } else { $r = Test-Compliance Write-Host "`nVNet Flow Logs → Log Analytics: $($r.WithLogAnalytics)/$($r.TotalFlowLogs)" } } catch { Write-Error $_; exit 1 } # ================================================================================ # Standaard Invoke-* Functions (Auto-generated) # ================================================================================ function Invoke-Implementation { <# .SYNOPSIS Implementeert de configuratie #> [CmdletBinding()] param() Invoke-Remediation } function Invoke-Monitoring { <# .SYNOPSIS Controleert de huidige configuratie status #> [CmdletBinding()] param() $Monitoring = $true try { Connect-RequiredServices if ($Monitoring) { $r = Test-Compliance Write-Host "`n========================================" -ForegroundColor Cyan Write-Host "$PolicyName" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "Total Flow Logs: $($r.TotalFlowLogs)" -ForegroundColor White Write-Host "With Log Analytics: $($r.WithLogAnalytics)" -ForegroundColor $(if ($r.WithLogAnalytics -eq $r.TotalFlowLogs) { 'Green' } else { 'Yellow' }) if ($r.WithLogAnalytics -lt $r.TotalFlowLogs) { Write-Host "`n⚠️ Configureer Log Analytics voor alle flow logs" -ForegroundColor Yellow } } else { $r = Test-Compliance Write-Host "`nVNet Flow Logs → Log Analytics: $($r.WithLogAnalytics)/$($r.TotalFlowLogs)" } } catch { Write-Error $_; exit 1 } } function Invoke-Remediation { <# .SYNOPSIS Herstelt de configuratie naar de gewenste staat .DESCRIPTION Dit is een monitoring-only control, remediation delegeert naar monitoring #> [CmdletBinding()] param() Write-Host "[INFO] Dit is een monitoring-only control" -ForegroundColor Yellow Write-Host "[INFO] Running monitoring check..." -ForegroundColor Cyan Invoke-Monitoring }

Risico zonder implementatie

Risico zonder implementatie
Low: VNet Flow Logs = newer feature. NSG Flow Logs usually sufficient. Het risico is laag - NSG logs adequate.

Management Samenvatting

VNet Flow Logs: Newer alternative to NSG Flow Logs (VNet-level instead subnet-level). NSG Flow Logs blijven primary recommendation. Activatie: VNet → Flow logs. Aanbevolen BIO 12.04. Implementatie: 2 uur. Optioneel - NSG sufficient.