質問編集履歴

1

ipsetについて調べてみた結果

2020/04/23 17:41

投稿

Jingles
Jingles

スコア8

test CHANGED
File without changes
test CHANGED
@@ -107,3 +107,39 @@
107
107
  0. EPELインストール
108
108
 
109
109
  0. fail2ban導入
110
+
111
+
112
+
113
+ ### ipsetについて調べてみた結果
114
+
115
+ 回答いただいたヒントを元に、BANされた後に`ipset list`コマンドを実行しても何も出力されませんでした。
116
+
117
+ そもそもbanactionとは指定された名前の[/etc/fail2ban/action.d/<banaction名>.conf]の内容を実行する。ということが理解できていませんでした。
118
+
119
+ [DEFAULT]でbansctionに指定されていた[iptables-multiport.conf]と[iptables-allports.conf]のactionstartの内容を確認してみると
120
+
121
+ ```
122
+
123
+ actionstart = <iptables> -N f2b-<name>
124
+
125
+ <iptables> -A f2b-<name> -j <returntype>
126
+
127
+ <iptables> -I <chain> -p <protocol> -j f2b-<name>
128
+
129
+ ```
130
+
131
+ BANされた時にこのコマンドが実行されるようですが、これでipsetにBANされたIPが登録されるということがいまいち繋がりませんでした。
132
+
133
+ 感覚的にはfirewallcmd-ipset.conf内の
134
+
135
+ ```
136
+
137
+ actionstart = ipset create <ipmset> hash:ip timeout <bantime><familyopt>
138
+
139
+ firewall-cmd --direct --add-rule <family> filter <chain> 0 <actiontype> -m set --match-set <ipmset> src -j <blocktype>
140
+
141
+ ```
142
+
143
+ 此方の方がipsetに登録してくれるような気がして`banaction = firewallcmd-ipset`に変更した後にBANさせて`ipset list`を実行してみましたが、結局何も出力されず。
144
+
145
+ firewallcmd-ipsetでは<ipmset>という名前のセットを作成してくれるようですが、そもそも<ipmset>とはどこで定義されているのでしょうか・・・