🎯 Mục Tiêu Lab
Tạo Firewall Policy Standard, cấu hình DNS settings
Gắn Firewall Policy vào Azure Firewall (thay thế classic rules)
Tạo Rule Collection Group với priority hierarchy
Bật Threat Intelligence ở chế độ Alert và thử chế độ Deny
Kết nối Log Analytics Workspace để xem Threat Intel logs
Hiểu Parent Policy inheritance cho multi-firewall scenario
📋 Chuẩn Bị
- Azure Firewall từ Lab 23 hoặc 24 (hoặc tạo mới)
- Log Analytics Workspace (sẽ tạo trong lab)
- Azure subscription Contributor role
- Khi gắn Policy vào Firewall → classic rules bị vô hiệu hóa
- Threat Intel hoạt động cần Log Analytics để xem logs
- Log Analytics tốn ~$2.76/GB ingested
🏗️ Kịch Bản
Công ty triển khai hub-spoke network với nhiều VNet. Thay vì quản lý rules riêng trên từng firewall, dùng Firewall Policy tập trung. Threat Intelligence tự động block traffic từ IP/domain độc hại trong Microsoft threat feed.
Firewall Policy (fp-lab25)
├─ Threat Intelligence: Alert/Deny
├─ DNS Settings: enabled
└─ Rule Collection Groups:
├─ RCG-Priority-100 (Infrastructure)
│ └─ App Rules: allow Windows Update
└─ RCG-Priority-200 (Applications)
└─ App Rules: allow *.microsoft.com
│
└─ Applied to: fw-lab25
🧪 Các Bước Thực Hiện
Tạo Log Analytics Workspace
Log Analytics Workspace cần có trước để gắn diagnostic settings cho firewall — xem Threat Intel alerts và firewall logs.
- 1.1Log Analytics workspaces → + Create → RG: rg-lab25-policy → Name:
law-lab25→ Region: Southeast Asia - 1.2Review + Create → đợi ~2 phút deploy xong
RG="rg-lab25-policy"
LOCATION="southeastasia"
# Tạo resource group
az group create --name $RG --location $LOCATION
# Tạo Log Analytics Workspace
az monitor log-analytics workspace create \
--resource-group $RG \
--workspace-name law-lab25 \
--location $LOCATION \
--sku PerGB2018 \
--retention-time 30
# Lấy workspace ID
LAW_ID=$(az monitor log-analytics workspace show \
--resource-group $RG \
--workspace-name law-lab25 \
--query id --output tsv)
echo "Log Analytics Workspace ID: $LAW_ID"
Tạo Azure Firewall và Firewall Policy
Tạo Firewall Policy trước, rồi tạo Firewall gắn với policy ngay từ đầu (hoặc gắn sau).
- 2.1Firewall Policies → + Create → Name:
fp-lab25→ Region: Southeast Asia → Policy tier: Standard - 2.2Tab DNS Settings → DNS proxy: Enabled → DNS Servers: Default (Azure DNS)
- 2.3Tab Threat Intelligence → Mode: Alert (bắt đầu bằng Alert, sau đổi thành Deny) → Review + Create
- 2.4Tạo VNet và Firewall (tham khảo Lab 23), khi tạo Firewall → chọn Firewall policy: fp-lab25
RG="rg-lab25-policy"
LOCATION="southeastasia"
# Tạo Firewall Policy Standard với Threat Intel ở chế độ Alert
az network firewall policy create \
--resource-group $RG \
--name fp-lab25 \
--location $LOCATION \
--sku Standard \
--threat-intel-mode Alert \
--enable-dns-proxy true
# Tạo VNet + subnet (tham khảo Lab 23 script)
az network vnet create \
--resource-group $RG --name vnet-lab25 \
--address-prefix 10.0.0.0/16 \
--subnet-name AzureFirewallSubnet --subnet-prefix 10.0.1.0/26
az network vnet subnet create \
--resource-group $RG --vnet-name vnet-lab25 \
--name snet-app --address-prefix 10.0.2.0/24
az network public-ip create \
--resource-group $RG --name pip-fw-lab25 \
--sku Standard --allocation-method Static
# Tạo Firewall gắn với Policy ngay từ đầu
az network firewall create \
--resource-group $RG \
--name fw-lab25 \
--location $LOCATION \
--sku-tier Standard \
--firewall-policy fp-lab25
az network firewall ip-config create \
--firewall-name fw-lab25 --resource-group $RG \
--name fw-ipconfig \
--public-ip-address pip-fw-lab25 --vnet-name vnet-lab25
Tạo Rule Collection Group và Rules
Rule Collection Group (RCG) là tầng tổ chức mới trong Firewall Policy. RCG chứa nhiều Rule Collections, có priority riêng. Ưu tiên thấp hơn = xử lý trước (100 trước 200).
- 3.1fp-lab25 → Rule collection groups → + Add rule collection group → Name:
rcg-infrastructure→ Priority: 100 - 3.2Trong rcg-infrastructure → + Add rule collection → Type: Application → Name:
arc-windowsupdate→ Priority: 100 → Action: Allow - 3.3Rules: Source: 10.0.2.0/24 → Protocol: Https:443 → Target FQDNs:
WindowsUpdate(FQDN tag tích hợp) - 3.4Thêm RCG thứ 2: rcg-applications → Priority: 200 → Arc: allow-microsoft → FQDNs: *.microsoft.com
RG="rg-lab25-policy"
# Tạo Rule Collection Group: Infrastructure (priority 100)
az network firewall policy rule-collection-group create \
--resource-group $RG \
--policy-name fp-lab25 \
--name rcg-infrastructure \
--priority 100
# Thêm Application Rule Collection vào rcg-infrastructure
az network firewall policy rule-collection-group collection add-filter-collection \
--resource-group $RG \
--policy-name fp-lab25 \
--rule-collection-group-name rcg-infrastructure \
--name arc-windowsupdate \
--collection-priority 100 \
--action Allow \
--rule-name allow-windows-update \
--rule-type ApplicationRule \
--source-addresses "10.0.2.0/24" \
--protocols Https=443 Http=80 \
--fqdn-tags WindowsUpdate
# Tạo Rule Collection Group: Applications (priority 200)
az network firewall policy rule-collection-group create \
--resource-group $RG \
--policy-name fp-lab25 \
--name rcg-applications \
--priority 200
# Thêm Application Rule Collection vào rcg-applications
az network firewall policy rule-collection-group collection add-filter-collection \
--resource-group $RG \
--policy-name fp-lab25 \
--rule-collection-group-name rcg-applications \
--name arc-microsoft \
--collection-priority 100 \
--action Allow \
--rule-name allow-microsoft \
--rule-type ApplicationRule \
--source-addresses "10.0.2.0/24" \
--protocols Https=443 Http=80 \
--target-fqdns "*.microsoft.com" "*.azure.com"
Bật Diagnostic Settings và Cấu Hình Threat Intelligence
Gắn Log Analytics Workspace để thu thập Azure Firewall logs. Sau đó thử đổi Threat Intel từ Alert sang Deny.
- 4.1fw-lab25 → Diagnostic settings → + Add diagnostic setting → Name:
diag-fw-lab25 - 4.2Chọn logs: AzureFirewallApplicationRule, AzureFirewallNetworkRule, AzureFirewallThreatIntelLog
- 4.3Destination: Send to Log Analytics workspace → chọn law-lab25 → Save
- 4.4fp-lab25 → Overview → Threat Intelligence mode → đổi sang Deny → Save (production setting)
RG="rg-lab25-policy"
# Lấy Firewall resource ID
FW_ID=$(az network firewall show \
--resource-group $RG --name fw-lab25 --query id --output tsv)
LAW_ID=$(az monitor log-analytics workspace show \
--resource-group $RG --workspace-name law-lab25 --query id --output tsv)
# Bật Diagnostic Settings gửi logs về Log Analytics
az monitor diagnostic-settings create \
--resource "$FW_ID" \
--name diag-fw-lab25 \
--workspace "$LAW_ID" \
--logs '[
{"category":"AzureFirewallApplicationRule","enabled":true},
{"category":"AzureFirewallNetworkRule","enabled":true},
{"category":"AzureFirewallThreatIntelLog","enabled":true}
]'
# Đổi Threat Intelligence mode sang Deny (production)
az network firewall policy update \
--resource-group $RG \
--name fp-lab25 \
--threat-intel-mode Deny
# Kiểm tra policy settings
az network firewall policy show \
--resource-group $RG \
--name fp-lab25 \
--query "{threatIntelMode:threatIntelMode,dnsProxy:dnsSettings.enableProxy}" \
--output table
Xem Logs trong Log Analytics
Sau khi có traffic qua firewall (5–10 phút để logs xuất hiện), dùng KQL query để xem firewall logs và threat intel alerts.
// Xem tất cả Application Rule logs (30 phút gần nhất)
AzureDiagnostics
| where ResourceType == "AZUREFIREWALLS"
| where Category == "AzureFirewallApplicationRule"
| where TimeGenerated > ago(30m)
| project TimeGenerated, msg_s, Action=action_s, FQDN=fqdn_s
| order by TimeGenerated desc
// Xem Threat Intelligence logs
AzureDiagnostics
| where Category == "AzureFirewallThreatIntelLog"
| project TimeGenerated, msg_s, SourceIP=src_ip_s, DestIP=dst_ip_s
| order by TimeGenerated desc
// Thống kê domain bị block nhiều nhất
AzureDiagnostics
| where Category == "AzureFirewallApplicationRule"
| where action_s == "Deny"
| summarize Count=count() by FQDN=fqdn_s
| order by Count desc
| take 10
📊 Kết Quả Đầu Ra Lab 25
fw-lab25 → Firewall policy: fp-lab25, classic rules bị disable
rcg-infrastructure (100) xử lý trước rcg-applications (200)
Traffic từ known malicious IPs bị block tự động
KQL query trả về AzureFirewallApplicationRule và ThreatIntelLog
🧹 Dọn Dẹp Tài Nguyên
az group delete --name rg-lab25-policy --yes --no-wait
❓ Câu Hỏi Ôn Tập
1. Firewall Policy khác Classic Rules ở điểm gì quan trọng nhất cho môi trường multi-firewall?
Gợi ý: Policy có thể gắn vào nhiều firewall cùng lúc, hỗ trợ parent policy inheritance. Classic rules chỉ áp dụng cho 1 firewall.
2. Threat Intelligence hoạt động như thế nào? Dữ liệu threat feed lấy từ đâu?
Gợi ý: Microsoft sử dụng threat feed từ Microsoft Intelligent Security Graph — tổng hợp từ nhiều nguồn: Windows Defender, Azure Security Center, MSTIC. Cập nhật liên tục.
3. Rule Collection Group priority 100 và 200: Rule nào được xử lý trước? Tại sao đặt Infrastructure ở 100?
Gợi ý: Số nhỏ hơn được xử lý trước. Infrastructure rules (Windows Update, Azure services) cần được ưu tiên để VM không bị "kẹt" do Application rules quá restrictive.
4. FQDN Tag "WindowsUpdate" là gì? Tại sao dùng nó thay vì liệt kê tay các domain của Microsoft Update?
Gợi ý: FQDN Tags là tập hợp FQDN predefined do Microsoft quản lý (như WindowsUpdate, AzureBackup, HDInsight). Microsoft tự cập nhật danh sách — bạn không cần maintain.
5. Sự khác biệt giữa Threat Intel mode Alert vs Deny? Khi nào dùng Alert trước khi chuyển Deny?
Gợi ý: Alert → log nhưng không block (quan sát false positives). Deny → block và log. Dùng Alert trong 1–2 tuần đầu để baseline, sau đó chuyển Deny khi đã review logs.