<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tim's Weblog &#187; ferm</title>
	<atom:link href="http://blog.hokkertjes.nl/tag/ferm/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hokkertjes.nl</link>
	<description>Random Thoughts and Rants</description>
	<lastBuildDate>Fri, 23 Jul 2010 11:41:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Rate limit incoming ssh connections</title>
		<link>http://blog.hokkertjes.nl/2008/07/06/rate-limit-incoming-ssh-connections/</link>
		<comments>http://blog.hokkertjes.nl/2008/07/06/rate-limit-incoming-ssh-connections/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 14:13:42 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[ferm]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[ipt_recent]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[rate limit]]></category>
		<category><![CDATA[recent]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[worm]]></category>

		<guid isPermaLink="false">http://blog.hokkertjes.nl/?p=492</guid>
		<description><![CDATA[So apparently, there&#8217;s a ssh worm in the wild that tries to break into servers by bombarding the ssh daemon with logins. No idea what they think they can achieve with this, since it mostly just takes down the ssh service (for everyone, including themselves). So it&#8217;s more annoying and inconvenient (you can&#8217;t login) than [...]]]></description>
			<content:encoded><![CDATA[<p>So apparently, there&#8217;s a ssh worm in the wild that tries to break into servers by bombarding the ssh daemon with logins. No idea what they think they can achieve with this, since it mostly just takes down the ssh service (for everyone, including themselves). So it&#8217;s more annoying and inconvenient (you can&#8217;t login) than threatening, in my opinion.</p>
<p>Luckily, there are easy ways to deal with this. We use the following <a href="http://ferm.foo-projects.org/">ferm</a> recipe to limit the incoming new ssh connections on source ip basis. Hope this helps someone. </p>
<p>You do the following in the filter table from the input chain. We assume you already allow established connections to pass.</p>
<pre>proto tcp dport ssh {
  # Rate-limit incoming SSH connections
  mod state state NEW mod recent name "ssh" {
    set NOP;
    update seconds 300 hitcount 31 REJECT reject-with tcp-reset;
  }

  # allow SSH clients which play nice
  ACCEPT;
}</pre>
<p>This will keep track of the number of connections made on the ssh port in the last 300 seconds, per source ip address. If more than 30 connections are made within 300 seconds, they will be rejected. Otherwise, they&#8217;re allowed.</p>
<p>This works great for us, but you want to test it before using it in a production environment, of course!</p>
<p><b>Update:</b> So ipt_recent only allows up to 20 counts. You might want to change the numbers in this recipe a bit to make it work correctly <img src='http://blog.hokkertjes.nl/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><b>Update 2:</b> Or even better:</p>
<pre>$ cat /etc/modprobe.d/ipt_recent
options ipt_recent ip_pkt_list_tot=31
$ sudo /etc/init.d/ferm stop
$ sudo rmmod ipt_recent
$ sudo /etc/init.d/ferm start</pre>
<p>You can check /sys/module/ipt_recent/parameters/ip_pkt_list_tot to see if it changed.</p>
<p>Btw, this all is not my own research, merely transcribing what Bart and Kees researched.</p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Tags: <a class='technorati-link' href='http://technorati.com/tag/connection' rel='tag' target='_self'>connection</a>, <a class='technorati-link' href='http://technorati.com/tag/ferm' rel='tag' target='_self'>ferm</a>, <a class='technorati-link' href='http://technorati.com/tag/firewall' rel='tag' target='_self'>firewall</a>, <a class='technorati-link' href='http://technorati.com/tag/ipt_recent' rel='tag' target='_self'>ipt_recent</a>, <a class='technorati-link' href='http://technorati.com/tag/limit' rel='tag' target='_self'>limit</a>, <a class='technorati-link' href='http://technorati.com/tag/rate+limit' rel='tag' target='_self'>rate limit</a>, <a class='technorati-link' href='http://technorati.com/tag/recent' rel='tag' target='_self'>recent</a>, <a class='technorati-link' href='http://technorati.com/tag/ssh' rel='tag' target='_self'>ssh</a>, <a class='technorati-link' href='http://technorati.com/tag/worm' rel='tag' target='_self'>worm</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.hokkertjes.nl/2008/07/06/rate-limit-incoming-ssh-connections/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
