Computer >> Hướng Dẫn Máy Tính >  >> Kết Nối Mạng >> An Ninh Mạng

Thiết bị an ninh mạng kiểm soát gói tin vào/ra: Firewall - Hoạt động, loại, cấu hình và Best Practices

Firewall: Thiết bị kiểm soát traffic Inbound/Outbound

Firewall (Tường lửa) là hệ thống an ninh mạng (phần cứng, phần mềm hoặc cloud) giám sát và kiểm soát lưu lượng mạng đến (inbound) và đi (outbound) dựa trên các quy tắc bảo mật xác định trước (Security Policies/Rules). Nó thiết lập rào chắn giữa mạng tin cậy (Trusted - Internal) và mạng không tin cậy (Untrusted - Internet, DMZ, Partner Network).

Cơ chế hoạt động cốt lõi

  1. Packet Inspection: Kiểm tra Header (Src/Dst IP, Src/Dst Port, Protocol, Flags) và/hoặc Payload.
  2. Rule Matching (Top-down): So khớp gói tin với danh sách quy tắc theo thứ tự ưu tiên (Priority). Quy tắc khớp đầu tiên được áp dụng (Allow/Deny/Drop/Reject).
  3. Stateful Inspection (Stateful Firewall - Tiêu chuẩn hiện nay): Duy trì State Table (Connection Table) theo dõi trạng thái kết nối (TCP Handshake, UDP pseudo-session). Tự động cho phép Return Traffic của kết nối đã Allow (không cần rule Outbound riêng). Phát hiện anomaly (Out-of-state, Invalid flags).
  4. Application Layer Inspection (L7 / Next-Gen): Hiểu giao thức ứng dụng (HTTP, DNS, SMTP, SQL, SSH, RDP...). Cho phép kiểm soát chi tiết: URL, File Type, User Agent, SQL Command, Command Injection...
  5. Identity Awareness: Map IP → User/Group (AD/Azure AD/IdP) → Policy based on User/Group, không chỉ IP.
  6. Threat Prevention (NG-FW): IPS (Intrusion Prevention), Anti-Malware (Sandbox/ML), URL Filtering, DNS Security, SSL/TLS Inspection, C2 Blocking, Credential Phishing Prevention.

3 Loại Firewall chính (Theo tiến hóa)

Lưu ý: "Proxy Firewall" / "Application Layer Gateway (ALG)" là kỹ thuật kiểm tra L7 cũ, chậm, ít dùng độc lập, thường tích hợp trong NGFW.

Phân loại theo Form Factor

  • Hardware Appliance: Hộp chuyên dụng (ASIC/NPU offload). Throughput cao, HA cứng. Data Center, Perimeter, Large Branch.
  • Virtual Appliance (VM-Series, vFW): Chạy trên Hypervisor (VMware, Hyper-V, KVM) / Cloud (AWS, Azure, GCP). Cho Virtualized Env, Cloud, Branch ảo.
  • Cloud-Native / Cloud-Delivered (FWaaS): Zscaler Cloud Firewall, Palo Alto Cloud NGFW, FortiGate CNF, Cisco Cloud Firewall, AWS Network Firewall, Azure Firewall, Google Cloud Firewall. No hardware, elastic scale, SASE/SSE component.
  • Container Firewall / Micro-segmentation: Calico, Cilium, NeuVector, Aqua, KubeArmor. East-West traffic trong K8s.

Firewall Rules - Cú pháp 5-Tuple + Extensions

Rule: Name, Description, Action (Allow/Deny/Drop/Reset), Enabled
Source: Zone/Interface, IP/Range/Group, User/Group (User-ID), Region/Geo, FQDN, ASG
Destination: Zone/Interface, IP/Range/Group, FQDN, Service Tag, Region/Geo
Application / Service: App-ID (facebook, ssl, ssh, custom) OR Service (TCP/443, UDP/53, Any)
URL Category / Profile: (Optional) URL Filtering Profile, File Blocking Profile, Spyware Profile, Vulnerability Profile, Antivirus Profile, WildFire Profile, Data Filtering Profile, SSL Decryption Profile
Logging: Start/End/Both, Send to Panorama/Log Collector/Syslog/SIEM
Schedule: Time-based enforcement

Best Practices cấu hình & vận hành

  1. Default Deny (Implicit Deny): Rule cuối cùng: Deny All. Chỉ Allow cái cần thiết (Least Privilege).
  2. Naming Convention: FW____ (vd: FW_PROD_IN_WEB_010). Description bắt buộc.
  3. Zone-based Policy: Định nghĩa Zone (Trust, Untrust, DMZ, Mgmt, Server, Guest, IoT, OT). Policy giữa Zone. Không dùng Interface-based policy.
  4. App-ID thay vì Port: Dùng App-ID (ssl, web-browsing, ms-teams, custom-app) thay vì TCP/443, TCP/80. Kiểm soát chính xác app, bypass port hopping.
  5. SSL Decryption (TLS Inspection): BẮT BUỘC cho Outbound (Forward Proxy) và Inbound (Reverse Proxy/Inbound Inspection) để thấy bên trong HTTPS (95%+ traffic). Cert management, Exclusion list (Banking, Health, Privacy).
  6. User-ID Integration: Map IP→User (AD, Azure AD, Okta, Captive Portal, GlobalProtect). Policy theo User/Group (HR, Finance, IT, Contractor).
  7. High Availability (HA): Active/Passive (A/P) hoặc Active/Active (A/A). Session Sync, Config Sync, Link Monitoring, Path Monitoring. Test Failover định kỳ.
  8. Logging & Monitoring: Log All (Allow + Deny) → SIEM (Splunk, Sentinel, Elastic, QRadar). Alert: Deny from Internal, Allow to High-Risk Country/Category, Threat Hits, HA Failover, Config Change.
  9. Change Management: Request → Risk Assessment → Approval → Staging/Pre-prod Test → Implementation Window → Verification → Rollback Plan → Documentation. Automation (Terraform, Ansible, API, Panorama).
  10. Rule Cleanup: Định kỳ (Quarterly): Remove Unused Rules (Hit count = 0 > 90d), Shadowed Rules, Redundant Rules, Expired Rules. Optimize Order.
  11. Firmware/Signature Updates: Auto-update Threat Signatures (Apps, Threats, AV, WildFire). Firmware: Test lab → Staged Rollout. Vendor Support Lifecycle.

Layer 3 vs Layer 4 vs Layer 7 Firewall

  • L3 Firewall: Lọc dựa trên IP Src/Dst (Routing/ACL). Không hiểu Port/Protocol sâu.
  • L4 Firewall (Stateful): Lọc IP + Port + Protocol + State (TCP/UDP Session). Hiểu "Conversation".
  • L7 Firewall (NGFW / Proxy / WAF): Hiểu Application Protocol (HTTP, DNS, SMTP, SQL, SSH, RDP...). Kiểm soát nội dung, hành vi, user, file, lệnh.

Kết luận

Firewall (đặc biệt NGFW) là thiết bị trung tâm kiểm soát traffic In/Out. Hiệu quả phụ thuộc vào: Chính sách Default Deny, App-ID/User-ID, SSL Decryption, HA, Logging/SIEM Integration, Change Management, Rule Hygiene, Signature/Firmware Update. Trong kiến trúc hiện đại (Zero Trust/SASE), Firewall Perimeter vẫn cần thiết nhưng phải kết hợp với ZTNA, CASB, SWG, EDR, Cloud FW, Micro-segmentation để bảo vệ toàn diện.

LoạiĐặc điểmVí dụ
1. Packet Filtering (Stateless)Chỉ kiểm tra Header (IP, Port, Proto). Không theo dõi state. Nhanh, ít resource. Không thấy context kết nối. Dễ bypass (IP Spoofing, Fragmentation).Router ACL, Linux iptables (basic), Cisco ASA (chế độ stateless).
2. Stateful InspectionTheo dõi State Table. Hiểu TCP handshake, UDP flow. An toàn hơn, hiệu năng tốt. Tiêu chuẩn thập kỷ 2000-2010.Check Point Statefull Inspection, Cisco ASA/PIX, Juniper SRX, FortiGate (base), Palo Alto (base).
3. Next-Generation Firewall (NGFW) - Tiêu chuẩn hiện tạiStateful + App-ID (L7) + User-ID + Threat Prevention (IPS, AV, Sandbox, URL, DNS, SSL Inspect) + Central Management & Automation. Single-pass architecture (parallel processing) để giữ hiệu năng.Palo Alto Networks (Pioneer), Fortinet FortiGate, Check Point Quantum, Cisco Secure Firewall (Firepower), Sophos XGS, Hillstone, Sangfor, NSFocus.