用 netsh trace 在 Windows 上抓取网络数据包
使用内置的 netsh trace 上下文开始 ETL 抓包——服务器上不想装 Wireshark 时的轻量方案。
运行 netsh trace start capture=yes tracefile=C:\temp\nettrace.etl 开始抓包,用 netsh trace stop 结束并合并追踪文件。
01命令
命令
$ netsh trace start capture=yes tracefile=C:\temp\nettrace.etl maxsize=51202作用说明
netsh trace 从 Windows Server 2008 起就已内置,但需要抓包时几乎没人记得它。除了抓原始数据包(capture=yes),它还能按 provider 场景追踪(如 scenario=Connectivity),停止时会生成带关联日志的 CAB 文件。生成的 .etl 可用 Microsoft Network Monitor 打开,或用 etl2pcapng 转换成 Wireshark 可读格式。
03风险
!注意: 抓包会一直进行直到执行 netsh trace stop——忘了停止会写满 maxsize 后继续覆盖记录;ETL 文件也很大,tracefile 请指定在空间充足的路径。
04撤销
撤销
$ netsh trace stop05来源
- netsh trace | Microsoft Learn依据: Microsoft documents 'netsh trace start' with capture=yes and tracefile parameters to begin a packet capture, and 'netsh trace stop' to end it and correlate the logs.
- NETSH - Windows CMD依据: SS64 documents the netsh trace context, including scenario-based tracing and capture options.
最后验证: 2026-09-17 · 分类: 网络