概要
自社サービスでaudit.logを監視しています。その中で監視に(未チューニングのため)ひかかったものの中からDocker関連のログをピックアップして残したいと思います。監視ツールの除外設定などに役に立てれば幸いです
また、出力されたログの調査からDockerの理解の深まりも図れるかと思います
前提条件
以降のログはAmazon Linux 2で出力されたログになります
iptables
iptableが変更された旨のメッセージ
出力例
/var/log/audit/audit.log
type=SYSCALL msg=audit(1545458152.159:227): arch=c000003e syscall=54 success=yes exit=0 a0=4 a1=0 a2=40 a3=22fe860 items=0 ppid=4067 pid=4171 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="iptables" exe="/usr/sbin/xtables-multi" key=(null)
出力されるタイミング
Dockerサービスを初回起動した際に、ホストのファイアウォールにDockerネットワークとホストネットワークの通信制御用に定義が追加されるために記録される
参考:「コンテナ通信の理解」
確認方法
-
Dockerサービス起動前にファイアウォールの確認
Docker関連の定義がないことを確認Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
-
Dockerサービス起動後にファイアウォールの確認
Docker関連の定義が追加されます> iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy DROP) target prot opt source destination DOCKER-USER all -- anywhere anywhere DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED DOCKER all -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT all -- anywhere anywhere Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain DOCKER (1 references) target prot opt source destination Chain DOCKER-ISOLATION-STAGE-1 (1 references) target prot opt source destination DOCKER-ISOLATION-STAGE-2 all -- anywhere anywhere RETURN all -- anywhere anywhere Chain DOCKER-ISOLATION-STAGE-2 (1 references) target prot opt source destination DROP all -- anywhere anywhere RETURN all -- anywhere anywhere Chain DOCKER-USER (1 references) target prot opt source destination RETURN all -- anywhere anywhere
ANOM_PROMISCUOUS
デバイスが無作為モードを有効または無効にすると開始します
詳しくは「Wiki プロミスキャス・モード」
出力例
/var/log/audit/audit.log
type=ANOM_PROMISCUOUS msg=audit(xxxxxxx): dev=veth66ee830 prom=256 old_prom=0 auid=xxxxxxx uid=0 gid=0 ses=xxxxxxx
出力されるタイミング
ログにもありますが、dev=veth66ee830という仮想ネットワークインターフェースはコンテナの起動時にアタッチされるために記録される
参考:Dockerネットワークについては「Docker の基本学習 ~ Docker のネットワーク」
確認方法
- 何かしらのコンテナを起動する
-
ネットワークインターフェース一覧を表示
一番下にログに出力されたveth66ee830
を確認できる> ifconfig -a docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 inet6 fe80::42:d6ff:fe98:eccf prefixlen 64 scopeid 0x20<link> ether 02:42:d6:98:ec:cf txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 6 bytes 516 (516.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001 inet 172.32.2.83 netmask 255.255.255.0 broadcast 172.32.2.255 inet6 fe80::8f4:3ff:feb3:d18c prefixlen 64 scopeid 0x20<link> ether 0a:f4:03:b3:d1:8c txqueuelen 1000 (Ethernet) RX packets 96478 bytes 139738280 (133.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 29933 bytes 1787310 (1.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 veth66ee830: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet6 fe80::1cef:e0ff:fecb:fb27 prefixlen 64 scopeid 0x20<link> ether 1e:ef:e0:cb:fb:27 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12 bytes 1032 (1.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0