大网数据广告活动
服务器运维问答

Wireshark filtering-trying to filter out my own local ip

· 52CE 我爱测

I'm trying to filter out my local machine's IP address 192.168.5.22 . I used ip.src != 192.168.5.22|| ip.dst !=192.168.5.22 and I keep seeing my address pop up.

问题原文

原帖链接 · chris · CC BY-SA 3.0

I'm trying to filter out my local machine's IP address 192.168.5.22.

I used ip.src != 192.168.5.22|| ip.dst !=192.168.5.22 and I keep seeing my address pop up.

社区高分解答

原帖链接 · Andrew Domaszek · CC BY-SA 3.0

Mitch is right. With the negative match like you have, you need both conditions to be true to filter off your IP, thus and instead of or. You could also write it like so:

not (ip.addr == 192.168.5.22)

It might seem more logical to write it as ip.addr != 192.168.5.22, but while that's a valid expression, it will match the other end of the connection as not being the specific ip and still be true. For example, when connecting to 192.168.5.254 from 192.168.5.22, ip.addr != 192.168.5.22 doesn't match *.22 IP, it matches *.254 and thus the packet matches the filter expression. Here's a complete example to filter http as well:

not ip.addr == 192.168.5.22 and not tcp.dstport == 80

tcp.dstport != 80 suffers from a similar problem; having tcp.dstport != 80 turns out to mean "match ONLY tcp traffic, but only tcp that is not dstport == 80"

While not strictly your question, I prefer to do filtering in the capture filter (double click the interface name in the capture-options dialog), whose syntax is exactly like tcpdump. It makes the capture take less memory and disk by avoiding capturing packets you're telling it to ignore. The downside is those packets are not captured if you later want to inspect them and you can't change the filter selected this way during a capture session. For example, to keep from capturing http and ssh traffic to/from any host and any packets to or from 192.168.5.22,

not host 192.168.5.22 and not port 80 and not port 22

If you only wanted to filter http traffic to and from that host, you could do this:

not (host 192.168.5.22 and port 80)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-09-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。