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

DMZ ในความปลอดภัยเครือข่าย คืออะไร? (Demilitarized Zone) คู่มือฉบับสมบูรณ์

🎯 DMZ (Demilitarized Zone) คืออะไร?

DMZ (Demilitarized Zone / Perimeter Network) = โซนเครือข่ายที่แยกออกมา ระหว่าง Internet (Untrusted) และ Internal Network (Trusted) ใช้วาง Server/Bankend ที่ต้องให้บริการสาธารณะ (Public-facing) โดยไม่เสี่ยงเครือข่ายภายในโดยตรง

นามมาจาก DMZ (เขต منزوعة السلاح) ระหว่างเกาหลีเหนือ-ใต้ - พื้นที่กลางที่ห้ามมีกองทัพ

🏗️ สถาปัตยกรรม DMZ (Architecture)

Single Firewall (Three-Legged) - ราคาถูก สำหรับ SMB

Internet ── Firewall (3 Interfaces) ── Internal LAN
                │
                └── DMZ (Web Server, Mail Server, DNS, VPN Gateway)
  • Firewall หนึ่งตัว มี 3 Interface: WAN, LAN, DMZ
  • Rule: Internet → DMZ (Allow Specific), DMZ → LAN (Deny/Restrict), LAN → DMZ (Allow Management)
  • เสี่ยง: Firewall Unique Point of Failure, Misconfiguration แทรกซ้อน

Dual Firewall (Back-to-Back) - มาตรฐาน Enterprise

Internet ── Firewall 1 (Front-end) ── DMZ ── Firewall 2 (Back-end) ── Internal LAN
  • Front-end Firewall: ป้องกันจาก Internet → DMZ (Allow 80/443/53/25/VPN)
  • Back-end Firewall: ป้องกันจาก DMZ → Internal (Strict, Only App→DB, Management)
  • ข้อดี: Defense in Depth, แยกหน้าที่, Compromise DMZ ไม่ได้ Internal ทันที
  • ข้อเสีย: แพงกว่า, ซับซ้อนกว่า, Latency เพิ่มเล็กน้อย

Cloud DMZ (AWS/Azure/GCP)

  • Public Subnet = DMZ (ALB/NLB, NAT Gateway, Bastion Host, VPN Gateway)
  • Private Subnet = Internal (App Server, Database, Cache)
  • Security Groups + NACLs = Firewall Rules
  • AWS: Internet Gateway → Public Subnet (DMZ) → NAT Gateway → Private Subnet

🎯 วัตถุประสงค์หลักของ DMZ

  1. Public Services Hosting - Web Server, API Gateway, Email (SMTP/IMAP), DNS, FTP, VPN Gateway, VoIP Gateway
  2. Buffer Zone - รับโจมตีจาก Internet ให้ DMZ Server ตาย แทน Internal Server
  3. Controlled Access - จำกัดการเข้าถึงจาก DMZ → Internal (Only Specific Ports, App-to-DB)
  4. Monitoring & Logging - จราจรผ่าน DMZ ถูก Log/Inspect เข้มข้น
  5. Compliance - PCI-DSS, HIPAA ต้องการ DMZ สำหรับ Public-facing Systems
  6. 🖥️ อะไรควรวางใน DMZ?

    ควรวางใน DMZ (Public-facing)ห้ามวางใน DMZ (ต้องอยู่ Internal)
    Web Server (Nginx, Apache, IIS)Database Server (SQL, Oracle, MongoDB, Redis)
    API Gateway / Reverse ProxyApplication Server (Business Logic)
    Email Server (SMTP, IMAP, POP3)File Server / NAS (Sensitive Data)
    DNS Server (Authoritative Public)Domain Controller / AD
    VPN Gateway / Remote AccessBackup Server
    VoIP / Session Border ControllerInternal Code Repo (GitLab, GitHub Enterprise)
    Load Balancer (Public)SIEM / Log Collector
    Bastion Host / Jump ServerHR/Finance/CRM Systems
    Proxy / Forward Proxy (Public)Certificate Authority (Root CA)
    Honeypot / DeceptionPassword Manager Vault

    🔒 การรักษาความปลอดภัย DMZ (Hardening)

    • Minimal Services - รันเฉพาะ Service ที่จำเป็น ปิด Port/Service ที่ไม่ใช้
    • OS Hardening - CIS Benchmarks, Disable Root/Administrator Login, SSH Key Only
    • Patch Management - Critical Patch ภายใน 72 ชม., Auto-update ถ้าเป็นได้
    • WAF (Web Application Firewall) - ป้องกัน OWASP Top 10 (SQLi, XSS, RCE)
    • HIPS/EDR - บน DMZ Servers ทุกตัว
    • File Integrity Monitoring (FIM) - Tripwire, OSSEC, Wazuh
    • Network Segmentation ใน DMZ - Web Tier, App Tier, Proxy Tier แยก Subnet/VLAN
    • Outbound Internet Access - จำกัด DMZ → Internet (Only Update Repos, Licensing, API Partners)
    • Vulnerability Scanning - สัปดาห์/เดือน + Agent-based Continuous
    • Penetration Testing - ปีละครั้ง / หลัง Major Change

    🔥 DMZ vs Port Forwarding

    คุณสมบัติDMZ (Host/Subnet)Port Forwarding
    ScopeExpose ทั้ง Server (All Ports/Protocols)Expose เฉพาะ Port ที่กำหนด
    Securityเสี่ยงกว่า (ถ้า Server โดนแฮก = ทั้งเครื่อง)ปลอดภัยกว่า (Limited Exposure)
    ใช้เมื่อไหร่หลาย Services, Dynamic Ports, Legacy Apps, Gaming ConsoleWeb Server (80/443), Specific App Port
    ManagementFirewall Rules แบบ BroadFirewall Rules แบบ Granular
    แนะนำหลีกเลี่ยง DMZ Host (Single IP) ใช้ Port Forwarding + WAF แทน✅ Best Practice สำหรับ Public Services

    ⚠️ DMZ Host (Router Feature "DMZ Host") ต่างจาก DMZ Network
    DMZ Host = Forward ทุก Port ไปยัง 1 Internal IP (อันตราย) | DMZ Network = Isolated Segment (ปลอดภัย)

    🛡️ DMZ ในกรอบ Zero Trust

    • Zero Trust ไม่ได้ "ทิ้ง" DMZ แต่ ขยายหลักการ Zero Trust เข้าไปใน DMZ
    • DMZ Servers: Identity-based Access, mTLS, Continuous Verification, Micro-segmentation
    • ไม่มี Implicit Trust ระหว่าง DMZ Servers เอง (East-West Encryption)
    • ZTNA (Zero Trust Network Access) แทน VPN สำหรับ Admin Access ไป DMZ

    ❓ FAQ

    DMZ ยังใช้อยู่ไหม? (Are DMZs still used?)

    ใช่ ยังใช้กันอย่างแพร่หลาย โดยเฉพาะ Enterprise, Cloud, Hybrid แม้ Zero Trust จะยิ่งนิยม DMZ ยังคงเป็น Network Segmentation Pattern ที่มีประสิทธิภาพสำหรับ Public-facing Services

    ต้องมี Firewall 2 ตัวเสมอไหม?

    ไม่บังคับ Single Firewall (3-legged) ทำได้ แต่ Dual Firewall ปลอดภัยกว่า (Defense in Depth) Enterprise ควรใช้ Dual

    DMZ อยู่ "นอก" Firewall ไหม?

    DMZ อยู่ ระหว่าง Front-end Firewall (Internet-facing) และ Back-end Firewall (Internal-facing) ถือว่าเป็น Semi-trusted Zone

    ข้อดีของ Dual Firewall DMZ?

    1. Two Security Levels (Front: Internet→DMZ, Back: DMZ→Internal)
    2. Compromise Front Firewall ≠ Compromise Internal
    3. Load Balancing / Failover ได้ง่ายกว่า
    4. Denial of Service บน Front Firewall ไม่กระทบ Internal

    DMZ Trusted หรือ Untrusted?

    Untrusted จากมุมมอง Internal Network (Traffic จาก DMZ → Internal ถูก Deny by Default)
    Semi-trusted จากมุมมอง Internet (มี Public Services ที่เข้าถึงได้)

    สรุป

    DMZ = Buffer Zone ระหว่าง Internet และ Internal Network
    วาง: Public-facing Servers (Web, Mail, DNS, VPN, API Gateway)
    ห้ามวาง: Database, AD, Sensitive Data, Business Logic
    架构: Single Firewall (SMB) หรือ Dual Firewall (Enterprise) หรือ Cloud Public Subnet
    Best Practice: ไม่ใช้ "DMZ Host" (Port Forward All) ใช้ Port Forwarding + WAF + Micro-segmentation + Zero Trust Principles