Firewall (Tường lửa) là gì?
Firewall là thiết bị phần cứng hoặc phần mềm giám sát, kiểm soát lưu lượng mạng vào/ra dựa trên tập quy tắc bảo mật (security policy) được định nghĩa trước. Mục tiêu: Cho phép traffic hợp pháp, chặn traffic độc hại/trái phép.
Firewall hoạt động tại ranh giới mạng (perimeter) và các phân đoạn nội bộ (segmentation), là dòng phòng thủ đầu tiên (first line of defense) trong mô hình Defense in Depth.
Cơ chế hoạt động của Firewall
- Packet Inspection: Kiểm tra header gói tin (Layer 3/4: IP src/dst, Port src/dst, Protocol TCP/UDP/ICMP).
- Stateful Inspection: Theo dõi trạng thái kết nối (Connection Table: SYN, SYN-ACK, ESTABLISHED, FIN/RST). Chỉ cho phép traffic thuộc kết nối hợp lệ đã thiết lập.
- Application Layer Inspection (Layer 7 / DPI): Phân tích payload: HTTP host, URL, User-Agent, DNS query, TLS SNI, SSH version, RDP cookie, SMB dialect.
- Policy Enforcement: So sánh với rulebase (từ trên xuống, first match). Action: Allow, Deny, Drop, Reset, Log, Alert, Quarantine, Rate-limit.
- Advanced Services (NGFW): IPS (Intrusion Prevention), AV (Antivirus), URL Filtering, File Blocking (by hash/type), SSL Decryption, App-ID, User-ID, WildFire/Cloud Sandbox.
3 Loại Firewall chính (Theo kiến trúc)
| Loại | Mô tả | Ưu điểm | Nhược điểm | Ví dụ |
|---|---|---|---|---|
| Packet Filtering (Stateless) | Kiểm tra header từng gói tin độc lập, không nhớ trạng thái. | Nhanh, đơn giản, ít tài nguyên. | Dễ bypass (IP spoofing, fragment), không hiểu context. | ACL trên Router/Switch, Linux iptables/nftables basic. |
| Stateful Inspection | Theo dõi state table, hiểu ngữ cảnh kết nối. | Cân bằng hiệu năng/bảo mật, chuẩn mực 20 năm. | Không thấy sâu Layer 7, không phòng zero-day app. | Check Point (người tiên phong), Cisco ASA (legacy), pfSense, FortiGate (chế độ flow-based). |
| Application Layer / Proxy / Next-Gen (NGFW) | Proxy kết nối (terminate client, initiate server), DPI toàn payload, App-ID, User-ID, SSL Decrypt, IPS, AV, Sandbox. | Bảo vệ sâu, kiểm soát app/user, phòng zero-day tốt hơn. | Tốn CPU/RAM, latency cao hơn, phức tạp config, giá cao. | Palo Alto Networks, FortiGate, Check Point Quantum, Cisco Secure Firewall (FTD), Sophos XGS, Juniper SRX. |
5 Loại Firewall theo chức năng triển khai (Deployment)
- Perimeter Firewall (Edge): Giữa Internet và DMZ/Internal. Throughput cao, rule nhiều, HA Active/Active hoặc Active/Passive.
- Internal Segmentation Firewall (ISFW): Chia segment nội bộ (IT/OT, PCI, Dev/Prod, Department). East-West traffic control, micro-segmentation.
- Data Center / Cloud Firewall: Bảo vệ workload cloud (AWS TGW + FW, Azure Firewall, GCP Firewall, Palo Alto VM-Series, FortiGate-VM).
- FWaaS (Firewall as a Service) / SASE: Cloud-delivered, cho remote user, branch office. Ví dụ: Zscaler, Netskope, Cato, Palo Alto Prisma Access, Cloudflare Magic Firewall.
- Host-based / Endpoint Firewall: Windows Defender Firewall, Linux iptables/nftables/ufw, macOS PF. Bảo vệ endpoint khi roaming.
Các tính năng nâng cao của NGFW (Next-Generation Firewall)
- App-ID: Nhận diện ứng dụng bất kể port/protocol (Facebook, BitTorrent, TeamViewer, SSH, RDP, SQL, DNS).
- User-ID: Map IP address → User identity (AD, LDAP, SAML, Kerberos, Captive Portal, GP Client).
- SSL Decryption (Forward Proxy / Inbound Inspection): Giải mã TLS để kiểm tra payload (malware, data exfil, C2).
- IPS (Intrusion Prevention System): Signature-based (CVE, exploit) + Anomaly-based.
- WildFire / Cloud Sandbox: Chạy file nghi ngờ trong VM izolated, phân tích hành vi (static + dynamic).
- DNS Security / DNS Sinkholing: Chặn C2, DGA, malicious domain.
- IoT/OT Security: Device profiling, behavioral baseline, IEC 62443 compliance.
Best Practice cấu hình & vận hành Firewall
- Default Deny (Implicit Deny): Chặn tất cả, chỉ cho phép rule explicit.
- Least Privilege: Rule cụ thể: Source IP/User/Zone, Destination IP/Zone, App, Port, Schedule.
- Zone-based Policy: Định nghĩa Zone (Untrust, DMZ, Trust, Server, Mgmt, Guest) → Policy inter-zone.
- SSL Decryption chiến lược: Decrypt outbound (forward proxy) cho user, inbound (reverse proxy) cho server public. Bypass financial/health/privacy category.
- Logging & Monitoring: Log all deny, log allow critical app, gửi SIEM, bật correlation rule.
- Rule Lifecycle Management: Review hàng quý: unused rule (0 hit 90 ngày), shadow rule, redundant rule, expired rule. Tự động hóa bằng Firewall Policy Management (Tufin, AlgoSec, FireMon, Skybox).
- High Availability (HA): Active/Passive (stateful sync session), Active/Active (load sharing). Test failover định kỳ.
- Firmware & Signature Update: Auto-update threat signature (hourly), firmware patch critical CVE (72h).
- Admin Security: MFA cho admin, Role-based admin (Read-only, Policy Admin, Superuser), Jump host/Bastion, Privileged Access Management.
Firewall trong mô hình Zero Trust
Firewall truyền thống = "Trust but verify" (Tin cậy nội bộ). Zero Trust = "Never trust, always verify".
- Firewall trở thành Policy Enforcement Point (PEP) cho Zero Trust.
- Policy Decision Point (PDP) tập trung (ZTNA Controller) quyết định allow/deny dựa trên: User identity, Device posture, Location, Time, App sensitivity, Threat intel.
- Micro-segmentation: Firewall phân tán (distributed) tại từng host/hypervisor (VMware NSX, Cisco ACI, Calico, Cilium) enforce policy East-West.
Kết luận
Firewall là thành phần bất khả thi của an ninh mạng, nhưng không phải "cây gậy thần". NGFW hiện đại kết hợp DPI, App-ID, User-ID, SSL Decrypt, IPS, Sandbox, DNS Security. Tuy nhiên, để bảo vệ toàn diện, firewall phải hoạt động trong hệ sinh thái: Zero Trust + Identity + Endpoint (EDR) + Cloud (CNAPP/SASE) + Data (DLP/Encryption) + SOC (SIEM/SOAR/Threat Hunting).