Subnetting คืออะไร?
**Subnetting (การแบ่งเครือข่ายย่อย)** คือการแบ่ง **IP Network ใหญ่** ให้เป็น **Subnetworks (Subnets) หลายๆ เครือข่าย** โดยใช้ **Subnet Mask** กำหนดขอบเขต — เช่น `192.168.1.0/24` แบ่งเป็น `192.168.1.0/26` (4 Subnets, 62 hosts แต่ละอัน)
ประโยชน์ด้านความปลอดภัยของ Subnetting
1. Network Segmentation & Isolation (แยกเครือข่าย/แยกโซน) — ⭐สำคัญที่สุด
- แบ่งเครือข่ายตาม **หน้าที่/ความไว**: DMZ, Server, User, Guest, IoT, OT/ICS, Management
- ควบคุม Traffic ระหว่าง Subnet ด้วย **Firewall/ACL/Security Group** — **Default Deny, Explicit Allow**
- จำกัด **Blast Radius** — หาก Subnet หนึ่งโดนแฮก โจมตีไม่ลุกลาม Subnet อื่นง่าย
- รองรับ **Zero Trust Micro-segmentation** — แบ่งถึงระดับ Workload/Application
2. Traffic Control & Monitoring (ควบคุมและเฝ้าระวัง Traffic)
- **Firewall Rules** ระหว่าง Subnet ชัดเจน กำหนด Port/Protocol ที่อนุญาต
- **QoS / Traffic Shaping** ต่อ Subnet — ป้องกัน Abuse, ให้ความสำคัญ Critical Traffic
- **NetFlow/sFlow/IPFIX** ต่อ Subnet — มองเห็นพฤติกรรม Baseline, Detect Anomaly
- **IDS/IPS Sensor Placement** — วางที่ Strategic Choke Points ระหว่าง Subnet
3. ลด Broadcast Domain & Attack Surface
- Subnet แยก Broadcast Domain → **ลด Broadcast Storm, ARP Spoofing, DHCP Spoofing**
- ลดโอกาส **Man-in-the-Middle (MitM)** ภายใน Subnet เดียวกัน
- จำกัด **Network Discovery/Scanning** ให้อยู่ใน Subnet เดียว
4. Access Control Granularity (ควบคุมการเข้าถึงละเอียด)
- **ACL / Security Group Rules** บน Router/Firewall/Cloud (AWS SG, Azure NSG, GCP Firewall)
- กำหนดได้ว่า: **Subnet A → Subnet B: Port 443 Only**, **Subnet C → Internet: Deny All**
- รองรับ **Compliance** (PCI-DSS: Cardholder Data Environment แยก Subnet)
5. Containment & Incident Response
- หากเกิด Incident: **Block/Quarantine Subnet นั้นได้ทันที** (Blackhole Route, ACL, VLAN Shutdown)
- Forensic: Logs, PCAP แยกตาม Subnet → ระบุ Scope เร็วขึ้น
- Recovery: กู้คืน Subnet ใด Subnet หนึ่ง ไม่กระทบอื่น
Subnetting ใน Secure Network Design (Best Practices)
| Zone/Subnet | CIDR Example | Purpose | Access Control |
|---|---|---|---|
| Management | 10.10.0.0/24 | Switch, Router, Firewall Mgmt, OOB | Admin Only, Jump Host, MFA |
| Server/Application | 10.10.10.0/24 | Web, App, DB Servers | Specific Ports from DMZ/User |
| DMZ / Public | 10.10.20.0/24 | Public-facing Services (Web, Mail, VPN) | Internet → DMZ (Limited), DMZ → Internal (Restricted) |
| User/Employee | 10.10.100.0/22 | Corporate Workstations | Internet (Proxy), Internal Apps, No Direct Server Access |
| Guest / BYOD | 10.10.200.0/24 | Visitor, Personal Devices | Internet Only, No Internal Access |
| IoT / OT | 10.10.150.0/24 | Cameras, Sensors, PLC, Building Mgmt | No Internet, Specific Controller Access Only |
| VPN / Remote | 10.10.250.0/24 | Remote Access VPN Pool | ZTNA Policy, Posture Check, Limited Access |
Subnetting และ IPv6
- IPv6 ใช้ **/64 ต่อ Subnet** (มาตรฐาน) — 18,446,744,073,709,551,616 Addresses
- ไม่ต้องคิด Host Count — Focus ที่ **Segmentation & Policy**
- ใช้ **ULA (fc00::/7)** สำหรับ Internal, **GUA** สำหรับ Internet-facing
- IPv6 Security: **RA Guard, DHCPv6 Guard, ND Inspection, SEND**
เครื่องมือช่วยคำนวณ Subnet
- Web: subnetcalculator.net, ipcalc.net, cidr.xyz
- CLI: `ipcalc`, `sipcalc`, `python -m ipaddress`
- Network Design: NetBox, phpIPAM, SolarWinds IPAM, Infoblox
สรุป
Subnetting ไม่ใช่แค่ "จัดการ IP ให้หมดพอ" — มันคือ **รากฐานของ Network Segmentation** ที่ทำให้:
- 🛡️ **Contain Threats** (จำกัดการแพร่กระจาย)
- 🔍 **Visibility** (มองเห็น Traffic ชัดเจนต่อ Zone)
- 📋 **Compliance** (แยก Environment ตามมาตรฐาน)
- ⚙️ **Operational Control** (จัดการ Policy, QoS, Routing ต่อ Subnet)