কম্পিউটার টিউটোরিয়াল

Azure-এ নেটওয়ার্ক সিকিউরিটি গ্রুপ (NSG) ভিউ/ম্যানেজ করার পদ্ধতি

Azure Network Security Group (NSG) দেখুন, ম্যানেজ করুন এবং মনিটর করুন — সম্পূর্ণ গাইড

Azure NSG হলো Layer 3/4 স্টেটফুল ফায়ারওয়াল যা Subnet বা NIC লেভেলে ইনবাউন্ড/আউটবাউন্ড ট্রাফিক ফিল্টার করে। নিচে Azure Portal, CLI, PowerShell, এবং মোনিটরিং টুলস দিয়ে NSG ভিউ/ম্যানেজ করার পদ্ধতি দেওয়া হলো।

১. Azure Portal দিয়ে NSG খুঁজে বের করা ও ভিউ করা

  1. Azure Portal (portal.azure.com) → Sign in।
  2. Search Bar-এ **Network Security Groups** টাইপ করুন → সিলেক্ট করুন।
  3. লিস্ট থেকে আপনার NSG-এ ক্লিক করুন।
  4. Overview পেইনে: Resource Group, Location, Subnet/NIC Associations, Rules Summary দেখবেন।
  5. Settings → Inbound Security Rules / Outbound Security Rules → সব রুল দেখুন/এডিট করুন।
  6. Settings → Network Interfaces / Subnets → কোন রিসোর্সে অ্যাটাচড আছে তা দেখুন।

২. Azure CLI দিয়ে NSG লিস্ট, ডিটেইল, রুল ম্যানেজমেন্ট

# সব NSG লিস্ট (সাবসক্রিপশন লেভেল):
az network nsg list --output table

# নির্দিষ্ট NSG ডিটেইল:
az network nsg show --resource-group rg-prod-network --name nsg-vm-web-prod --output json

# Inbound Rules লিস্ট:
az network nsg rule list --resource-group rg-prod-network --nsg-name nsg-vm-web-prod --output table

# নির্দিষ্ট রুল ডিটেইল:
az network nsg rule show --resource-group rg-prod-network --nsg-name nsg-vm-web-prod --name Allow-HTTP

# নতুন রুল তৈরি (উদাহরণ: Allow HTTPS from Specific IP):
az network nsg rule create \
  --resource-group rg-prod-network \
  --nsg-name nsg-vm-web-prod \
  --name Allow-HTTPS-Admin \
  --priority 105 \
  --source-address-prefixes 203.0.113.10 \
  --destination-port-ranges 443 \
  --protocol Tcp --access Allow \
  --description "Admin HTTPS Access"

# NSG Subnet Association চেক:
az network vnet subnet show --resource-group rg-prod-network --vnet-name vnet-prod --name subnet-web --query networkSecurityGroup.id

# NSG NIC Association চেক:
az network nic show --resource-group rg-prod-network --name nic-vm-web-01 --query networkSecurityGroup.id

৩. PowerShell (Az.Network Module) দিয়ে

# Connect
Connect-AzAccount

# List NSGs
Get-AzNetworkSecurityGroup | Format-Table ResourceGroupName, Name, Location, ProvisioningState -AutoSize

# Get NSG with Rules
$nsg = Get-AzNetworkSecurityGroup -ResourceGroupName "rg-prod-network" -Name "nsg-vm-web-prod"
$nsg.SecurityRules | Format-Table Name, Priority, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, DestinationAddressPrefix, Access, Direction -AutoSize

# Get Effective Security Rules (VM NIC Level - Real Evaluation):
Get-AzEffectiveNetworkSecurityGroup -NetworkInterfaceName "nic-vm-web-01" -ResourceGroupName "rg-prod-network" |
  Select-Object -ExpandProperty EffectiveSecurityRules |
  Format-Table Name, Priority, Protocol, SourceAddressPrefix, DestinationAddressPrefix, DestinationPortRange, Access, Direction -AutoSize

৪. NSG Flow Logs & Traffic Analytics (Monitoring/Visibility)

  1. NSG Resource → **Monitoring → Flow logs** → **Create/Enable**।
  2. Storage Account বা Log Analytics Workspace** সিলেক্ট করুন।
  3. Traffic Analytics: ON করুন (Geo-location, Protocol Distribution, Top Talkers, Malicious IP Detection, Flow Visualization)。——
  4. Retention: **৯০+ দিন** (Compliance Requirement)。——

৫. NSG Flow Logs কোয়েরি করা (KQL / Log Analytics)

// NSG Flow Logs Raw Query
AzureNetworkAnalytics_CL
| where TimeGenerated > ago(24h)
| where FlowStatus_s == "A" // Allowed
| summarize Count = count() by SrcIP_s, DestIP_s, DestPort_d, Protocol_s, RuleName_s
| order by Count desc

// Traffic Analytics - Top Blocked Flows
AzureNetworkAnalytics_CL
| where FlowStatus_s == "D" // Denied
| summarize BlockedCount = count() by SrcIP_s, DestIP_s, DestPort_d, RuleName_s
| order by BlockedCount desc
| limit 20

// Malicious IP Detection (via Traffic Analytics)
AzureNetworkAnalytics_CL
| where MaliciousIP_s == "True"
| project TimeGenerated, SrcIP_s, DestIP_s, DestPort_d, ThreatIntel_s

৬. Effective Security Rules (ভেরিফিকেশন: NSG আসলে কী ব্লক/অ্যালাউ করছে)

Subnet NSG + NIC NSG + Default Rules মিলে **Effective Rules** বানায়। এটি চেক করতে:

  • Portal: VM Resource → Networking → **Effective Security Rules** ট্যাব।
  • CLI: az network nic list-effective-nsg --resource-group rg --name nic-name।
  • PowerShell: Get-AzEffectiveNetworkSecurityGroup (উপরে উদাহরণ দেওয়া আছে)।

৭. NSG ডিলিট / ডিসঅসোসিয়েট করা

# Subnet থেকে ডিসঅসোসিয়েট:
az network vnet subnet update --resource-group rg --vnet-name vnet --name subnet --remove networkSecurityGroup

# NIC থেকে ডিসঅসোসিয়েট:
az network nic update --resource-group rg --name nic --remove networkSecurityGroup

# NSG ডিলিট (Association থাকলে ডিলিট হবে না - প্রথমে ডিসঅসোসিয়েট করুন):
az network nsg delete --resource-group rg --name nsg-name

৮. NSG vs Azure Firewall: কখন কী ব্যবহার করবেন

ফিচারNSGAzure Firewall
OSI LayerLayer 3/4 (IP, Port, Protocol)Layer 3/4/7 (App ID, FQDN, TLS Inspection)
StatefulYesYes
Threat IntelligenceNo (Custom Rules Only)Yes (Microsoft TI Feed, Custom)
FQDN FilteringNo (Service Tags Only)Yes (Wildcard FQDN, SQL/Storage FQDN)
SNAT/DNATNoYes
ScalabilityPer Subnet/NICCentralized, Hub-Spoke Model
CostFree (Rules Only)~$1.25/hr + Data Processing

সুপারিশ: NSG = Micro-segmentation, VM/Subnet Level Control (Free)। Azure Firewall = Centralized Egress/Ingress Inspection, Threat Intel, App Layer Control (Paid)। **দুইটো একসাথে ব্যবহার করুন** (Hub-Spoke Architecture)。——

৯. কম্প্লায়েন্স ও গভర్నেন্স (Policy/Initiative)

  • Azure Policy: "NSG Flow Logs should be enabled", "NSG should restrict RDP/SSH from Internet", "NSG should not allow 0.0.0.0/0 on 22/3389"।
  • Microsoft Defender for Cloud: **Adaptive Network Hardening** — ML-Based NSG Rule Recommendations (Machine Learning analyzes traffic patterns & suggests rules)。——
  • Initiative: Azure Security Benchmark, CIS Azure Foundations, PCI-DSS, NIST SP 800-53, ISO 27001।

সারমর্ম: Azure NSG ম্যানেজমেন্টের জন্য: **Portal** দিয়ে ভিউ/এডিট, **CLI/PowerShell/Bicep/Terraform** দিয়ে অটোমেশন/IaC, **Flow Logs + Traffic Analytics** দিয়ে ভিজিবিলিটি, **Effective Rules** দিয়ে ভেরিফিকেশন, **Azure Policy/Defender for Cloud** দিয়ে গভর্ণেন্স। NSG বিনামূল্যে কিন্তু শক্তিশালী—সঠিকভাবে ব্যবহার করুন।

  1. নেটওয়ার্ক নিরাপত্তা কী এবং এটি কীভাবে কাজ করে?

  2. নেটওয়ার্ক সিকিউরিটি ইনফো (Information) কীভাবে দেখবেন?

  3. Windows 10-এ নেটওয়ার্ক সিকিউরিটি কী (Wi-Fi পাসওয়ার্ড) দেখার সম্পূর্ণ গাইড

  4. ভিন্ডোজে নেটওয়ার্ক সিকিউরিটি ইনফো দেখার পদ্ধতি