Appearance
Appearance
Simple Network Management Protocol (SNMP) 用于监控和管理网络设备。在 Wireshark 中,本页主要用于识别 SNMP 流量、解析 OID/MIB,以及配置 SNMPv3 加密数据包的解密。
什么时候用:
不要混淆:
| 概念 | 含义 | 排查时注意 |
|---|---|---|
| SNMP | 网络管理协议本身 | 通常使用 UDP 161/162,但也可以运行在其他传输之上。 |
| MIB | 管理信息库定义,用于解释 OID | MIB 不等同于抓包内容;缺少 MIB 时仍可看到数字 OID。 |
| OID | 对象标识符,例如 1.3.6.1.2.1... | Wireshark 可借助 libsmi/MIB 将其解析为可读名称。 |
| SNMPv3 USM | SNMPv3 的用户安全模型 | 解密需要 engine-id、用户名、认证协议/密码、隐私协议/密码等信息。 |
| TRAP | 设备主动发出的通知类消息 | 常见端口为 UDP 162,不是普通查询的 UDP 161。 |
通常,SNMP 使用 UDP 作为传输协议。知名 UDP 端口为:
原页还说明,SNMP 也可以运行在 TCP、Ethernet、IPX 和其他协议之上;ATM 使用 SNMP 作为 ILMI(Integrated Local Management Interface)协议。
SNMP dissector 功能完整。如果配置正确,Wireshark 可以解密加密的 SNMPv3 数据包。
仅显示 SNMP 流量:
snmp抓包时不能直接过滤“SNMP 协议”本身;如果按默认 UDP 端口捕获,可使用:
udp port 161 or udp port 162如果 Wireshark 构建时包含 libsmi,它可以把数字 OID(例如 1.3.6.1.2.1.2.2.1.6.1)解析为更易读的形式(例如 IF-MIB::ifPhysAddress.1)。默认安装只包含一些常见 MIB,因此并不能解析所有厂商 OID。
配置 MIB 时注意:
DEFINITIONS 关键字来确认模块名。不同平台的原页说明:
| 平台 | 检查或存放位置 |
|---|---|
| Unix | 可在 Help -> About Wireshark 中查看是否包含 with SMI;原页说明 Wireshark 会假定 MIB 文件存储在 /usr/local/share/mibs 下。 |
| macOS | Wireshark 网站提供的二进制文件使用 libsmi 构建。 |
| Windows | Wireshark 网站提供的二进制文件使用 libsmi 构建;MIB 文件示例路径为 C:\Program Files\Wireshark\snmp\mibs。 |
在使用 libsmi 构建的 Wireshark 中,可通过 Edit -> Preferences -> Name resolution 找到 Enable OID resolution,并通过 SMI (MIB and PIB) Modules 添加或移除模块。
1.3.6.1.4.1.253...。253 对应 Xerox。printer-MIB。MIB 加载失败时,Wireshark 可能在控制台输出类似警告:
Cannot find module (IP-MIB): At line 0 in (none)原页提到旧的 WIRESHARK_DEBUG_MIBS 环境变量已在相关代码变更中弃用;如果要诊断当前版本的 MIB 加载问题,应以当前 Wireshark 日志机制和版本文档为准。
USMuserTable 文件首选项允许选择一个包含 engine-id、用户名和密码的文件,用于解密加密数据包。
注意:文件中参数顺序会随 Wireshark 版本不同而变化。如果示例不可用,应通过 Edit -> Preferences -> Protocols -> SNMP 在 GUI 中添加设置,然后查看 Wireshark 生成的 snmp_users 文件,以确认列顺序。
较新版本示例格式(原页示例路径为 ~/.wireshark/snmp_users):
# This file is automatically generated, DO NOT MODIFY.
# Engine ID, Username, Authentication model, Password, Privacy Protocol, Privacy Password
12abed,"admin","MD5","myauth","DES","mysecretkey"字段含义:
| 字段 | 说明 |
|---|---|
| Engine ID | 十六进制字符串,对应 SNMP PDU 的 snmp.msgAuthoritativeEngineID。留空时,会尝试把同用户名条目用于任意 Engine ID;旧版 Wireshark 曾使用 * 表示任意 Engine ID。 |
| Username | SNMPv3 USM 用户名。 |
| Authentication model | 原页记录 Wireshark 2.0.2 时可为 MD5 或 SHA1。 |
| Password | 认证密码。 |
| Privacy Protocol | 原页记录可为 DES、AES、AES192 或 AES256。 |
| Privacy Password | 隐私/加密密码。 |
原页还保留了一个旧格式示例,可能已过时,仅适合作为历史参考:
# this is an example snmp_users_file (e.g. ~/.wireshark/snmp_users)
# comments start with a # and finish at the end of line
# empty lines are ignored
# each record has the following fields
# engine-id username auth_pass priv_pass auth_proto priv_proto
# fields are separated by whitespace
# a '*' as engine-id matches any given engine-id
80001F888059DC486145A26322 "pippo" "plutoxxx" "PLUTOxxx" MD5 DES
* "pippo" "plutoxxx" "PLUTOxxx"
80001F888059DC486145A26322 "pippo2" "plutoxxx" "PLUTOxxx" SHA
80001F888059DC486145A26322 "pippo3" "plutoxxx" "PLUTOxxx" SHA AES
80001F888059DC486145A26322 "pippo4" "plutoxxx" "PLUTOxxx" AESWireshark 的 SNMP 协议首选项可控制:
原页提到的示例包括:
SampleCaptures/b6300a.cap:一组 GET 和 RESPONSE。原页列出的 RFC 主题包括:
原页讨论了如何判断真正需要哪个 MIB,以及能否通过在线资源找到 OID 与 MIB 的映射;并提到 http://www.mibdepot.com 可在这方面提供帮助。
于 2020-08-11 23:25:45 UTC 从 https://wiki.wireshark.org/SNMP 导入