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

Cách kiểm tra và cấu hình quy tắc tường lửa cho lưu lượng vào (Inbound Traffic)

Quản lý Inbound Rules (Quy tắc lưu lượng vào) trên Windows Firewall

Inbound traffic là lưu lượng mạng khởi tạo từ bên ngoài (Internet, mạng khác) hướng vào thiết bị/server của bạn. Cấu hình đúng inbound rules trên tường lửa là then chốt để bảo vệ server cho phép truy cập hợp pháp nhưng chặn tấn công.

Khái niệm cốt lõi

  • Inbound Rule: Quy tắc cho phép/chặn kết nối vào máy (ví dụ: cho phép port 80/443 vào web server)
  • Outbound Rule: Quy tắc cho phép/chặn kết nối ra từ máy (ví dụ: cho phép server cập nhật Windows Update)
  • Default behavior: Windows Firewall chặn tất cả inbound trừ rule cho phép, cho phép tất cả outbound trừ rule chặn

Cách mở Windows Firewall Advanced Security

  1. Win + R → gõ wf.msc → Enter
  2. Hoặc: Win + X → Windows Terminal (Admin) → gõ wf.msc
  3. Hoặc: Control Panel → System and Security → Windows Defender Firewall → Advanced settings

Kiểm tra Inbound Rules hiện có

  1. Trong cửa sổ Windows Defender Firewall with Advanced Security
  2. Chọn Inbound Rules ở pane trái
  3. Danh sách hiển thị: Name, Group, Profile, Enabled, Action (Allow/Block), Local Port, Remote Port, Program
  4. Có thể lọc: Filter by Profile (Domain/Private/Public), Action, Enabled

Tạo Inbound Rule mới (Ví dụ: Cho phép HTTPS vào Web Server)

  1. Pane phải → New Rule...
  2. Rule Type: Port → Next
  3. Protocol and Ports:
    • TCP
    • Specific local ports: 443 (hoặc 80,443 cho cả HTTP/HTTPS)
  4. Action: Allow the connection → Next
  5. Profile: Tick Domain, Private (bỏ Public nếu server không trực tiếp Internet) → Next
  6. Name: Allow HTTPS Inbound (TCP 443)
  7. Description: Cho phép truy cập HTTPS vào web server. Tạo ngày XX/XX/XXXX bởi [Tên admin]. Ticket: XXX
  8. Finish

Tạo Inbound Rule cho chương trình cụ thể (Program Path)

  1. New Rule → Program → Next
  2. This program path: %ProgramFiles%\MyApp\MyApp.exe (dùng biến môi trường)
  3. Action: Allow the connection
  4. Profile: Domain, Private
  5. Name: Allow MyApp Inbound

Best Practice cấu hình Inbound Rules

Nguyên tắcMô tả
Least Privilege (Đặc quyền tối thiểu)Chỉ mở port/IP/protocol thực sự cần thiết. Không dùng "Any" trừ khi bắt buộc
Scope restriction (Giới hạn phạm vi)Tab Scope: Chỉ định Remote IP addresses cụ thể (VPN subnet, IP quản trị, CIDR khách hàng)
Profile separationKhông bật rule trên profile Public cho server nội bộ
Naming convention[ALLOW/BLOCK] [Protocol] [Port] [Mục đích] [Source]. VD: ALLOW TCP 443 WebServer LAN
DocumentationMô tả rõ: lý do, chủ sở hữu, ticket, ngày review tiếp theo
Group Policy (Doanh nghiệp)Triển khai qua GPO: Computer Configuration → Policies → Windows Settings → Security Settings → Windows Defender Firewall with Advanced Security

Kiểm tra rule có hiệu lực không

  1. Trên máy client: Test-NetConnection -ComputerName SERVER_IP -Port 443 (PowerShell)
  2. Hoặc: telnet SERVER_IP 443 (cài telnet client trước)
  3. Trên server: Monitoring → Firewall → Active Inbound Rules - xác nhận rule hiển thị
  4. Xem log: Monitoring → Firewall → Logging Settings → bật log dropped/allowed packets

Cảnh báo bảo mật

  • KHÔNG BAO GIỜ tạo rule Allow All Inbound (Any-Any-Allow) trên production
  • Chặn mặc định các port nguy hiểm: 135, 139, 445 (SMB), 3389 (RDP - chỉ cho VPN/IP quản trị), 1433 (SQL), 3306 (MySQL)
  • Sử dụng IPsec trong rule (tab Advanced → Customize → Require authentication) cho traffic nhạy cảm
  • Đồng bộ với Network Firewall (hardware firewall) - lớp bảo vệ đầu tiên

Troubleshooting thường gặp

Vấn đềKiểm traGiải pháp
Rule Allow nhưng vẫn không kết nối đượcProfile sai (Public vs Private), Rule bị disable, Rule Deny khác ưu tiên cao hơn, Sai port/protocol, Windows Firewall service stoppedKiểm tra profile network (Get-NetConnectionProfile), Enable rule, Sắp xếp thứ tự ưu tiên, Kiểm tra port/service, Khởi động lại service MpsSvc
Kết nối chậm/lỗi timeoutMTU, Fragmentation, IPS/IDS chặn, Asymmetric routingKiểm tra MTU 1500, Bypass IPS cho IP server, Kiểm tra routing đối xứng