LoginSignup
13
13

More than 5 years have passed since last update.

CoreOS でも tcpdump したい (CoreOS toolbox)

Posted at

CoreOS 上でも tcpdump でネットワークデバッグする話です。

tcpdump くらいあるやろ

core@core-01 ~ $ tcpdump
-bash: tcpdump: command not found

無いんですよねー

CoreOS toolbox

CoreOS は OS 本体に何も入ってない(からアプリケーションは Docker コンテナとして動かす)ことで有名ですが、上記のように tcpdump すら入ってないので特に低レイヤーの調査で困ることがあります。それを補助するために、CoreOS が公式に toolbox というのを提供しています。

実際に使ってみましょう。

core@core-01 ~ $ /usr/bin/toolbox
latest: Pulling from fedora

48ecf305d2cf: Pull complete
ded7cd95e059: Pull complete
fedora:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.

Digest: sha256:49ae2d6d0b51f713a18db1c0da9fb1b5c94e92eb43cd712ba09028161ea22880
Status: Downloaded newer image for fedora:latest
core-fedora-latest
Spawning container core-fedora-latest on /var/lib/toolbox/core-fedora-latest.
Press ^] three times within 1s to kill container.
[root@core-01 ~]#

そう、toolbox の正体は Fedora のコンテナなのです!
~/.toolboxrc を書けばベース OS は変えられるようです [参考])

[root@core-01 ~]# tcpdump
-bash: tcpdump: command not found

しかし tcpdump はここにも入ってません。入れましょう。Fedora なので yum で入ります。

[root@core-01 ~]# yum install -y tcpdump
Yum command has been deprecated, redirecting to '/usr/bin/dnf install tcpdump'.
See 'man dnf' and 'man yum2dnf' for more information.
To transfer transaction metadata from yum to DNF, run:
'dnf install python-dnf-plugins-extras-migrate && dnf-2 migrate'

(snip)

Installed:
  libpcap.x86_64 14:1.7.3-1.fc22      tcpdump.x86_64 14:4.7.4-2.fc22

Complete!

確認

[root@core-01 ~]# tcpdump -s0 -A port 80
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
07:05:16.294511 IP core-01.36947 > 160.16.73.241.http: Flags [S], seq 3568280055, win 29200, options [mss 1460,sackOK,TS val 197800 ecr 0,nop,wscale 7], length 0
E..<._@.@..L
.....I..S.P..........r..>.........
............
07:05:16.774151 IP 160.16.73.241.http > core-01.36947: Flags [S.], seq 64320001, ack 3568280056, win 65535, options [mss 1460], length 0
E..,....@.....I.

CoreOS でも tcpdump できました。終わったら exit でコンテナから抜けます。
また tcpdump したくなったら /usr/bin/toolbox すればコンテナが立ち上がり作業できます。

おわりに

CoreOS toolbox を使って CoreOS 上で tcpdump する方法を紹介しました。

REF

13
13
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
13
13