macos - macos 中“任何”伪设备的模拟
问题描述
是否有可能通过 tcpdump 从 MacOS 中的所有设备捕获数据包?在 Linux 中,我会使用“sudo tcpdump -i any”。在我的 MacOS 中,当我执行“sudo tcpdump -D”时,我看不到“任何”伪设备。
解决方案
根据@ChristopherMaynard:
tcpdump 文档指定any
为在 linux 上工作:On Linux systems with 2.2 or later kernels, an interface argument of ``any'' can be used to capture packets from all interfaces.
但是,它实际上并不是特定于操作系统的。
tcpdumpany
在我的测试中接受了 macos 上的接口,所以在回答你的问题时,any
在 linux 上的模拟是any
在 macos 上:
bash-5.0 $ sudo tcpdump -i any
tcpdump: data link type PKTAP
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type PKTAP (Apple DLT_PKTAP), capture size 262144 bytes
09:43:57.789302 IP6 dsldevice7.attlocal.net.domain > 2600:1700:a700:7340:6dad:2758:c536:f29f.56483: 4283 1/0/0 SOA (85)
09:43:57.789324 IP6 2600:1700:a700:7341:6dad:2759:c536:f29f > dsldevice7.attlocal.net: ICMP6, destination unreachable, unreachable port, 2600:1700:a700:7340:6ded:2759:c536:f29f udp port 56423, length 141
...
tcpdump 在 macos 和 linux 上应该有相同的选项(manpage),除了下面详述的那些。如果你有旧版本的 tcpdump(我的版本是 4.9.3/Apple 版本 83.200.3),你可以用brew install tcpdump
.
Macos/Linux Tcpdump 差异
如有疑问,您仍应查看联机帮助页,但这是对差异的总结:
Linux
-Q direction
:选择发送/接收方向(in/out/inout)
苹果系统
-k
: 控制数据包元数据的显示-Q
:指定基于数据包元数据的过滤器表达式-P
: 保存到 pcapng
注意:与 Linux 或 *BSD 不同,Macos不支持 -Q 方向。
推荐阅读
- django - 对各种模型实例进行批量操作
- c# - C# 使用 GetType 将值分配给字符串中的属性
- git - 主分支之前的部署分支
- java - java多线程求和
- python - 如何 zip() 多行以制表符分隔的文件以转置文件内容?
- ios - mapKit 错误作为“UIImageView”类型的值没有成员“锚”
- python - 数据框计算列不返回数值
- javascript - RxJS - Epic 只读 1 个 Promise
- android - Android Studio 布局预览没有得到我当前的主题
- android - 如何从使用 Ionic Framework 中的相机插件选择的视频文件 URI 创建 Blob?