Firewall Là Gì?

Firewall là hệ thống bảo mật network giám sát và kiểm soát incoming và outgoing traffic dựa trên security rules đã được định nghĩa. Firewall là line of defense đầu tiên giữa trusted internal network và untrusted external networks như internet.

Firewall concept không mới – từ năm 1980s khi internet bắt đầu phổ biến. Tuy nhiên, firewalls hiện đại đã tiến hóa từ simple packet filtering sang complex next-generation firewalls với deep packet inspection, intrusion prevention, và application awareness.

Các Loại Firewall

1. Packet Filtering Firewall

Loại firewall đơn giản nhất, kiểm tra packet headers và apply rules dựa trên source/destination IP, port numbers, và protocol type. Hoạt động ở Layer 3 và Layer 4.

  • Ưu điểm: Fast, low latency, simple to implement
  • Nhược điểm: Không inspect payload, dễ bị spoofing attacks, không stateful

2. Stateful Inspection Firewall

Giữ track của active connections trong state table. Chỉ allow responses to established connections, không allow unsolicited inbound traffic. Hoạt động smarter hơn packet filtering.

  • Ưu điểm: Track connection states, better security than packet filter
  • Nhược điểm: Higher memory usage cho state tables, complex to configure

3. Proxy Firewall (Application-Level Gateway)

Acts as intermediary giữa client và destination server. Proxy receives requests, inspects payload, và forward nếu pass rules. Complete protocol inspection possible.

  • Ưu điểm: Full application layer visibility, logs all content
  • Nhược điểm: Higher latency vì inspection overhead

4. Next-Generation Firewall (NGFW)

Modern firewalls với advanced features:

  • Deep Packet Inspection (DPI) – inspect payload không chỉ headers
  • Application-layer filtering – identify specific apps (Facebook, Netflix)
  • Intrusion Prevention System (IPS)
  • SSL/TLS inspection – decrypt và inspect encrypted traffic
  • Threat intelligence integration
  • User identity awareness (Active Directory integration)

5. Cloud-based Firewall (Firewall as a Service – FWaaS)

Như Cloudflare, Zscaler, AWS Security Groups. Policy-based filtering được apply ở cloud edge trước khi traffic đến origin. Đặc biệt hữu ích cho distributed architectures và remote workers.

Firewall Rules – Cách Hoạt Động

Firewall rules được evaluate theo thứ tự (top to bottom). Khi traffic matches một rule, action được take và không continue checking rules phía dưới.

Default Rule Configuration

  • Default deny – Block all traffic not explicitly allowed
  • Default allow – Allow all traffic not explicitly blocked (không recommended)

Rule Components

  • Source IP/Range – 192.168.1.0/24, any, specific IP
  • Destination IP/Range – 10.0.0.1, any, internal subnet
  • Protocol – TCP, UDP, ICMP, any
  • Port/Port Range – 80, 443, 22, 5000-6000
  • Action – Allow, deny, drop, reject, log

Zone-Based Firewall

Thay vì viết rules cho từng IP, organization define security zones và apply policies giữa zones:

  • Trust Zone – Internal corporate network
  • DMZ Zone – Public-facing servers (web, email)
  • Untrust Zone – Internet
  • Guest Zone – Guest WiFi

Policy giữa Trust → Untrust: Deny Inbound, Allow Outbound. Policy giữa DMZ → Untrust: Allow Outbound only.

Stateful vs Stateless Firewall

FeatureStatelessStateful
Connection TrackingNoYes – state table
Rule EvaluationPer packetPer packet + connection context
PerformanceFast (less memory)Slower (state table)
Security LevelBasicHigher
ExampleBasic home router ACLEnterprise firewall

Common Firewall Ports và Services

PortServiceSecurity Note
22SSHAllow from trusted IPs only
80HTTPConsider redirect to HTTPS
443HTTPSEncrypted, but verify certificates
3389RDPHigh risk – never expose to internet
3306MySQLOnly allow from app servers
5432PostgreSQLOnly allow from internal networks
25SMTPLimit to mail gateway servers

Firewall Deployment Scenarios

Home/SOHO Network

Consumer routers có built-in firewall với basic ACLs. NAT functioning như implicit firewall. Đủ cho basic protection nhưng không đủ cho business security.

DMZ Architecture

Public servers đặt trong DMZ (Demilitarized Zone) – network segment tách biệt từ internal LAN. Firewall rules chỉ allow specific traffic từ internet đến DMZ, không bao giờ allow internet → internal direct access.

Cloud Security Groups

AWS Security Groups, Azure NSGs hoạt động như stateful firewalls cho cloud instances. Default deny, chỉ allow what you need. Ví dụ: Web server allow 80/443 from anywhere, DB server allow 3306 from app server subnet only.

Firewall Logging và Monitoring

Firewall logs cung cấp visibility vào network traffic và potential threats:

  • Allowed connections – Audit trail cho compliance
  • Denied connections – Detect potential scanning/attacks
  • Rule matches – Verify rules work as intended
  • Bandwidth usage – Identify unusual traffic patterns

Nên integrate firewall logs với SIEM (Security Information and Event Management) như Splunk, ELK stack, hoặc cloud-native solutions để correlate events và detect threats real-time.

Common Firewall Bypass Techniques

Attackers sử dụng nhiều phương pháp để bypass firewall restrictions:

  • Port hopping – Tunnel malicious traffic qua allowed ports (VD: SSH over port 443)
  • Protocol tunneling – Encapsulate prohibited protocols trong allowed protocols
  • IP fragmentation – Split packets để evade detection
  • DNS tunneling – Encapsulate data trong DNS queries/responses

NGFWs với deep packet inspection và SSL inspection giúp detect và block nhiều bypass attempts này.

Firewall Best Practices

  • Default deny – Block everything not explicitly allowed
  • Principle of least privilege – Chỉ allow necessary ports, IPs, protocols
  • Regular rule review – Audit và remove stale rules
  • Zone segmentation – Separate network into security zones
  • Monitor logs – Review denied traffic patterns
  • Update firmware – Keep firewall software patched
  • Backup configurations – Document before making changes

Web Application Firewall (WAF)

WAF protect web applications khỏi attacks như SQL injection, XSS, CSRF. Khác với network firewall, WAF operate at Layer 7 (Application) và inspect HTTP traffic.

  • Cloud WAF – Cloudflare, AWS WAF, Imperva
  • Inline WAF – F5 ASM, Fortinet FortiWeb
  • Software WAF – ModSecurity, NAXI

Kết Luận

Firewall là component thiết yếu của network security architecture. Từ simple packet filtering đến next-generation platforms, firewall evolution reflect sự phức tạp ngày càng của threats. Effective firewall strategy kết hợp multiple layers: network firewall, WAF, host-based firewall, và proper segmentation.

Các Câu Hỏi Thường Gặp (FAQ)

1. Firewall và Antivirus khác nhau thế nào?

Firewall kiểm soát network traffic ở packet level – quyết định allow hay block dựa trên IP, port, protocol. Antivirus scan files và processes ở endpoint để detect malware. Cả hai bổ trợ nhau: firewall block unauthorized network access, antivirus detect malicious software đã bypassed firewall hoặc arrived via other vectors.

2. Tường lửa Windows có đủ không?

Windows Firewall đủ cho basic protection trên single endpoint. Tuy nhiên, nó không provide network-wide visibility, centralized management, hoặc advanced threat detection của enterprise firewalls. Trong business environment, cần dedicated hardware/software firewall ở network perimeter.

3. Stateful vs Stateless – loại nào tốt hơn?

Stateful firewalls better cho most use cases vì chúng track connection states và automatically allow return traffic. Stateless firewalls fast hơn nhưng require manual rules cho return traffic và không detect unauthorized connections attempt. Modern networks almost universally use stateful inspection.

4. Làm sao để test firewall rules?

Sử dụng port scanners như nmap từ external location để verify ports exposed. Từ inside network, verify traffic flows correctly giữa segments. Cloud providers cung cấp security group simulators. Regular penetration testing giúp identify misconfigurations.

5. Firewall có thể prevent DDoS không?

Traditional firewalls không designed để handle volumetric DDoS attacks vì bandwidth capacity limited. NGFW có some rate limiting capabilities nhưng không đủ cho large attacks. Effective DDoS protection cần dedicated solutions như Cloudflare, Akamai, hoặc AWS Shield ở network edge trước khi traffic đến firewall.

Chào các bạn mình là Quốc Hùng , mình sinh ra thuộc cung song tử ,song tử luôn khẳng định chính mình ,luôn luôn phấn đấu vượt lên phía trước ,mình sinh ra và lớn lên tại vùng đất võ cổ truyền ,đam mê của mình là coder ,ngày đi học tối về viết blog ...