Tcpdump命令行 与 GUI Wireshark

http://www.cnblogs.com/ggjucheng/archive/2012/01/14/2322659.html


tcpdump host 192.168.1.26 and (192.168.1.27 or 192.168.1.152 )

截获主机192.168.1.26 和主机192.168.1.27或192.168.1.152的通信 (192.168.1.26从另外两接收,或者从192.168.1.26发送给另外两台电脑)

tcpdump  host 192.168.1.26 and 192.168.1.27   

192.168.1.26<---->192.168.1.27
写入tt.cap 然后在WINDOW 或者在linux 打开tt.cap文件分析


tcpdump host 192.168.1.26 and 192.168.1.27 -w tt.cap
临空指定主机TCP协议端口号:

tcpdump tcp port 10514 and host 192.168.1.26

获取主机192.168.1.26除了和主机192.168.1.27之外所有主机通信的 ip 包

tcpdump ip host 192.168.1.26 and ! 192.168.1.27

指定方向数据监控:

截获主机 192.168.1.27 发送的所有数据

tcpdump -i eth0 src host 192.168.1.27
监视所有送到主机192.168.1.27的数据包 tcpdump
-i eth0 dst 192.168.1.27
tcpdump 与wireshark

Tcpdump + Wireshark 的完美组合实现:在 Linux 里抓包,然后在Windows 里分析包。

tcpdump tcp -i eth1 -t -s 0 -c 100 and dst port ! 22 and src net 192.168.1.0/24 -w ./target.cap
(
1)tcp: ip icmp arp rarp 和 tcp、udp、icmp这些选项等都要放到第一个参数的位置,用来过滤数据报的类型
(
2)-i eth1 : 只抓经过接口eth1的包 [interface]
(
3)-t : 不显示时间戳 [timestamp]
(
4)-s 0 : 抓取数据包时默认抓取长度为68字节。加上-s 0 后可以抓到完整的数据包 :Setting snaplen to 0 means use the required length to catch whole packets.
(5)-c 100 : 只抓取100个数据包 [count]
(
6)dst port ! 22 : 不抓取目标端口是22的数据包 [dst src]:批对包(发送者信息 或者 目标者信息)过滤
(
7)src net 192.168.1.0/24 : 数据包的源网络地址为192.168.1.0/24
(8)-w ./target.cap : 保存成cap文件,方便用ethereal(即wireshark)分析
原文地址:https://www.cnblogs.com/zengkefu/p/5580885.html