组合示例
组合示例
tcpdump -nn -i eth0 'host 10.0.0.5 and (port 80 or port 443)'
tcpdump -nn -i eth0 'tcp and not port 22 and not port 443'
tcpdump -nn -i eth0 '(dst port 3306 or dst port 5432) and src net 10.0.0.0/24'
# 交互式 shell 中 ! 有历史展开风险,脚本里安全写法:
tcpdump -nn -i eth0 'not port 22'| 优先级 | not 最高,其次 and,最后 or;不确定就加括号 |
|---|---|
| 引号 | 整段表达式用单引号包裹,内部再用双引号会与 shell 冲突 |
| 常见坑 | bash 的 ! 触发历史展开(交互式),用 not 避开 |
表达式越复杂越要先用 -c 5 试跑验证语法与命中量,再放开长期抓取。