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
- Win + R → gõ
wf.msc → Enter
- Hoặc: Win + X → Windows Terminal (Admin) → gõ
wf.msc
- Hoặc: Control Panel → System and Security → Windows Defender Firewall → Advanced settings
Kiểm tra Inbound Rules hiện có
- Trong cửa sổ Windows Defender Firewall with Advanced Security
- Chọn Inbound Rules ở pane trái
- Danh sách hiển thị: Name, Group, Profile, Enabled, Action (Allow/Block), Local Port, Remote Port, Program
- 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)
- Pane phải → New Rule...
- Rule Type: Port → Next
- Protocol and Ports:
- TCP
- Specific local ports:
443 (hoặc 80,443 cho cả HTTP/HTTPS)
- Action: Allow the connection → Next
- Profile: Tick Domain, Private (bỏ Public nếu server không trực tiếp Internet) → Next
- Name:
Allow HTTPS Inbound (TCP 443)
- 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
- Finish
Tạo Inbound Rule cho chương trình cụ thể (Program Path)
- New Rule → Program → Next
- This program path:
%ProgramFiles%\MyApp\MyApp.exe (dùng biến môi trường)
- Action: Allow the connection
- Profile: Domain, Private
- Name:
Allow MyApp Inbound
Best Practice cấu hình Inbound Rules
| Nguyên tắc | Mô 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 separation | Khô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 |
| Documentation | Mô 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
- Trên máy client:
Test-NetConnection -ComputerName SERVER_IP -Port 443 (PowerShell)
- Hoặc:
telnet SERVER_IP 443 (cài telnet client trước)
- Trên server: Monitoring → Firewall → Active Inbound Rules - xác nhận rule hiển thị
- 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 tra | Giải pháp |
| Rule Allow nhưng vẫn không kết nối được | Profile sai (Public vs Private), Rule bị disable, Rule Deny khác ưu tiên cao hơn, Sai port/protocol, Windows Firewall service stopped | Kiể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 timeout | MTU, Fragmentation, IPS/IDS chặn, Asymmetric routing | Kiểm tra MTU 1500, Bypass IPS cho IP server, Kiểm tra routing đối xứng |