一、較根本的解決法:
參考 Postfix Performance Tuning 裡的:
Measures against clients that make too many connections
這一段內容,列出了postfix可以限制client送信頻率的參數。
中文介紹可參閱:
postfix2.2以後帶有發信頻率控制的控制
二、用簡單的shell script 可立刻查發信IP的頻率:
1.整個mail.log檔
<pre class="c" name="code">fgrep " connect from " /var/log/mail.log | sed -e 's/.*\[\(.*\)\]/\1/'|sort| uniq -c| sort -n
2.前1000行
<pre class="c" name="code">tail -1000 /var/log/mail.log | fgrep " connect from " | sed -e 's/.[(.)]/\1/'|sort| uniq -c| sort -n
3.用 awk 來算次數:建一個 count.awk 檔
<pre class="c" name="code">{
freq[$1]++
}
END {
for (ip in freq)
printf "%d\t%s\n", freq[ip], ip
}
然後執行
<pre class="c" name="code">tail -1000 /var/log/mail.log | fgrep " connect from " | sed -e 's/.[(.)]/\1/'| awk -f /path/to/count.awk |sort -n |sort -n
出來的結果會類似這樣:(不用awk:)
<pre class="c" name="code"> 2 195.24.212.3
2 220.228.9.18
5 190.84.237.250
18 203.161.109.116
(用awk:)
<pre class="c" name="code">1 83.151.151.51
1 85.182.175.4
1 96.31.247.154
6 190.84.237.250
19 203.161.109.116