netstat tcpdump

tcpdump

最簡單的命令,指定host:
tcpdump -i eth0 host 172.20.20.155 or 172.28.13.61
截獲本機與172.20.20.155 或172.28.13.61交互中接收和發送的包網絡

若是要區分源和目的,能夠加src , dst ,dst or src, dst and src關鍵字:
tcpdump -i eth0 src host 172.20.20.155 or 172.28.13.61 and dst port 80
截獲172.20.20.155 或172.28.13.61發送給本機80端口的包tcp

若是要指定協議,能夠加tcp,udp,ip等關鍵字,注意tcp udp只能修飾port:
tcpdump -i eth0 src host 172.20.20.155 or 172.28.13.61 and tcp dst port 80
截獲172.20.20.155 或172.28.13.61發送給本機80端口的tcp包spa

若是要排除某些機器和端口的包,還提供了!操做符:
tcpdump -i eth0 host ! 172.20.20.155 and ! 172.28.13.61
截獲本機與除172.20.20.155 和172.28.13.61之外全部機器交互中接收和發送的包ip

若是要把抓包結果輸出爲文件,能夠加-w關鍵字:
tcpdump -i eth0 src host 172.20.20.155 or 172.28.13.61 and tcp dst port 80 -w out.cap
這樣文件out.cap能夠用wireshark進一步分析udp

若是要把抓包結果輸出爲文件,能夠加-w關鍵字:
tcpdump -i eth0 -X src host 172.20.20.155 or 172.28.13.61 and tcp dst port 80
這樣文件out.cap能夠用wireshark進一步分析協議

 

-nn:不顯示主機名而直接顯示ip.port端口

-c :監聽的包數,若是沒有這個參數,tcpdump會不持續不斷的監聽, 直到使用者輸入 [ctrl]-c 爲止。wireshark

-i:要監聽的網絡設備,例如eth0, lo等,能夠經過ifconfig查看。文件

-X :能夠列出十六進制 (hex) 以及 ASCII 的包內容。co

相關文章
相關標籤/搜索