標籤:tcpdump 命令使用
1、抓取包含10.10.10.122的資料包
# tcpdump -i eth0 -vnn host 10.10.10.122
2、抓取包含10.10.10.0/24網段的資料包
# tcpdump -i eth0 -vnn net 10.10.10.0/24
3、抓取包含連接埠22的資料包
# tcpdump -i eth0 -vnn port 22
4、抓取udp協議的資料包
# tcpdump -i eth0 -vnn udp
5、抓取icmp協議的資料包
# tcpdump -i eth0 -vnn icmp
6、抓取arp協議的資料包
# tcpdump -i eth0 -vnn arp
7、抓取ip協議的資料包
# tcpdump -i eth0 -vnn ip
8、抓取源ip是10.10.10.122資料包。
# tcpdump -i eth0 -vnn src host 10.10.10.122
9、抓取目的ip是10.10.10.122資料包
# tcpdump -i eth0 -vnn dst host 10.10.10.122
10、抓取源連接埠是22的資料包
# tcpdump -i eth0 -vnn src port 22
11、抓取源ip是10.10.10.253且目的ip是22的資料包
# tcpdump -i eth0 -vnn src host 10.10.10.253 and dst port 22
12、抓取源ip是10.10.10.122或者包含連接埠是22的資料包
# tcpdump -i eth0 -vnn src host 10.10.10.122 or port 22
13、抓取源ip是10.10.10.122且連接埠不是22的資料包
[[email protected] ftp]# tcpdump -i eth0 -vnn src host 10.10.10.122 and not port 22
14、抓取源ip是10.10.10.2且目的連接埠是22,或源ip是10.10.10.65且目的連接埠是80的資料包。
# tcpdump -i eth0 -vnn \( src host 10.10.10.2 and dst port 22 \) or \( src host 10.10.10.65 and dst port 80 \)
15、抓取源ip是10.10.10.59且目的連接埠是22,或源ip是10.10.10.68且目的連接埠是80的資料包。
[[email protected] ~]# tcpdump -i eth0 -vnn ‘src host 10.10.10.59 and dst port 22‘ or ‘ src host 10.10.10.68 and dst port 80 ‘
16、把抓取的資料包記錄存到/tmp/fill檔案中,當抓取100個資料包後就退出程式。
# tcpdump –i eth0 -vnn -w /tmp/fil1 -c 100
17、從/tmp/fill記錄中讀取tcp協議的資料包
# tcpdump –i eth0 -vnn -r /tmp/fil1 tcp
18、從/tmp/fill記錄中讀取包含10.10.10.58的資料包
# tcpdump –i eth0 -vnn -r /tmp/fil1 host 10.10.10.58
本文出自 “我是一隻小小鳥” 部落格,請務必保留此出處http://2242558.blog.51cto.com/2232558/1545317
tcpdump 命令使用