正規サイトとハニーポット切り替え詳細
4月2日より、「深淵 迎賓館 仕様変更」、「シュレディンガーのサーバー」
の内容にてサーバー公開を行っているが、その後 iptables の改良を重ね、構成がほぼFIXしたため、その内容を覚書として記す。
●本構成の振り分けイメージ
Internet
|
v
+----------------------------+
| Router |
| iptables / NAT |
+----------------------------+
| |
| |
Normal Suspicious
/ Allowed / Unknown
| |
v v
+----------------+ +----------------+
| 192.168.1.1 | | 192.168.1.2 |
| Main Server | | Honeypot |
+----------------+ +----------------+
上記の振り分けを、PREROUTINGチェインに集約した。
現在はPREROUTINGを確認するだけで、流入トラフィックの性質がほぼ把握できる状態となっている。
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 44 2492 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:smtp match-set firehol_level3 src to:192.168.1.2:25
2 0 0 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:smtp match-set firehol_level2 src to:192.168.1.2:25
3 5 228 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:smtp match-set firehol_level1 src to:192.168.1.2:25
4 2 120 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:smtp match-set gcloud src to:192.168.1.2:25
5 0 0 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:smtp match-set other_block src to:192.168.1.2:25
6 126 6626 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:http match-set firehol_level3 src to:192.168.1.2:80
7 50 2592 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:http match-set firehol_level2 src to:192.168.1.2:80
8 12 580 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:http match-set firehol_level1 src to:192.168.1.2:80
9 2 100 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:http match-set gcloud src to:192.168.1.2:80
10 0 0 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:http match-set other_block src to:192.168.1.2:80
11 255 13436 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:https match-set firehol_level3 src to:192.168.1.2:443
12 15 784 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:https match-set firehol_level2 src to:192.168.1.2:443
13 17 920 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:https match-set firehol_level1 src to:192.168.1.2:443
14 4 200 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:https match-set gcloud src to:192.168.1.2:443
15 0 0 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:https match-set other_block src to:192.168.1.2:443
16 13 760 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:ssh match-set jpnet src to:192.168.1.1:22
17 1 60 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:smtp match-set jpnet src to:192.168.1.1:25
18 0 0 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:smtp match-set searchengines src to:192.168.1.1:25
19 1 40 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:http match-set jpnet src to:192.168.1.1:80
20 3 180 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:http match-set searchengines src to:192.168.1.1:80
21 16 988 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:https match-set jpnet src to:192.168.1.1:443
22 176 9872 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:https match-set searchengines src to:192.168.1.1:443
23 0 0 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:submission match-set jpnet src to:192.168.1.1:587
24 1 60 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:imaps match-set jpnet src to:192.168.1.1:993
25 7 356 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:smtp to:192.168.1.2:25
26 150 7602 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:http to:192.168.1.2:80
27 305 18288 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:https to:192.168.1.2:443
28 8 480 DNAT tcp -- ppp0 any anywhere anywhere tcp dpt:2222 match-set jpnet src to:192.168.1.2:22
・firehol_level1~3 : FireHOLで公開されているブラックリストIPからのアクセスを Honeypot(192.168.1.2)へ振り分け
・jpnet : 日本国内からのアクセスを Main Server(192.168.1.1)へ振り分け
・searchengines : 主要サーチエンジンからのアクセスを Main Server(192.168.1.1)へ振り分け
・gcloud : スパムアクセスの多い Google Cloud からのアクセスを Honeypot(192.168.1.2)へ振り分け
・other_block : その他、不審と判断したアクセス(主に国内)を Honeypot(192.168.1.2)へ振り分け
※ Gmailのホストは searchengines に含めているため Main Server(192.168.1.1)で受信可能。
それ以外の海外サーバーからのメールは Honeypot(192.168.1.2)で受信されるため、取りこぼしは発生しない設計としている。
※ グローバルIPアドレスおよびホスト名は Main Server / Honeypot で共通としているため、Honeypot 側のSSL証明書も Main Server と同一のものを使用している。
■補足
デフォルトでは最終的にすべてのトラフィックは Honeypot 側へフォールバックする構成となっているため、「未知のアクセス=自動的に観測対象」となる。
これにより、ホワイトリスト方式(許可ベース)の安全性と、ブラックリスト方式(観測・分析)の両立が可能となっている。
FORWARDチェインについては、下記の通り非常にシンプルな構成とした。
ハニーポットを無効化する場合は、ルール10を DROP に変更するのみで切り離しが可能。
Chain FORWARD (policy DROP 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 5602K 3882M ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
2 0 0 DROP tcp -- br0 ppp0 anywhere anywhere tcp dpts:137:netbios-ssn
3 0 0 DROP udp -- br0 ppp0 anywhere anywhere udp dpts:netbios-ns:139
4 5 260 DROP tcp -- br0 ppp0 anywhere anywhere tcp dpt:microsoft-ds
5 0 0 DROP udp -- br0 ppp0 anywhere anywhere udp dpt:445
6 0 0 DROP tcp -- br0 ppp0 anywhere anywhere tcp dpt:sunrpc
7 0 0 DROP udp -- br0 ppp0 anywhere anywhere udp dpt:sunrpc
8 24314 14M ACCEPT all -- br0 ppp0 192.168.1.0/24 anywhere
9 211 11960 ACCEPT all -- ppp0 br0 anywhere 192.168.1.1
10 1010 55128 ACCEPT all -- ppp0 br0 anywhere 192.168.1.2
■補足(運用面)
本構成では DNAT のみで振り分けを完結させているため、フィルタリングとルーティングの責務が明確に分離され、トラブルシュートが容易になっている。
また、iptables のカウンタ値(pkts/bytes)を確認することで、「どの属性で振り分けられているか」が直感的に把握できる点も大きい。
LOG観測、可視性、メンテナンス性のすべてにおいて、現時点で満足のいく構成となった。