不正アクセスがたくさんくるので、ブラックリストを整理する。
sshにアクセスが多いので、iptablesのIPを整理する。
日本向けのサーバーは、あまり考えず切っていたのですが、
これからは、海外の物もプロバイダーかデータセンターかいちいちチェックしないと行けないので、ちょっとスクリプトを書いておきます。
log watchから
sshd:
Authentication Failures:
root (corewave.jp): 1438 Time(s)
root (218.108.85.250): 1162 Time(s)
unknown (93.84.115.6): 549 Time(s)
root (93.84.115.6): 435 Time(s)
unknown (218.108.85.250): 271 Time(s)
unknown (144.140.140.221): 192 Time(s)
root (vhost1409.site2.compute.ihost.com): 105 Time(s)
root (server-08.lglg.in): 101 Time(s)
unknown (antispam.topdiag.com): 81 Time(s)
unknown (server-08.lglg.in): 66 Time(s)
Authentication Failures:
root (corewave.jp): 1438 Time(s)
root (218.108.85.250): 1162 Time(s)
unknown (93.84.115.6): 549 Time(s)
root (93.84.115.6): 435 Time(s)
unknown (218.108.85.250): 271 Time(s)
unknown (144.140.140.221): 192 Time(s)
root (vhost1409.site2.compute.ihost.com): 105 Time(s)
root (server-08.lglg.in): 101 Time(s)
unknown (antispam.topdiag.com): 81 Time(s)
unknown (server-08.lglg.in): 66 Time(s)
* ドメインの場合、nslookupする。
Name: corewave.jp
Address: 49.212.91.160
Address: 49.212.91.160
* ipをwhois する。
inetnum: 49.212.91.0 – 49.212.91.255
netname: SAKURA-NET
descr: SAKURA Internet Inc.
country: JP
netname: SAKURA-NET
descr: SAKURA Internet Inc.
country: JP
この場合は、さくらなので、ゾーンで切る。
iptablesに以下を追加
-A INPUT -s 49.212.91.0/24 -j DROP
# /etc/init.d/iptables status
テーブル: filter
Chain INPUT (policy DROP)
num target prot opt source destination
1 DROP all — 49.212.91.0/24 0.0.0.0/0
2 DROP all — 218.108.0.0/16 0.0.0.0/0
テーブル: filter
Chain INPUT (policy DROP)
num target prot opt source destination
1 DROP all — 49.212.91.0/24 0.0.0.0/0
2 DROP all — 218.108.0.0/16 0.0.0.0/0
policy dropなので、空いているのは22,80だけですが
それも、サーバーからは全拒否です。
さくらを利用しているので、自分のサーバーのIPだけ許可しないと駄目なので少し面倒です。
* 海外の大きなネットワークもバックエンドのサーバーでは拒否する。
* フロントhttpのサーバーは、仕方ないので22だけ拒否。
例えば以下のような
NetRange: 212.0.0.0 – 212.255.255.255
CIDR: 212.0.0.0/8
OriginAS:
NetName: RIPE-NCC-212
NetHandle: NET-212-0-0-0-1
Parent:
NetType: Allocated to RIPE NCC
Comment: These addresses have been further assigned to users in
Comment: the RIPE NCC region. Contact information can be found in
Comment: the RIPE database at http://www.ripe.net/whois
RegDate: 1997-11-14
Updated: 2009-03-25
Ref: http://whois.arin.net/rest/net/NET-212-0-0-0-1
CIDR: 212.0.0.0/8
OriginAS:
NetName: RIPE-NCC-212
NetHandle: NET-212-0-0-0-1
Parent:
NetType: Allocated to RIPE NCC
Comment: These addresses have been further assigned to users in
Comment: the RIPE NCC region. Contact information can be found in
Comment: the RIPE database at http://www.ripe.net/whois
RegDate: 1997-11-14
Updated: 2009-03-25
Ref: http://whois.arin.net/rest/net/NET-212-0-0-0-1
OrgName: RIPE Network Coordination Centre
OrgId: RIPE
参考:スパムとか
http://www.rbl.jp/index-j.php
http://www.spamhaus.org/datafeed/