抓包保存到文件的命令参数是-w xxx.cap
抓eth1的包
tcpdump -i eth1 -w /tmp/xxx.cap
抓 192.168.1.123的包
tcpdump -i eth1 host 192.168.1.123 -w /tmp/xxx.cap
抓192.168.1.123的80端口的包
tcpdump -i eth1 host 192.168.1.123 and port 80 -w /tmp/xxx.cap
抓目标地址是192.168.1.123的80端口的包
tcpdump -i eth1 dst 192.168.1.123 and port 80 -w /tmp/xxx.cap
抓192.168.1.123的icmp的包
tcpdump -i eth1 host 192.168.1.123 and icmp -w /tmp/xxx.cap
抓eth1非arp,rarp的包
tcpdump -i eth1 not arp and not rarp
抓包日志中显示IP,不进行IP解析
tcpdump -i eth1 -n
抓192.168.1.123的80端口和110和25以外的其他端口的包
tcpdump -i eth1 host 192.168.1.123 and ! port 80 and ! port 25 and ! port 110
-w /tmp/xxx.cap
抓vlan 1的包
tcpdump -i eth1 port 80 and vlan 1 -w /tmp/xxx.cap
抓pppoe的密码
tcpdump -i eth1 pppoes -w /tmp/xxx.cap
使用易读的时间戳
tcpdump -tttt -i eth1
以100m大小分割保存文件, 超过100m另开一个文件 -C 100m
抓10000个包后退出 -c 10000
抓取大于/小于N bytes 的包
tcpdump -i eth1 greater 1024
tcpdump -i eth1 less 1024
后台抓包, 控制台退出也不会影响:
nohup tcpdump -i eth1 port 110 -w /tmp/xxx.cap &
抓下来的文件可以直接用ethereal 或者wireshark打开。