LoginSignup
0
0

More than 5 years have passed since last update.

ネットワークの通信状況を可視化する(CentOS,tcpdump)

Posted at

ネットワークで疎通できているのかなど確認する際にtcpdumpを利用しますが、いつも必要に迫られて試行錯誤しているので今回コマンドとオプションを整理しておきたい。良くある利用方法として、dump取得してwhiresharkで表示していましたが今回はLinuxのみで完結します。

環境とコマンド

$ uname -a
Linux tk2-249-34492.vs.sakura.ne.jp 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ which tcpdump
/usr/sbin/tcpdump
$ /usr/sbin/tcpdump --version
tcpdump version 4.9.0
libpcap version 1.5.3
OpenSSL 1.0.1e-fips 11 Feb 2013

tcpdump

tcpdump [ -AbdDefhHIJKlLnNOpqStuUvxX# ] [ -B buffer_size ]
 [ -c count ]
 [ -C file_size ] [ -G rotate_seconds ] [ -F file ]
 [ -i interface ] [ -j tstamp_type ] [ -m module ] [ -M secret ]
 [ --number ] [ -Q|-P in|out|inout ]
 [ -r file ] [ -V file ] [ -s snaplen ] [ -T type ] [ -w file ]
 [ -W filecount ]
 [ -E spi@ipaddr algo:secret,...  ]
 [ -y datalinktype ] [ -z postrotate-command ] [ -Z user ]
 [ --time-stamp-precision=tstamp_precision ]
 [ --immediate-mode ] [ --version ]
 [ expression ]

記載例

$ sudo dist hostname:80 宛のパケット表示
/usr/sbin/tcpdump dst port 80 and host dst <<hostname>>
01:16:55.904796 IP <<srcip>>.port > <<dstip>>.http: Flags [S], seq 192944438, win 29200, options [mss 1460,sackOK,TS val 198347148 ecr 0,nop,wscale 7], length 0

$ sudo /usr/sbin/tcpdump [dit port 80 /src port 80] [dst <<hostname>> / scr <<hostname>> ]

出力例

01:16:55.904796 IP <<srcip>>.port > <<dstip>>.http: Flags [S], seq 192944438, win 29200, options [mss 1460,sackOK,TS val 198347148 ecr 0,nop,wscale 7], length 0

01:16:55.904796 パケット出力、受信時刻
srcip.port > dstip.http 送信元IP.ポート > 送信先IP.port

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0