Simple Network Management Protocol (SNMP) là giao thức lớp ứng dụng cho phép thiết bị mạng chia sẻ thông tin, bất kể khác biệt phần cứng hoặc phần mềm. Không có SNMP, công cụ quản lý mạng không xác định thiết bị, ghi thay đổi mạng, giám sát hiệu suất, hoặc xác định trạng thái thiết bị mạng real-time.
Trước đây, dùng Turn Windows Features on/off trong Control Panel bật/tắt SNMP. Từ Windows 1803 trở đi, Microsoft deprecated tính năng do rủi ro bảo mật và khuyên dùng Common Information Model (CIM) thay thế. Dù vậy, nếu muốn cài và bật SNMP trên PC, chúng tôi hướng dẫn cách làm.
Cách Bật SNMP Từ Settings
SNMP là optional feature trên Windows 10. Bật optional feature: Settings > Apps > Apps & features > Optional features. Click Add a feature tìm snmp. Chọn Simple Network Management Protocol (SNMP) và WMI SNMP Provider click Install.
Xong, kiểm tra SNMP có trong Services console.
Cách Bật SNMP Dùng PowerShell
Để bật SNMP qua PowerShell, trước hết đảm bảo máy có internet. Nếu có, chạy PowerShell nâng cao: Win + X chọn Windows PowerShell (Admin). Thực thi lệnh cài SNMP server từ server Microsoft:
Add-WindowsCapability -Online -Name "SNMP.Client----0.0.1.0"
Thay vào đó, cũng cài SNMP dùng DISM:
DISM /online /add-capability /capabilityname:SNMP.Client----0.0.1.0
Sau khi chạy lệnh (Add-WindowsCapability hoặc DISM) thành công, xác minh SNMP service cài bằng:
Get-WindowsCapability -Online -Name "SNMP*"
Khắc Phục Mã Lỗi 0x800f0954
Chạy lệnh báo lỗi "Add-WindowsCapability failed error. Error code = 0x800f0954", có thể do máy kéo Windows update từ WSUS internal server thay vì Microsoft Update servers.
Khắc phục bằng bypass WSUS kéo file cài SNMP từ Microsoft Update servers. Các bước:
- Thực thi lệnh bypass WSUS:
Lệnh thêm DWORD value tại "HKEY_LOCAL_MACHINE... \WindowsUpdateAU" đặt giá trị 0.reg add "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdateAU" /v UseWUServer /t REG_DWORD /d 0 /f - Khởi động lại Windows Update service 3 lệnh:
netshh winhttp reset policy
net stop wuauserv
net start wuauserv - Thử cài SNMP lại dùng Add-WindowsCapability. Nếu chạy, undo thay đổi registry bước 1:
reg add "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdateAU" /v UseWUServer /t REG_DWORD /d 1 /f - Khởi động lại Windows Update service dùng lệnh bước 2.
Cách Cấu Hình SNMP Từ Services Panel
SNMP service đã cài, cấu hình nó.
Đầu tiên, xác minh dịch vụ SNMP (SNMP Service và SNMP Trap) chạy. Win + R, gõ services.msc Enter mở Services panel. Tìm cả hai dịch vụ SNMP kiểm tra có trong danh sách.
Cũng kiểm tra SNMP Service đang chạy. Nếu không, double-click service nhấn Start. Đổi Startup type = Automatic tự chạy từ boot sau.
Chuyển tab Agent điền Contact và Location tên và vị trí. Phần Service, tick các service muốn thu thập data chuyển đến thiết bị giám sát.
Chuyển tab Security.
Thêm tên SNMP host muốn xác thực vào danh sách Accepted community names. Bạn chọn None, Notify, READ ONLY, READ WRITE, hoặc READ CREATE authentication cho community.
Tiếp, thêm server muốn nhận SNMP packets vào ô tiếp theo, đảm bảo radio button Accept SNMP packets from these hosts được chọn. Tùy chọn Accept SNMP packets from any host bỏ hết giới hạn IP cho phép mọi host gửi SNMP packets. Cẩn thận, không an toàn, nhất là máy public.
Xong, Apply, về tab General restart service (Click Stop rồi Start), OK thoát. Bước cuối mở port SNMP: UDP 161 (SNMP) và UDP 162 (SNMPTRAP). Thực thi lệnh:
netsh advfirewall firewall add rule name="SNMP UDP Port 161 In" dir=in action=allow protocol=UDP localport=161
netsh advfirewall firewall add rule name="SNMPTRAP UDP Port 162 In" dir=in action=allow protocol=UDP localport=162
netsh advfirewall firewall add rule name="SNMP UDP Port 161 Out" dir=out action=allow protocol=UDP localport=161
netsh advfirewall firewall add rule name=" SNMPTRAP UDP Port 162 Out" dir=out action=allow protocol=UDP localport=162
Cách Cấu Hình SNMP Từ Group Policy Editor
Bạn đổi Group Policy Object (GPO) tham số để cấu hình trung tâm SNMP. Mở Local Group Policy Editor điều hướng Computer Configuration > Administrative Templates > Network > SNMP cấu hình tham số.
Pane phải thấy:
- Specify communities: cho phép thêm và xác thực community gửi SNMP request.
- Specify permitted managers: cho phép thêm host gửi SNMP packets đến máy bạn.
- Specify traps for public community: cấu hình tên host nhận trap message từ SNMP service.
SNMP Service Của Bạn Đã Sẵn Sàng
Hy vọng mọi thứ suôn sẻ và bạn cài cấu hình SNMP thành công. Hơi phức tạp chạy, nhưng hy vọng một trong các cách trên hiệu quả.
Giám sát mạng quan trọng dù công việc hay nghỉ nhà. Nếu nghi ngờ người nhà ăn dữ liệu, hoặc nghi malware xâm nhập, dùng công cụ theo dõi data chuyển động mạng bắt "kẻ tham lam".