Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบเครือข่าย >> ความปลอดภัยเครือข่าย

จำนวนกฎสูงสุดของ Network Security Group (NSG) ใน Azure

คำตอบสรุป: ขีดจำกัดกฎ NSG ใน Azure

ประเภทขีดจำกัดค่าเริ่มต้น (Default)ขีดจำกัดสูงสุด (Max Limit)วิธีเพิ่ม
กฎต่อ NSG หนึ่งกลุ่ม (Rules per NSG)200 กฎ1,000 กฎเปิด Support Request (Ticket) ไปที่ Azure Support
NSG ต่อ Subscription ต่อ Region5,000 NSGไม่ระบุ (ขึ้นกับโควต้า)ขอเพิ่มโควต้าผ่าน Support Request
NSG ที่ผูกกับ Subnet เดียว1 NSG1 NSGไม่สามารถเพิ่มได้ (1 Subnet = 1 NSG)
NSG ที่ผูกกับ NIC เดียว1 NSG1 NSGไม่สามารถเพิ่มได้ (1 NIC = 1 NSG)

NSG (Network Security Group) คืออะไร?

Network Security Group (NSG) เป็นไฟร์วอลล์ระดับเครือข่ายใน Azure ใช้ควบคุมการจราจรเข้า-ออก (Inbound/Outbound) ไปยังทรัพยากร Azure เช่น Virtual Machines, Subnets, Network Interfaces

โครงสร้างกฎ NSG (Security Rule)

แต่ละกฎประกอบด้วย:

  • Name - ชื่อกฎ (ไม่ซ้ำใน NSG เดียวกัน)
  • Priority - ลำดับความสำคัญ (100-4096, ต่ำกว่า = สำคัญกว่า)
  • Source / Destination - IP CIDR, Service Tag, Application Security Group
  • Source Port / Destination Port - พอร์ตหรือช่วงพอร์ต (เช่น 80, 443, 1000-2000)
  • Protocol - TCP, UDP, ICMP, ESP, AH, หรือ * (ทั้งหมด)
  • Action - Allow (อนุญาต) หรือ Deny (ปฏิเสธ)
  • Direction - Inbound (เข้า) หรือ Outbound (ออก)

กฎเริ่มต้นของ NSG (Default Rules)

Inbound (เข้า)

  • AllowVNetInBound (Priority 65000) - อนุญาตจราจรภายใน VNet เดียวกัน
  • AllowAzureLoadBalancerInBound (Priority 65001) - อนุญาต Health Probe ของ Azure Load Balancer
  • DenyAllInBound (Priority 65500) - ปฏิเสธทั้งหมดที่ไม่ตรงกฎข้างบน

Outbound (ออก)

  • AllowVnetOutBound (Priority 65000) - อนุญาตออกไป VNet เดียวกัน
  • AllowInternetOutBound (Priority 65001) - อนุญาตออกสู่อินเทอร์เน็ต
  • DenyAllOutBound (Priority 65500) - ปฏิเสธทั้งหมดที่ไม่ตรงกฎข้างบน

หมายเหตุ: กฎเริ่มต้นไม่สามารถลบได้ แต่สามารถเขียนกฎใหม่ Priority ต่ำกว่า (เช่น 100-1000) เพื่อ Override ได้

NSG vs Azure Firewall

คุณสมบัติNSGAzure Firewall
Layer (OSI)Layer 3 (Network) + Layer 4 (Transport)Layer 3, 4, 7 (Application)
Stateful Inspectionใช่ (พื้นฐาน)ใช่ (ขั้นสูง)
Application Rule (FQDN, HTTP/HTTPS)ไม่มีมี
Threat Intelligenceไม่มีมี (Built-in)
SNAT / DNATไม่มีมี
ราคาฟรี (จ่ายค่า NSG rules limit)จ่ายตามชั่วโมง + ข้อมูลที่ประมวลผล
เหมาะสำหรับควบคุมพอร์ต/IP พื้นฐานEnterprise, App-layer filtering, Centralized logging

Best Practices การใช้ NSG

  1. ผูก NSG ที่ Subnet ระดับแรก (Management, Web, App, DB Subnet แยกกัน)
  2. ใช้ Application Security Groups (ASG) แทนการระบุ IP เฉพาะ - จัดกลุ่ม VM ตามบทบาท
  3. Service Tags ใช้แทน IP Range ของ Azure Services (เช่น AzureCloud, Storage, Sql)
  4. Priority ให้ห่างกัน (100, 200, 300...) เพื่อแทรกกฎใหม่ง่าย
  5. Document ทุกกฎ ใน Description field
  6. Monitor ด้วย NSG Flow Logs ส่งไป Log Analytics / Event Hub
  7. Review กฎทุกไตรมาส ลบกฎไม่ใช้, รวมกฎซ้ำ

การสร้าง NSG ใน Azure Portal

  1. Azure Portal > Create a resource
  2. ค้นหา Network Security Group > Create
  3. Subscription, Resource Group, Region, Name
  4. Create > รอ Deploy สำเร็จ
  5. เข้า NSG > Inbound/Outbound security rules > Add
  6. ผูกกับ Subnet: Subnets > + Associate

ข้อจำกัดเพิ่มเติมที่ควรทราบ

  • Priority Range: 100 - 4096 (สำหรับกฎผู้ใช้), 65000+ (สำหรับกฎเริ่มต้น)
  • ไม่สามารถมี Priority ซ้ำ ใน Direction เดียวกัน (Inbound/Outbound แยกกัน)
  • กฎถูกประมวลผลตาม Priority ต่ำสุดก่อน หาตรงกฎแรกก็หยุด (First Match Wins)
  • Flow Logs เก็บได้สูงสุด 1 ปี ใน Storage Account
  • NSG ไม่รองรับ Geo-blocking ต้องใช้ Azure Firewall หรือ WAF

สรุป

Default: 200 กฎ/NSG | Max: 1,000 กฎ/NSG (ต้องขอ Support Ticket) | 1 NSG ต่อ 1 Subnet/NIC | ใช้ ASG + Service Tags เพื่อลดจำนวนกฎและจัดการง่ายขึ้น