
問題は、私の IP が DOS 攻撃に使用されたという報告を受けたことです。問題は、どのコンピューターが感染したのかがわからず、攻撃はもうアクティブではないことです。
ローカル IP ごとのパケット レートをカウントし、選択した定数を超えた場合にシェル スクリプトを起動するルーター (Fedora を実行) 用のシンプルな Linux ツールはありますか?
注意: ローカル ホストから生成されたパケットにも興味があります (サーバー自体がハッキングされた場合に備えて)。
答え1
そこで、iptables を使用した 1 つの解決策を見つけました。
# create new chain for every local ip we wanna monitor
iptables -N ip10
# forward traffic from monitored IP to it's chain "ip10"
iptables -A FORWARD -i myLan -s 192.168.2.10 -o myWan -j ip10
# trafic from other IP's we trusted we just accept
iptables -A FORWARD -i myLan -o myWan -j ACCEPT
# here we have even better thing than I asked for
# we can ban the DOS attack before it gets out
# in following line we set maximum 100 packet per second
iptables -A ip10 -m limit --limit 100/s --limit-burst 300 -j ACCEPT
# here we can directly log if above limit is breached
# log will be in /var/log/message and it will contains IP src+dst, src mac and other info
# note limit 3 msg per minute is important to not have too big log file
iptables -A ip10 -m limit --limit 3/m --limit-burst 10 -j LOG --log-prefix 'mylog:' --log-level 4
# finally packets over limit will be discarded
iptables -A ip10 -j DROP
1 つの IP から送信されたパケットとそのサイズを確認するには、次の呼び出しを実行します。
iptables -L ip10 -vxn
興味があれば、スクリプトでそれを実行し、1秒あたりのパケット数に再計算する必要があります。
サーバー自体を監視するには、チェーンに対して同様のアプローチを行う必要があることに注意してください。
iptables -A OUTPUT
fedora 18 でテストしました。他のコンピュータを攻撃しようとしましたが、パケットが本当に停止しました :)
答え2
これは典型的なシナリオですネットフロートラフィックの履歴データがアドレス、プロトコル、ポート別に分類されて提供され、評価したり、見やすいグラフで確認したりできるようになります。