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

วิธีเพิ่มผู้ใช้/กฎใน Network Security Group (NSG) บน Azure

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

NSG (Network Security Group) เป็นกลุ่มกฎความปลอดภัย (Security Rules) ที่ควบคุมการเข้าออกของトラฟฟิก (Inbound/Outbound) ไปยังทรัพยากร Azure เช่น VM, Subnet, NIC โดยใช้หลักการ Allow/Deny ตาม Priority

ส่วนประกอบของ NSG Rule

  • Name - ชื่อกฎ
  • Priority - ลำดับความสำคัญ (100-4096, ต่ำกว่า = สำคัญกว่า)
  • Source / Destination - IP CIDR, Service Tag, Application Security Group (ASG)
  • Protocol - TCP, UDP, ICMP, * (ทั้งหมด)
  • Port Range - พอร์ตปลายทาง (เช่น 80, 443, 22, 3389, *)
  • Action - Allow หรือ Deny
  • Direction - Inbound หรือ Outbound

วิธีสร้างและเพิ่มกฎใน NSG (Azure Portal)

  1. เข้า Azure Portal > Create a resource > Networking > Network Security Group
  2. กรอก Subscription, Resource Group, Name, Region > Create
  3. หลังสร้างเสร็จ คลิกเข้า NSG > เมนู Inbound security rules หรือ Outbound security rules
  4. กด + Add > กรอกข้อมูลกฎ > Add

เชื่อมโยง NSG กับทรัพยากร

  • Subnet: NSG ผูกกับ Subnet → ใช้กับทุก VM ใน Subnet นั้น
  • NIC (Network Interface): NSG ผูกกับ NIC ของ VM เฉพาะตัว → ควบคุมละเอียดกว่า
  • แนะนำ: ใช้ทั้งคู่ (Subnet + NIC) เพื่อ Layered Security

Application Security Group (ASG)

ASG ใช้จัดกลุ่ม VM ตามหน้าที่ (เช่น Web-Servers, DB-Servers) แล้วอ้างอิงใน NSG Rule แทน IP Address ทำให้จัดการง่ายขึ้นเมื่อ Scale Out

NSG vs Azure Firewall

คุณสมบัติNSGAzure Firewall
OSI LayerL3, L4L3, L4, L7
StatefulYesYes
Application InspectionNoYes (L7)
Threat IntelligenceNoYes
ค่าใช้จ่ายฟรี (ค่า NSG Rules)มีค่าใช้จ่ายรายชั่วโมง + ต่อ GB

Best Practices

  • ตั้ง Priority ให้เว้นช่อง (100, 200, 300...) เพื่อเพิ่มกฎระหว่างทางได้
  • ใช้ Service Tags (AzureCloud, AzureLoadBalancer, Internet, VirtualNetwork) แทน IP
  • ใช้ ASG สำหรับจัดกลุ่ม Workload
  • Deny All เป็นกฎสุดท้าย (Priority สูงสุด) แล้ว Allow เฉพาะที่จำเป็น
  • Log 流量 ไป Log Analytics Workspace เพื่อ Audit

สรุป

NSG คือ Firewall ระดับ Network บน Azure ควบคุม Inbound/Outbound ด้วยกฎ Allow/Deny สร้างผ่าน Portal/CLI/PowerShell ผูกกับ Subnet หรือ NIC ควบคู่กับ ASG เพื่อจัดการ Scale ได้ดี