<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Stop spam flood attack with postfix and iptables</title>
	<atom:link href="http://blog.exeko.com/2008/06/stop-spam-flood-postfix-iptables/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.exeko.com/2008/06/stop-spam-flood-postfix-iptables/</link>
	<description>un blog pas comme les autres ...</description>
	<lastBuildDate>Thu, 15 Jul 2010 00:26:02 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: sege</title>
		<link>http://blog.exeko.com/2008/06/stop-spam-flood-postfix-iptables/comment-page-1/#comment-9368</link>
		<dc:creator>sege</dc:creator>
		<pubDate>Mon, 19 Apr 2010 17:44:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.exeko.com/?p=30#comment-9368</guid>
		<description>Great script, I had some configuration issues with my mailserver and ended up on about any spam-bot-net out there...

Your script helped me stop the still coming to me :)</description>
		<content:encoded><![CDATA[<p>Great script, I had some configuration issues with my mailserver and ended up on about any spam-bot-net out there&#8230;</p>
<p>Your script helped me stop the still coming to me <img src='http://blog.exeko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simom</title>
		<link>http://blog.exeko.com/2008/06/stop-spam-flood-postfix-iptables/comment-page-1/#comment-8621</link>
		<dc:creator>Simom</dc:creator>
		<pubDate>Sun, 07 Feb 2010 19:53:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.exeko.com/?p=30#comment-8621</guid>
		<description>I have a atack of spam but it`s go i 1512 / min :) your script is okey but only if you have spam flood 12 / min :)</description>
		<content:encoded><![CDATA[<p>I have a atack of spam but it`s go i 1512 / min <img src='http://blog.exeko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  your script is okey but only if you have spam flood 12 / min <img src='http://blog.exeko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flaz</title>
		<link>http://blog.exeko.com/2008/06/stop-spam-flood-postfix-iptables/comment-page-1/#comment-4790</link>
		<dc:creator>Flaz</dc:creator>
		<pubDate>Thu, 18 Jun 2009 21:38:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.exeko.com/?p=30#comment-4790</guid>
		<description>Great idea.
I just had one problem about the month in the date command, that in debian (italian) writes the month in italian, but in log files is in english.

So that how it looks now:

&lt;code&gt;#!/bin/bash

IPT=/sbin/iptables
LIMIT=10

# first get one minute of log
grep &quot;`date +&quot; %d %H:%M:&quot; --date=&quot;1 minutes ago&quot;`&quot; /var/log/mail.info &gt; /tmp/minutelog

# now extract the rejected attempts, sort and count uniq ip
cat /tmp/minutelog &#124; grep &quot;reject:&quot; &#124; cut -d&quot; &quot; -f10 &#124; cut -d&quot;[&quot; -f2 &#124; cut -d&quot;]&quot; -f 1 &#124; sort &#124; uniq -c &#124; sort -n &#124; sed &quot;s/^[ \t]*//&quot; &gt; /tmp/rejectedlog

# for each line in result
while read line
do
	MYCOUNT=`echo $line &#124; cut -d&quot; &quot; -f1`
	MYIP=`echo $line &#124; cut -d&quot; &quot; -f2`

	if [ $MYCOUNT -gt $LIMIT ]; then
		$IPT -A INPUT --proto tcp -s $MYIP --destination-port 25 -j LOG --log-prefix &#039;filter_smtp &#039; --log-level 4
		$IPT -A INPUT --proto tcp -s $MYIP --destination-port 25 -j DROP
		echo $MYIP &gt;&gt; /tmp/blocked_ip_smtp
	fi
done &lt; /tmp/rejectedlog

rm -f /tmp/minutelog
rm -f /tmp/rejectedlog
&lt;/code&gt;

Thanks a lot :)</description>
		<content:encoded><![CDATA[<p>Great idea.<br />
I just had one problem about the month in the date command, that in debian (italian) writes the month in italian, but in log files is in english.</p>
<p>So that how it looks now:</p>
<p><code>#!/bin/bash</p>
<p>IPT=/sbin/iptables<br />
LIMIT=10</p>
<p># first get one minute of log<br />
grep "`date +" %d %H:%M:" --date="1 minutes ago"`" /var/log/mail.info &gt; /tmp/minutelog</p>
<p># now extract the rejected attempts, sort and count uniq ip<br />
cat /tmp/minutelog | grep "reject:" | cut -d" " -f10 | cut -d"[" -f2 | cut -d"]" -f 1 | sort | uniq -c | sort -n | sed "s/^[ \t]*//" &gt; /tmp/rejectedlog</p>
<p># for each line in result<br />
while read line<br />
do<br />
	MYCOUNT=`echo $line | cut -d" " -f1`<br />
	MYIP=`echo $line | cut -d" " -f2`</p>
<p>	if [ $MYCOUNT -gt $LIMIT ]; then<br />
		$IPT -A INPUT --proto tcp -s $MYIP --destination-port 25 -j LOG --log-prefix 'filter_smtp ' --log-level 4<br />
		$IPT -A INPUT --proto tcp -s $MYIP --destination-port 25 -j DROP<br />
		echo $MYIP &gt;&gt; /tmp/blocked_ip_smtp<br />
	fi<br />
done &lt; /tmp/rejectedlog</p>
<p>rm -f /tmp/minutelog<br />
rm -f /tmp/rejectedlog<br />
</code></p>
<p>Thanks a lot <img src='http://blog.exeko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Panx</title>
		<link>http://blog.exeko.com/2008/06/stop-spam-flood-postfix-iptables/comment-page-1/#comment-3258</link>
		<dc:creator>Panx</dc:creator>
		<pubDate>Fri, 20 Feb 2009 01:40:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.exeko.com/?p=30#comment-3258</guid>
		<description>Great script, i was using ddos deflate so far, to block apache botnets. But it wasn&#039;t very effective against spam botnets that were attacking on port 25. This really helped a lot... I was about to code my own one, but i said i&#039;d give it a try with googling a bit :) glad i did... thanks again.</description>
		<content:encoded><![CDATA[<p>Great script, i was using ddos deflate so far, to block apache botnets. But it wasn&#8217;t very effective against spam botnets that were attacking on port 25. This really helped a lot&#8230; I was about to code my own one, but i said i&#8217;d give it a try with googling a bit <img src='http://blog.exeko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  glad i did&#8230; thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chingson</title>
		<link>http://blog.exeko.com/2008/06/stop-spam-flood-postfix-iptables/comment-page-1/#comment-3054</link>
		<dc:creator>Chingson</dc:creator>
		<pubDate>Sun, 01 Feb 2009 13:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.exeko.com/?p=30#comment-3054</guid>
		<description>I found ubuntu 8.04 will generate &quot;Feb 01&quot; instead of &quot;Feb  1&quot;, which is used in /var/mail.info.
Following code is better used at Feb 1.


LASTMIN=`date +&quot;%b %_d %H:%M:&quot; --date=&quot;1 minutes ago&quot;`
#echo LASTMIN is $LASTMIN
grep -i &quot;$LASTMIN&quot; /var/log/mail.info &gt; minutelog</description>
		<content:encoded><![CDATA[<p>I found ubuntu 8.04 will generate &#8220;Feb 01&#8243; instead of &#8220;Feb  1&#8243;, which is used in /var/mail.info.<br />
Following code is better used at Feb 1.</p>
<p>LASTMIN=`date +&#8221;%b %_d %H:%M:&#8221; &#8211;date=&#8221;1 minutes ago&#8221;`<br />
#echo LASTMIN is $LASTMIN<br />
grep -i &#8220;$LASTMIN&#8221; /var/log/mail.info &gt; minutelog</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://blog.exeko.com/2008/06/stop-spam-flood-postfix-iptables/comment-page-1/#comment-1966</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Thu, 17 Jul 2008 01:52:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.exeko.com/?p=30#comment-1966</guid>
		<description>Jonathan,

Found your blog post as the 5th result of a Google search for &quot;stopping a spam flood&quot;.  I&#039;ve started running your script on our system to help mitigate a flood attack that has been intense enough to at times cause postfix to use up all the ports on our MySQL server looking up bogus generated names.  Thanks very much.

Andrew</description>
		<content:encoded><![CDATA[<p>Jonathan,</p>
<p>Found your blog post as the 5th result of a Google search for &#8220;stopping a spam flood&#8221;.  I&#8217;ve started running your script on our system to help mitigate a flood attack that has been intense enough to at times cause postfix to use up all the ports on our MySQL server looking up bogus generated names.  Thanks very much.</p>
<p>Andrew</p>
]]></content:encoded>
	</item>
</channel>
</rss>
