您好,登錄后才能下訂單哦!
小編給大家分享一下Linux常用命令tcpdump怎么用,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
tcpdump [-adeflnNOpqStvx][-c][-dd][-ddd][-F][-i][-r][-s][-tt][-T][-vv][-w][輸出數(shù)據(jù)欄位]
參數(shù)說明:
-a 嘗試將網(wǎng)絡(luò)和廣播地址轉(zhuǎn)換成名稱。
-c 收到指定的數(shù)據(jù)包數(shù)目后,就停止進(jìn)行傾倒操作。
-d 把編譯過的數(shù)據(jù)包編碼轉(zhuǎn)換成可閱讀的格式,并傾倒到標(biāo)準(zhǔn)輸出。
-dd 把編譯過的數(shù)據(jù)包編碼轉(zhuǎn)換成C語言的格式,并傾倒到標(biāo)準(zhǔn)輸出。
-ddd 把編譯過的數(shù)據(jù)包編碼轉(zhuǎn)換成十進(jìn)制數(shù)字的格式,并傾倒到標(biāo)準(zhǔn)輸出。
-e 在每列傾倒資料上顯示連接層級(jí)的文件頭。
-f 用數(shù)字顯示網(wǎng)際網(wǎng)絡(luò)地址。
-F 指定內(nèi)含表達(dá)方式的文件。
-i 使用指定的網(wǎng)絡(luò)截面送出數(shù)據(jù)包。
-l 使用標(biāo)準(zhǔn)輸出列的緩沖區(qū)。
-n 不把主機(jī)的網(wǎng)絡(luò)地址轉(zhuǎn)換成名字。
-N 不列出域名。
-O 不將數(shù)據(jù)包編碼最佳化。
-p 不讓網(wǎng)絡(luò)界面進(jìn)入混雜模式。
-q 快速輸出,僅列出少數(shù)的傳輸協(xié)議信息。
-r 從指定的文件讀取數(shù)據(jù)包數(shù)據(jù)。
-s 設(shè)置每個(gè)數(shù)據(jù)包的大小。
-S 用絕對(duì)而非相對(duì)數(shù)值列出TCP關(guān)聯(lián)數(shù)。
-t 在每列傾倒資料上不顯示時(shí)間戳記。
-tt 在每列傾倒資料上顯示未經(jīng)格式化的時(shí)間戳記。
-T 強(qiáng)制將表達(dá)方式所指定的數(shù)據(jù)包轉(zhuǎn)譯成設(shè)置的數(shù)據(jù)包類型。
-v 詳細(xì)顯示指令執(zhí)行過程。
-vv 更詳細(xì)顯示指令執(zhí)行過程。
-x 用十六進(jìn)制字碼列出數(shù)據(jù)包資料。
-w 把數(shù)據(jù)包數(shù)據(jù)寫入指定的文件。
顯示TCP包信息
# tcpdump tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 23:35:55.129998 IP 192.168.0.3.ssh > 192.168.0.1.2101: P 148872068:148872168(100) ack 4184371747 win 2100 23:35:55.182357 IP 192.168.0.1.2101 > 192.168.0.3.ssh: . ack 100 win 64240 23:35:55.182397 IP 192.168.0.3.ssh > 192.168.0.1.2101: P 100:200(100) ack 1 win 2100 23:35:55.131713 IP 192.168.0.3.32804 > dns2.cs.hn.cn.domain: 50226+ PTR? 1.0.168.192.in-addr.arpa. (42) 23:35:55.131896 PPPoE [ses 0x1cb0] IP 118.250.6.85.64215 > dns2.cs.hn.cn.domain: 50226+ PTR? 1.0.168.192.in-addr.arpa. (42) 23:35:55.154238 PPPoE [ses 0x1cb0] IP dns2.cs.hn.cn.domain > 118.250.6.85.64215: 50226 NXDomain 0/0/0 (42) 23:35:55.156298 IP dns2.cs.hn.cn.domain > 192.168.0.3.32804: 50226 NXDomain 0/0/0 (42) 23:35:55.159292 IP 192.168.0.3.32804 > dns2.cs.hn.cn.domain: 30304+ PTR? 3.0.168.192.in-addr.arpa. (42) 23:35:55.159449 PPPoE [ses 0x1cb0] IP 118.250.6.85.64215 > dns2.cs.hn.cn.domain: 30304+ PTR? 3.0.168.192.in-addr.arpa. (42) 23:35:55.179816 PPPoE [ses 0x1cb0] IP dns2.cs.hn.cn.domain > 118.250.6.85.64215: 30304 NXDomain 0/0/0 (42) 23:35:55.181279 IP dns2.cs.hn.cn.domain > 192.168.0.3.32804: 30304 NXDomain 0/0/0 (42) 23:35:55.181806 IP 192.168.0.3.ssh > 192.168.0.1.2101: P 200:268(68) ack 1 win 2100 23:35:55.182177 IP 192.168.0.1.2101 > 192.168.0.3.ssh: . ack 268 win 64198 23:35:55.182677 IP 192.168.0.3.32804 > dns2.cs.hn.cn.domain: 43983+ PTR? 112.96.103.202.in-addr.arpa. (45) 23:35:55.182807 PPPoE [ses 0x1cb0] IP 118.250.6.85.64215 > dns2.cs.hn.cn.domain: 43983+ PTR? 112.96.103.202.in-addr.arpa. (45) 23:35:55.183055 IP 192.168.0.3.ssh > 192.168.0.1.2101: P 268:352(84) ack 1 win 2100 23:35:55.201096 PPPoE [ses 0x1cb0] IP dns2.cs.hn.cn.domain > 118.250.6.85.64215: 43983 1/0/0 (72) 23:35:55.203087 IP dns2.cs.hn.cn.domain > 192.168.0.3.32804: 43983 1/0/0 (72) 23:35:55.204666 IP 192.168.0.3.ssh > 192.168.0.1.2101: P 352:452(100) ack 1 win 2100 23:35:55.204852 IP 192.168.0.1.2101 > 192.168.0.3.ssh: . ack 452 win 64152 23:35:55.205305 IP 192.168.0.3.ssh > 192.168.0.1.2101: P 452:520(68) ack 1 win 2100 23:35:55.205889 IP 192.168.0.3.32804 > dns2.cs.hn.cn.domain: 9318+ PTR? 85.6.250.118.in-addr.arpa. (43) 23:35:55.206071 PPPoE [ses 0x1cb0] IP 118.250.6.85.64215 > dns2.cs.hn.cn.domain: 9318+ PTR? 85.6.250.118.in-addr.arpa. (43) 23:35:55.215338 PPPoE [ses 0x1cb0] IP 115.238.1.45.3724 > 118.250.6.85.64120: P 2392751922:2392751987(65) ack 2849759785 win 54 23:35:55.216273 IP 115.238.1.45.3724 > 192.168.0.65.2057: P 2392751922:2392751987(65) ack 2849759785 win 54 23:35:55.329204 IP 192.168.0.1.2101 > 192.168.0.3.ssh: . ack 520 win 64135 23:35:55.458214 IP 192.168.0.65.2057 > 115.238.1.45.3724: . ack 65 win 32590 23:35:55.458221 PPPoE [ses 0x1cb0] IP 118.250.6.85.64120 > 115.238.1.45.3724: . ack 65 win 32590 23:35:55.708228 PPPoE [ses 0x1cb0] IP 115.238.1.45.3724 > 118.250.6.85.64120: P 65:118(53) ack 1 win 54 23:35:55.710213 IP 115.238.1.45.3724 > 192.168.0.65.2057: P 65:118(53) ack 1 win 54 23:35:55.865151 IP 192.168.0.65.2057 > 115.238.1.45.3724: . ack 118 win 32768 23:35:55.865157 PPPoE [ses 0x1cb0] IP 118.250.6.85.64120 > 115.238.1.45.3724: . ack 118 win 32768 23:35:56.242805 IP 192.168.0.65.2057 > 115.238.1.45.3724: P 1:25(24) ack 118 win 32768 23:35:56.242812 PPPoE [ses 0x1cb0] IP 118.250.6.85.64120 > 115.238.1.45.3724: P 1:25(24) ack 118 win 32768 23:35:56.276816 PPPoE [ses 0x1cb0] IP 115.238.1.45.3724 > 118.250.6.85.64120: . ack 25 win 54 23:35:56.278240 IP 115.238.1.45.3724 > 192.168.0.65.2057: . ack 25 win 54 23:35:56.349747 PPPoE [ses 0x1cb0] IP 115.238.1.45.3724 > 118.250.6.85.64120: P 118:159(41) ack 25 win 54 23:35:56.351780 IP 115.238.1.45.3724 > 192.168.0.65.2057: P 118:159(41) ack 25 win 54 23:35:56.400051 PPPoE [ses 0x1cb0] IP 119.147.18.44.8000 > 118.250.6.85.4000: UDP, length 79 23:35:56.475050 IP 192.168.0.65.2057 > 115.238.1.45.3724: . ack 159 win 32762 23:35:56.475063 PPPoE [ses 0x1cb0] IP 118.250.6.85.64120 > 115.238.1.45.3724: . ack 159 win 32762 23:35:56.508968 PPPoE [ses 0x1cb0] IP 115.238.1.45.3724 > 118.250.6.85.64120: P 159:411(252) ack 25 win 54 23:35:56.510182 IP 115.238.1.45.3724 > 192.168.0.65.2057: P 159:411(252) ack 25 win 54 23:35:56.592028 PPPoE [ses 0x1cb0] IP 117.136.2.43.38959 > 118.250.6.85.63283: UDP, length 36 44 packets captured 76 packets received by filter 0 packets dropped by kernel
顯示指定數(shù)量包
# tcpdump -c 20 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 23:36:28.949538 IP 192.168.0.3.ssh > 192.168.0.1.2101: P 148875984:148876020(36) ack 4184373187 win 2100 23:36:28.994325 IP 192.168.0.1.2101 > 192.168.0.3.ssh: . ack 36 win 64020 23:36:28.994368 IP 192.168.0.3.ssh > 192.168.0.1.2101: P 36:72(36) ack 1 win 2100 23:36:28.950779 IP 192.168.0.3.32804 > dns2.cs.hn.cn.domain: 18242+ PTR? 1.0.168.192.in-addr.arpa. (42) 23:36:28.950948 PPPoE [ses 0x1cb0] IP 118.250.6.85.64215 > dns2.cs.hn.cn.domain: 18242+ PTR? 1.0.168.192.in-addr.arpa. (42) 23:36:28.960105 PPPoE [ses 0x1cb0] IP 222.82.119.41.13594 > 118.250.6.85.63283: UDP, length 36 23:36:28.962192 IP 222.82.119.41.13594 > 192.168.0.65.13965: UDP, length 36 23:36:28.963118 IP 192.168.0.65.13965 > 222.82.119.41.13594: UDP, length 34 23:36:28.963123 PPPoE [ses 0x1cb0] IP 118.250.6.85.63283 > 222.82.119.41.13594: UDP, length 34 23:36:28.970185 PPPoE [ses 0x1cb0] IP dns2.cs.hn.cn.domain > 118.250.6.85.64215: 18242 NXDomain 0/0/0 (42) 23:36:28.970413 IP dns2.cs.hn.cn.domain > 192.168.0.3.32804: 18242 NXDomain 0/0/0 (42) 23:36:28.972352 IP 192.168.0.3.32804 > dns2.cs.hn.cn.domain: 17862+ PTR? 3.0.168.192.in-addr.arpa. (42) 23:36:28.972474 PPPoE [ses 0x1cb0] IP 118.250.6.85.64215 > dns2.cs.hn.cn.domain: 17862+ PTR? 3.0.168.192.in-addr.arpa. (42) 23:36:28.982287 PPPoE [ses 0x1cb0] IP 121.12.131.163.13109 > 118.250.6.85.63283: UDP, length 27 23:36:28.984162 IP 121.12.131.163.13109 > 192.168.0.65.13965: UDP, length 27 23:36:28.985021 IP 192.168.0.65.13965 > 121.12.131.163.13109: UDP, length 103 23:36:28.985027 PPPoE [ses 0x1cb0] IP 118.250.6.85.63283 > 121.12.131.163.13109: UDP, length 103 23:36:28.991919 PPPoE [ses 0x1cb0] IP dns2.cs.hn.cn.domain > 118.250.6.85.64215: 17862 NXDomain 0/0/0 (42) 23:36:28.993142 IP dns2.cs.hn.cn.domain > 192.168.0.3.32804: 17862 NXDomain 0/0/0 (42) 23:36:28.993574 IP 192.168.0.3.ssh > 192.168.0.1.2101: P 72:140(68) ack 1 win 2100 20 packets captured 206 packets received by filter 129 packets dropped by kernel
精簡(jiǎn)顯示
# tcpdump -c 10 -q //精簡(jiǎn)模式顯示 10個(gè)包 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 23:43:05.792280 IP 192.168.0.3.ssh > 192.168.0.1.2101: tcp 36 23:43:05.842115 IP 192.168.0.1.2101 > 192.168.0.3.ssh: tcp 0 23:43:05.845074 IP 115.238.1.45.3724 > 192.168.0.65.2057: tcp 0 23:43:05.907155 IP 192.168.0.3.ssh > 192.168.0.1.2101: tcp 36 23:43:05.793880 IP 192.168.0.3.32804 > dns2.cs.hn.cn.domain: UDP, length 42 23:43:05.794076 PPPoE [ses 0x1cb0] IP 118.250.6.85.64219 > dns2.cs.hn.cn.domain: UDP, length 42 23:43:05.811127 PPPoE [ses 0x1cb0] IP dns2.cs.hn.cn.domain > 118.250.6.85.64219: UDP, length 42 23:43:05.814764 IP dns2.cs.hn.cn.domain > 192.168.0.3.32804: UDP, length 42 23:43:05.816404 IP 192.168.0.3.32804 > dns2.cs.hn.cn.domain: UDP, length 42 23:43:05.816545 PPPoE [ses 0x1cb0] IP 118.250.6.85.64219 > dns2.cs.hn.cn.domain: UDP, length 42 10 packets captured 39 packets received by filter 0 packets dropped by kernel
轉(zhuǎn)換克閱讀格式
# tcpdump -d (000) ret #96
轉(zhuǎn)換成十進(jìn)制格式
# tcpdump -ddd 1 6 0 0 96
以上是“Linux常用命令tcpdump怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。