🎯 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
- Public Services Hosting - Web Server, API Gateway, Email (SMTP/IMAP), DNS, FTP, VPN Gateway, VoIP Gateway
- Buffer Zone - รับโจมตีจาก Internet ให้ DMZ Server ตาย แทน Internal Server
- Controlled Access - จำกัดการเข้าถึงจาก DMZ → Internal (Only Specific Ports, App-to-DB)
- Monitoring & Logging - จราจรผ่าน DMZ ถูก Log/Inspect เข้มข้น
- Compliance - PCI-DSS, HIPAA ต้องการ DMZ สำหรับ Public-facing Systems
- 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
- 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
- Two Security Levels (Front: Internet→DMZ, Back: DMZ→Internal)
- Compromise Front Firewall ≠ Compromise Internal
- Load Balancing / Failover ได้ง่ายกว่า
- Denial of Service บน Front Firewall ไม่กระทบ Internal
🖥️ อะไรควรวางใน DMZ?
| ควรวางใน DMZ (Public-facing) | ห้ามวางใน DMZ (ต้องอยู่ Internal) |
|---|---|
| Web Server (Nginx, Apache, IIS) | Database Server (SQL, Oracle, MongoDB, Redis) |
| API Gateway / Reverse Proxy | Application Server (Business Logic) |
| Email Server (SMTP, IMAP, POP3) | File Server / NAS (Sensitive Data) |
| DNS Server (Authoritative Public) | Domain Controller / AD |
| VPN Gateway / Remote Access | Backup Server |
| VoIP / Session Border Controller | Internal Code Repo (GitLab, GitHub Enterprise) |
| Load Balancer (Public) | SIEM / Log Collector |
| Bastion Host / Jump Server | HR/Finance/CRM Systems |
| Proxy / Forward Proxy (Public) | Certificate Authority (Root CA) |
| Honeypot / Deception | Password Manager Vault |
🔒 การรักษาความปลอดภัย DMZ (Hardening)
🔥 DMZ vs Port Forwarding
| คุณสมบัติ | DMZ (Host/Subnet) | Port Forwarding |
|---|---|---|
| Scope | Expose ทั้ง Server (All Ports/Protocols) | Expose เฉพาะ Port ที่กำหนด |
| Security | เสี่ยงกว่า (ถ้า Server โดนแฮก = ทั้งเครื่อง) | ปลอดภัยกว่า (Limited Exposure) |
| ใช้เมื่อไหร่ | หลาย Services, Dynamic Ports, Legacy Apps, Gaming Console | Web Server (80/443), Specific App Port |
| Management | Firewall Rules แบบ Broad | Firewall 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
❓ 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?
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