tcpdump -i any host ip地址(例192.168.1.1) -n
yum install tcpdump -y
tcpdump: verbose output suppressed,
use -v or -vv for full protocol decode listening on any,
link-type LINUX_SLL (Linux cooked),
capture size 262144 bytes 12:46:39.994082 IP 192.168.1.1 > 192.168.1.2: ICMP echo request, id 12555, seq 13, length 64
12:46:39.994140 IP 192.168.1.2 > 192.168.1.1: ICMP echo reply, id 12555, seq 13, length 64
12:46:40.995101 IP 192.168.1.1 > 192.168.1.2: ICMP echo request, id 12555, seq 14, length 64
12:46:40.995144 IP 192.168.1.2 > 192.168.1.1: ICMP echo reply, id 12555, seq 14, length 64
12:46:41.996738 IP 192.168.1.1 > 192.168.1.2: ICMP echo request, id 12555, seq 15, length 64
12:46:41.996783 IP 192.168.1.2 > 192.168.1.1: ICMP echo reply, id 12555, seq 15, length 64
12:46:42.997791 IP 192.168.1.1 > IP 192.168.1.2 : ICMP echo request, id 12555, seq 16, length 64
12:46:42.997828 IP 192.168.1.2 > IP 192.168.1.1: ICMP echo reply, id 12555, seq 16, length 64
12:46:43.998973 IP 192.168.1.1 > IP 192.168.1.2 : ICMP echo request, id 12555, seq 17, length 64
过滤网卡
tcpdump -i eth0 #抓取所有经过网卡eth0数据包
tcpdump -i lo #抓取环回口的数据包
过滤主机/IP
tcpdump host 192.168.10.10 #抓取所有IP为192.168.10.10的数据包
tcpdump src host 192.168.10.10 #抓取所有源IP为192.168.10.10的数据包
tcpdump dst host 192.168.10.10 #抓取所有目的IP为192.168.10.10的数据包
过滤端口:
tcpdump port 1234 #抓取所有端口为1234的网络数据
tcpdump src port 1234 #抓取所有源端口为1234的网络数据
tcpdump dst port 1234 #抓取所有目的端口为1234的网络数据
过滤特定协议:
tcpdump udp #抓取UDP协议的数据包
tcpdump icmp #抓取ICMP协议的数据包
抓取特定类型的数据包:
tcpdump -i eth1 'tcp[tcpflags] = tcp-syn' #抓取所有经过网卡1的SYN类型数据包
结合
tcpdump -i eth1 udp dst port 53 #抓取经过网卡eth1的所有DNS数据包(默认端口)
逻辑语句过滤:
tcpdump -i eth1 ‘((tcp) and ((dst net 172.16) and (not dst host 192.168.1.200)))’ #抓取所有经过网卡1,目的网络是172.16,但目的主机不是192.168.1.200的TCP数据
抓包存取:
tcpdump -i eth1 host 172.16.7.206 and port 80 -w /tmp/xxx.cap #抓取所有经过网卡1,目的主机为172.16.7.206的端口80的网络数据并