Home » Firewall Best Practices: Rule Design และ Zone-Based Policy
Firewall Best Practices: Rule Design และ Zone-Based Policy
Firewall Best Practices: Rule Design และ Zone-Based Policy
Firewall เป็นด่านแรกของ network security ที่ควบคุม traffic เข้าออก network แต่ firewall จะมีประสิทธิภาพก็ต่อเมื่อ rules ถูกออกแบบมาอย่างดี Firewall ที่มี rules เยอะ ซ้ำซ้อน หรือ allow มากเกินไป อาจเป็นช่องโหว่ขนาดใหญ่ที่ให้ความรู้สึกปลอดภัยเทียม (false sense of security)
หลายองค์กรมี firewall rules หลายร้อยถึงหลายพัน rules ที่สะสมมาหลายปี ไม่มีใครรู้ว่า rule ไหนยังจำเป็น rule ไหนซ้ำซ้อน หรือ rule ไหนเปิดกว้างเกินไป (any-any) การ review และ optimize firewall rules เป็นสิ่งที่ต้องทำเป็นประจำ บทความนี้จะสอน best practices สำหรับ firewall rule design
Firewall Types
| Type |
Layer |
ตรวจสอบอะไร |
ตัวอย่าง |
| Packet Filter |
L3-L4 |
IP, port, protocol |
iptables, ACLs |
| Stateful Firewall |
L3-L4 |
+ connection state tracking |
Cisco ASA, pfSense |
| NGFW (Next-Gen) |
L3-L7 |
+ application, user identity, content |
Palo Alto, Fortinet, Check Point |
| WAF (Web Application) |
L7 |
HTTP/HTTPS traffic, OWASP attacks |
AWS WAF, Cloudflare, F5 ASM |
Zone-Based Firewall Design
| Zone |
Trust Level |
ประกอบด้วย |
| Outside (Untrust) |
0 (lowest) |
Internet, public networks |
| DMZ |
25 |
Web servers, mail servers, DNS |
| Users |
50 |
Desktops, laptops, phones |
| Servers |
75 |
Application servers, databases |
| Management |
100 (highest) |
Firewall, switches, routers management |
Inter-Zone Policy Matrix
| Source → Dest |
Outside |
DMZ |
Users |
Servers |
Management |
| Outside |
– |
HTTP/HTTPS |
DENY |
DENY |
DENY |
| DMZ |
Limited |
– |
DENY |
API ports |
DENY |
| Users |
HTTP/HTTPS/DNS |
HTTP/HTTPS |
– |
App ports |
DENY |
| Servers |
Updates only |
DENY |
DENY |
– |
DENY |
| Management |
Limited |
SSH/HTTPS |
SSH/HTTPS |
SSH/HTTPS |
– |
Rule Design Principles
| Principle |
รายละเอียด |
| Least Privilege |
Allow เฉพาะ traffic ที่จำเป็น deny ที่เหลือทั้งหมด |
| Deny by Default |
Default policy = deny all, explicit allow ที่จำเป็น |
| Specific before General |
Rules ที่ specific อยู่ก่อน rules ที่ general |
| Most Used First |
Rules ที่ match บ่อยอยู่บน → ลด processing time |
| No Any-Any Rules |
ห้ามมี rule ที่ source=any, dest=any, service=any |
| Document Every Rule |
ทุก rule ต้องมี comment อธิบาย who, what, why, when |
| Expiration Date |
Temporary rules ต้องมีวันหมดอายุ |
Rule Order
| Order |
Rule Category |
ตัวอย่าง |
| 1 |
Anti-spoofing |
Block RFC1918 from outside, block own IPs from outside |
| 2 |
Block known threats |
Block blacklisted IPs, known C2 IPs |
| 3 |
Allow established/related |
Stateful: allow return traffic for established connections |
| 4 |
Allow specific services |
Allow HTTP/HTTPS to DMZ, allow DNS outbound |
| 5 |
Allow management |
Allow SSH/HTTPS from management IPs |
| 6 |
Log & deny rest |
Log + deny all (cleanup rule) |
Common Mistakes
| Mistake |
Risk |
Fix |
| Any-any-any rules |
Bypass firewall completely |
Replace กับ specific rules ทีละ service |
| ไม่ review rules เป็นประจำ |
Stale rules สะสม → security holes |
Review ทุก 3-6 เดือน remove unused rules |
| ไม่ log deny rules |
ไม่เห็น attack attempts |
Log ทุก deny rule (ดู syslog/SIEM) |
| Allow outbound any |
Data exfiltration, C2 communication |
Allow เฉพาะ ports ที่จำเป็น outbound |
| ไม่มี change management |
Unauthorized rule changes |
ใช้ change request process สำหรับ firewall changes |
| Shadow rules |
Rules ที่ถูก override โดย rules ข้างบน |
ตรวจหา shadow rules ด้วย firewall analysis tools |
Firewall Audit Checklist
| Check |
Action |
| Any-any rules |
หาและ replace ด้วย specific rules |
| Unused rules |
ดู hit count = 0 → ลบหรือ disable |
| Shadow rules |
หา rules ที่ไม่เคย match (shadowed by rules above) |
| Expired rules |
ลบ temporary rules ที่หมดอายุแล้ว |
| Overly permissive |
Rules ที่ allow มากเกินจำเป็น → tighten |
| Documentation |
ทุก rule มี comment + owner + date |
| Logging |
Deny rules ทั้งหมด log ไป SIEM |
NGFW Features
| Feature |
ประโยชน์ |
| Application Control |
Allow/block ตาม application (ไม่ใช่แค่ port) |
| User Identity |
Rules based on AD username/group (ไม่ใช่แค่ IP) |
| IPS/IDS |
ตรวจจับ + block known exploits/attacks |
| URL Filtering |
Block website categories (gambling, malware, etc.) |
| SSL Decryption |
Decrypt HTTPS เพื่อ inspect content |
| Threat Intelligence |
Block known malicious IPs/domains (real-time feeds) |
ทิ้งท้าย: Firewall = Only as Good as Its Rules
Firewall ไม่มีค่าถ้า rules ไม่ดี Deny by default + allow เฉพาะที่จำเป็น Zone-based design: Outside → DMZ → Users → Servers → Management ห้ามมี any-any rules, document ทุก rule Review + audit ทุก 3-6 เดือน
อ่านเพิ่มเติมเกี่ยวกับ Network Segmentation และ DNS Security DNSSEC ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com