<?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: ip_conntrack: table full, dropping packet</title>
	<atom:link href="http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/feed/" rel="self" type="application/rss+xml" />
	<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/</link>
	<description>Words of wisdom from a server administrator</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:43:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Sam</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-25699</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Wed, 16 Nov 2011 10:31:13 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-25699</guid>
		<description>As Mihai said above, it is possible to have the connection tracking kernel module loaded, part of the network stack execution path and suffer from this problem without having any rules that require connection tracking present in your running iptables configuration. This certainly caused me some pain on hosts that were behaving very differently but were seemingly configured equally.

For example, adding and then removing from the nat table is enough to cause the DLKM to be loaded up.

I expand more on this &lt;a href=&quot;http://blog.sam-pointer.com/2011/11/15/nf_conntrack-table-full-how-the-absence-of-rules-can-lead-to-unexpected-behaviour&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; - the short answer is that you&#039;ll need to rmmod conntrack and friends out of your kernel to completely prevent the kernel from attempting to track connections.</description>
		<content:encoded><![CDATA[<p>As Mihai said above, it is possible to have the connection tracking kernel module loaded, part of the network stack execution path and suffer from this problem without having any rules that require connection tracking present in your running iptables configuration. This certainly caused me some pain on hosts that were behaving very differently but were seemingly configured equally.</p>
<p>For example, adding and then removing from the nat table is enough to cause the DLKM to be loaded up.</p>
<p>I expand more on this <a href="http://blog.sam-pointer.com/2011/11/15/nf_conntrack-table-full-how-the-absence-of-rules-can-lead-to-unexpected-behaviour" rel="nofollow">here</a> - the short answer is that you'll need to rmmod conntrack and friends out of your kernel to completely prevent the kernel from attempting to track connections.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nginx using up ip_conntrack a lot faster than squid .. why? - Admins Goodies</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-23772</link>
		<dc:creator>nginx using up ip_conntrack a lot faster than squid .. why? - Admins Goodies</dc:creator>
		<pubDate>Fri, 12 Aug 2011 09:47:42 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-23772</guid>
		<description>[...] a short-term workaround I&#8217;m just raising the ip_conntrack limits (as per http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet) but I was wondering if anyone here knows why nginx is hitting these limits so much more quickly, [...]</description>
		<content:encoded><![CDATA[<p>[...] a short-term workaround I&#8217;m just raising the ip_conntrack limits (as per <a href="http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet" rel="nofollow">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet</a>) but I was wondering if anyone here knows why nginx is hitting these limits so much more quickly, [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TQuang</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-23365</link>
		<dc:creator>TQuang</dc:creator>
		<pubDate>Thu, 30 Jun 2011 10:07:52 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-23365</guid>
		<description>A few days (and now), my server had been DDoS[ed] with largest qutity bad connection. Yes, that that attacking is SYN_FLOOD

And this my configuration tunning server to could opposed (/etc/sysctl.conf)
By way increase connection, decrease time, ... your server can good load/response. Remember, read document for all config below to understand them

net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_keepalive_time = 1800
net.ipv4.tcp_window_scaling = 0
net.ipv4.tcp_sack = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.ip_conntrack_max = 524288

net.core.somaxconn = 4096

net.ipv4.netfilter.ip_conntrack_max = 524288
net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_recv = 5
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 108000
net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_sent = 15
net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 3
net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 3
net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 3

net.ipv4.ip_local_port_range = 10000 65536</description>
		<content:encoded><![CDATA[<p>A few days (and now), my server had been DDoS[ed] with largest qutity bad connection. Yes, that that attacking is SYN_FLOOD</p>
<p>And this my configuration tunning server to could opposed (/etc/sysctl.conf)<br />
By way increase connection, decrease time, ... your server can good load/response. Remember, read document for all config below to understand them</p>
<p>net.ipv4.tcp_fin_timeout = 10<br />
net.ipv4.tcp_keepalive_time = 1800<br />
net.ipv4.tcp_window_scaling = 0<br />
net.ipv4.tcp_sack = 0<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_timestamps = 1<br />
net.ipv4.tcp_max_syn_backlog = 4096<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.conf.default.rp_filter = 1<br />
net.ipv4.conf.all.rp_filter = 1<br />
net.ipv4.conf.default.accept_source_route = 0<br />
net.ipv4.conf.all.accept_source_route = 0<br />
net.ipv4.ip_conntrack_max = 524288</p>
<p>net.core.somaxconn = 4096</p>
<p>net.ipv4.netfilter.ip_conntrack_max = 524288<br />
net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_recv = 5<br />
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 108000<br />
net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_sent = 15<br />
net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 3<br />
net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 3<br />
net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 3</p>
<p>net.ipv4.ip_local_port_range = 10000 65536</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abdullah</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-23313</link>
		<dc:creator>Abdullah</dc:creator>
		<pubDate>Sat, 25 Jun 2011 13:53:42 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-23313</guid>
		<description>I LOVE YOU MAN! YOU SAVED MY LIFE!!!!!!!!!!!!!! :D:D</description>
		<content:encoded><![CDATA[<p>I LOVE YOU MAN! YOU SAVED MY LIFE!!!!!!!!!!!!!! <img src='http://rackerhacker.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> :D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Swapnil</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-22849</link>
		<dc:creator>Swapnil</dc:creator>
		<pubDate>Tue, 03 May 2011 06:00:25 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-22849</guid>
		<description>Thanks Yaaaar...... :)</description>
		<content:encoded><![CDATA[<p>Thanks Yaaaar...... <img src='http://rackerhacker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Son Nguyen</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-20998</link>
		<dc:creator>Son Nguyen</dc:creator>
		<pubDate>Sat, 05 Mar 2011 16:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-20998</guid>
		<description>Turning off ip_conntrack would be great but is not possible with APF (it will reload the module once started) and manual firewall rules are not just helpful with most busy servers.</description>
		<content:encoded><![CDATA[<p>Turning off ip_conntrack would be great but is not possible with APF (it will reload the module once started) and manual firewall rules are not just helpful with most busy servers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Gillette</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-20867</link>
		<dc:creator>Eric Gillette</dc:creator>
		<pubDate>Tue, 22 Feb 2011 23:04:51 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-20867</guid>
		<description>I had a client being hit with a DDoS attack and this definitely helped his server to recover. . .

It seems as if it&#039;s a common consensus that once IP_CONNTRACK is full, the server goes &quot;offline&quot;, or rejects packets.</description>
		<content:encoded><![CDATA[<p>I had a client being hit with a DDoS attack and this definitely helped his server to recover. . .</p>
<p>It seems as if it's a common consensus that once IP_CONNTRACK is full, the server goes "offline", or rejects packets.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mihai Secasiu</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-18904</link>
		<dc:creator>Mihai Secasiu</dc:creator>
		<pubDate>Tue, 14 Dec 2010 19:15:25 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-18904</guid>
		<description>Be careful the tables can fill up if the ip_conntrack  kernel module is loaded even if you don&#039;t use any rules state related rules. These modules shouldn&#039;t be loaded if you don&#039;t use such rules.</description>
		<content:encoded><![CDATA[<p>Be careful the tables can fill up if the ip_conntrack  kernel module is loaded even if you don't use any rules state related rules. These modules shouldn't be loaded if you don't use such rules.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alpha01</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-16776</link>
		<dc:creator>Alpha01</dc:creator>
		<pubDate>Thu, 18 Nov 2010 18:05:09 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-16776</guid>
		<description>Awesome article with a thorough explanation. 

I&#039;m sure a lof of sysadmins who stumble across this article  would find it helpful like I did.

Thanks!</description>
		<content:encoded><![CDATA[<p>Awesome article with a thorough explanation. </p>
<p>I'm sure a lof of sysadmins who stumble across this article  would find it helpful like I did.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iptables &#171; Cyker&#039;s Constellation</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-16345</link>
		<dc:creator>iptables &#171; Cyker&#039;s Constellation</dc:creator>
		<pubDate>Sun, 20 Jun 2010 05:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-16345</guid>
		<description>[...] http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/ [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/" rel="nofollow">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Major Hayden</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-16138</link>
		<dc:creator>Major Hayden</dc:creator>
		<pubDate>Tue, 13 Apr 2010 15:40:29 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-16138</guid>
		<description>Briprad - I&#039;m glad it was able to help!</description>
		<content:encoded><![CDATA[<p>Briprad - I'm glad it was able to help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Briprad</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-16137</link>
		<dc:creator>Briprad</dc:creator>
		<pubDate>Tue, 13 Apr 2010 15:38:19 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-16137</guid>
		<description>Thanks for the post. Really helped. I was down to restarting server few times a day before reading this.</description>
		<content:encoded><![CDATA[<p>Thanks for the post. Really helped. I was down to restarting server few times a day before reading this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ip_conntrack table is full and dropping packets &#124; My Literature Tech blog</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15983</link>
		<dc:creator>ip_conntrack table is full and dropping packets &#124; My Literature Tech blog</dc:creator>
		<pubDate>Fri, 12 Mar 2010 12:00:22 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15983</guid>
		<description>[...] traffic. Then I found a good article on the same issue which you can read by clicking below linking here. Tags: dropping, full, iptables, ip_conntrack, loaded, packets, table        This entry was posted [...]</description>
		<content:encoded><![CDATA[<p>[...] traffic. Then I found a good article on the same issue which you can read by clicking below linking here. Tags: dropping, full, iptables, ip_conntrack, loaded, packets, table        This entry was posted [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ip_conntrack: table full, dropping packet &#124; Mạnh Nguyễn</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15901</link>
		<dc:creator>ip_conntrack: table full, dropping packet &#124; Mạnh Nguyễn</dc:creator>
		<pubDate>Thu, 25 Feb 2010 02:50:33 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15901</guid>
		<description>[...] ip_conntrack: table full, dropping packet [...]</description>
		<content:encoded><![CDATA[<p>[...] ip_conntrack: table full, dropping packet [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15580</link>
		<dc:creator>Jay</dc:creator>
		<pubDate>Tue, 10 Nov 2009 05:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15580</guid>
		<description>Nice article :)</description>
		<content:encoded><![CDATA[<p>Nice article <img src='http://rackerhacker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tom3k</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15418</link>
		<dc:creator>tom3k</dc:creator>
		<pubDate>Mon, 03 Aug 2009 05:52:54 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15418</guid>
		<description>oh worth mentioning, if you wish to change the hashsize... it can be done without reloading the module / using options (according to http://www.wallfire.org/misc/netfilter_conntrack_perf.txt):

Since 2.6.14, it is possible to set hashsize dynamically at runtime,
after boot and module load.

Between 2.6.14 and 2.6.19 (included), use:
# echo $HASHSIZE &gt; /sys/module/ip_conntrack/parameters/hashsize

Since 2.6.20, use:
# echo $HASHSIZE &gt; /sys/module/nf_conntrack/parameters/hashsize</description>
		<content:encoded><![CDATA[<p>oh worth mentioning, if you wish to change the hashsize... it can be done without reloading the module / using options (according to <a href="http://www.wallfire.org/misc/netfilter_conntrack_perf.txt" rel="nofollow">http://www.wallfire.org/misc/netfilter_conntrack_perf.txt</a>):</p>
<p>Since 2.6.14, it is possible to set hashsize dynamically at runtime,<br />
after boot and module load.</p>
<p>Between 2.6.14 and 2.6.19 (included), use:<br />
# echo $HASHSIZE &gt; /sys/module/ip_conntrack/parameters/hashsize</p>
<p>Since 2.6.20, use:<br />
# echo $HASHSIZE &gt; /sys/module/nf_conntrack/parameters/hashsize</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tom3k</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15417</link>
		<dc:creator>tom3k</dc:creator>
		<pubDate>Mon, 03 Aug 2009 05:48:33 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15417</guid>
		<description>darien and adrian, thank you kindly for sharing the knowhow.

i recently found a bunch of

ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.
ip_conntrack: table full, dropping packet.

in my dmesg, this article, plus your advice, will hopefully take care of this :)

thanks!</description>
		<content:encoded><![CDATA[<p>darien and adrian, thank you kindly for sharing the knowhow.</p>
<p>i recently found a bunch of</p>
<p>ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.<br />
ip_conntrack: table full, dropping packet.</p>
<p>in my dmesg, this article, plus your advice, will hopefully take care of this <img src='http://rackerhacker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Salinas</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15409</link>
		<dc:creator>Daniel Salinas</dc:creator>
		<pubDate>Tue, 28 Jul 2009 18:30:25 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15409</guid>
		<description>One other aspect to consider when raising your max conntrack setting is the depth of the memory objects used to track these connections, henceforth referred to as &quot;buckets&quot;.  

On RedHat the default hashsize for the conntrack module is 8192.  The rule of thumb is to allow for no more than 8 connections per bucket so you would set your conntrack size to be equal to 8 * hashsize.  This is why RedHat defaults the ip_conntrack_max to 65536.

You can tweak these settings by adjusting not just the ip_conntrack_max setting but the hashsize option to the ip_conntrack module.  

So, for example, if you were to set your ip_conntrack_max to 131072 without modifying the default hashsize of 8k, you are allowing for a bucket depth of 16 entries.  Thus the kernel has to dig deeper, potentially, to find that one connection object in it&#039;s bucket.

There are a number of schools of thought on how best to address this but in practice I have found that, given the resources, a shallower bucket is better.

For a server that does extremely heavy network traffic, and of course has the memory to spare, you would want to keep the average bucket depth to 2 or 4.

Hashsize, to my knowledge, isn&#039;t a dynamic setting so you will need to load the ip_conntrack module with the option:

hashsize = 

So in Major&#039;s example above, if you want to double your server&#039;s capacity for tracked connections while not doubling the lookups you would reload the module with:

options ip_conntrack hashsize=16384

This keeps the items per bucket to 8.  I have seen machines with a depth of beyond 8 get completely cowed under heavy network load and since memory is relatively plentiful nowadays you can increase the efficiency of the lookups by making this 4 connections per bucket or even 2 by just doing simple math and reloading the module with the right options.

Hope that helps.


Here is some relatively dated yet still applicable information on the subject:
http://www.wallfire.org/misc/netfilter_conntrack_perf.txt</description>
		<content:encoded><![CDATA[<p>One other aspect to consider when raising your max conntrack setting is the depth of the memory objects used to track these connections, henceforth referred to as "buckets".  </p>
<p>On RedHat the default hashsize for the conntrack module is 8192.  The rule of thumb is to allow for no more than 8 connections per bucket so you would set your conntrack size to be equal to 8 * hashsize.  This is why RedHat defaults the ip_conntrack_max to 65536.</p>
<p>You can tweak these settings by adjusting not just the ip_conntrack_max setting but the hashsize option to the ip_conntrack module.  </p>
<p>So, for example, if you were to set your ip_conntrack_max to 131072 without modifying the default hashsize of 8k, you are allowing for a bucket depth of 16 entries.  Thus the kernel has to dig deeper, potentially, to find that one connection object in it's bucket.</p>
<p>There are a number of schools of thought on how best to address this but in practice I have found that, given the resources, a shallower bucket is better.</p>
<p>For a server that does extremely heavy network traffic, and of course has the memory to spare, you would want to keep the average bucket depth to 2 or 4.</p>
<p>Hashsize, to my knowledge, isn't a dynamic setting so you will need to load the ip_conntrack module with the option:</p>
<p>hashsize = </p>
<p>So in Major's example above, if you want to double your server's capacity for tracked connections while not doubling the lookups you would reload the module with:</p>
<p>options ip_conntrack hashsize=16384</p>
<p>This keeps the items per bucket to 8.  I have seen machines with a depth of beyond 8 get completely cowed under heavy network load and since memory is relatively plentiful nowadays you can increase the efficiency of the lookups by making this 4 connections per bucket or even 2 by just doing simple math and reloading the module with the right options.</p>
<p>Hope that helps.</p>
<p>Here is some relatively dated yet still applicable information on the subject:<br />
<a href="http://www.wallfire.org/misc/netfilter_conntrack_perf.txt" rel="nofollow">http://www.wallfire.org/misc/netfilter_conntrack_perf.txt</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Otto</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15408</link>
		<dc:creator>Adrian Otto</dc:creator>
		<pubDate>Tue, 28 Jul 2009 15:19:49 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15408</guid>
		<description>Some readers may be interested to know what ip_conntrack is in the first place, and why it fills up. If you run an iptables firewall, and have rules that act upon the state of a packet, then the kernel uses ip_conntrack to keep track of what state what connections are in so that the firewall rule logic can be applied against them. If you have a system that&#039;s getting a lot of network activity (high rates of connections, lots of concurrent connections, etc) then the table will accumulate entries. 

The entries remain until an RST packet is sent from the original IP address. If you have a flaky network somewhere between you, and the clients accessing your server, it can cause the RST packets to be dropped due to the packet loss, and leave orphaned entries in your ip_conntrack table. This can also happen if you have a malfunctioning switch or NIC card... not necessarily a routing problem out on the internet somewhere.

Typically when I&#039;ve seen this trouble crop up is when a server is the target of a DDoS attack. Filling up the ip_conntrack table is a relatively easy way to knock a server off line, and attackers know this.

As Major suggested, you can get short term relief by increasing the size of the table. However, these entries are held in memory by the kernel. The bigger you make the table, the more memory it will consume. That memory  could be used by your server to serve requests if you really don&#039;t need the stateful firewall capability. Don&#039;t waste resources on this feature if you really don&#039;t need it.

 Another option to consider is turning OFF iptables rules that use ip_conntrack so the state able is not used at all. Anything with &quot;-m state&quot; or &quot;-t nat&quot; can be turned off. If you want to just flush all your iptables rules you can do an &quot;iptables -P&quot; to set a default allow policy and &quot;iptables -F&quot; to flush all the rules. On an RHEL or CentOS system you can just do &quot;service iptables stop&quot;.

Once iptables is no longer using ip_conntrack, you can reclaim the memory the table was using by unloading the related kernel modules.

rmmod ipt_MASQUERADE
rmmod iptable_nat
rmmod ipt_state
rmmod ip_conntrack

Then you will have an empty ip_conntrack that will stay empty. I mention this because a lot of sysadmins have hordes of iptables rules installed as a matter of course, and don&#039;t recognize the downside of having them present. You can still use iptables, but to avoid the use of ip_conntrack simply don&#039;t use rules based on stateful logic.</description>
		<content:encoded><![CDATA[<p>Some readers may be interested to know what ip_conntrack is in the first place, and why it fills up. If you run an iptables firewall, and have rules that act upon the state of a packet, then the kernel uses ip_conntrack to keep track of what state what connections are in so that the firewall rule logic can be applied against them. If you have a system that's getting a lot of network activity (high rates of connections, lots of concurrent connections, etc) then the table will accumulate entries. </p>
<p>The entries remain until an RST packet is sent from the original IP address. If you have a flaky network somewhere between you, and the clients accessing your server, it can cause the RST packets to be dropped due to the packet loss, and leave orphaned entries in your ip_conntrack table. This can also happen if you have a malfunctioning switch or NIC card... not necessarily a routing problem out on the internet somewhere.</p>
<p>Typically when I've seen this trouble crop up is when a server is the target of a DDoS attack. Filling up the ip_conntrack table is a relatively easy way to knock a server off line, and attackers know this.</p>
<p>As Major suggested, you can get short term relief by increasing the size of the table. However, these entries are held in memory by the kernel. The bigger you make the table, the more memory it will consume. That memory  could be used by your server to serve requests if you really don't need the stateful firewall capability. Don't waste resources on this feature if you really don't need it.</p>
<p> Another option to consider is turning OFF iptables rules that use ip_conntrack so the state able is not used at all. Anything with "-m state" or "-t nat" can be turned off. If you want to just flush all your iptables rules you can do an "iptables -P" to set a default allow policy and "iptables -F" to flush all the rules. On an RHEL or CentOS system you can just do "service iptables stop".</p>
<p>Once iptables is no longer using ip_conntrack, you can reclaim the memory the table was using by unloading the related kernel modules.</p>
<p>rmmod ipt_MASQUERADE<br />
rmmod iptable_nat<br />
rmmod ipt_state<br />
rmmod ip_conntrack</p>
<p>Then you will have an empty ip_conntrack that will stay empty. I mention this because a lot of sysadmins have hordes of iptables rules installed as a matter of course, and don't recognize the downside of having them present. You can still use iptables, but to avoid the use of ip_conntrack simply don't use rules based on stateful logic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sonicmind</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15389</link>
		<dc:creator>sonicmind</dc:creator>
		<pubDate>Tue, 07 Jul 2009 06:20:59 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15389</guid>
		<description>Thanks this is great article... veary helpfull</description>
		<content:encoded><![CDATA[<p>Thanks this is great article... veary helpfull</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jhon</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15361</link>
		<dc:creator>Jhon</dc:creator>
		<pubDate>Mon, 15 Jun 2009 07:47:48 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15361</guid>
		<description>Thanks a lot..
Been puzzled by this :)</description>
		<content:encoded><![CDATA[<p>Thanks a lot..<br />
Been puzzled by this <img src='http://rackerhacker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: YangLei</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15345</link>
		<dc:creator>YangLei</dc:creator>
		<pubDate>Tue, 09 Jun 2009 12:16:40 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-15345</guid>
		<description>wtf, your article is great, saved me from ultimate &amp;**&amp;(**)
huge thanks.</description>
		<content:encoded><![CDATA[<p>wtf, your article is great, saved me from ultimate &amp;**&amp;(**)<br />
huge thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kaolin Fire</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-13916</link>
		<dc:creator>Kaolin Fire</dc:creator>
		<pubDate>Wed, 25 Feb 2009 03:20:21 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-13916</guid>
		<description>This just saved my (*#&amp;$(*#.  Thank you.</description>
		<content:encoded><![CDATA[<p>This just saved my (*#&amp;$(*#.  Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven</title>
		<link>http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-350</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Fri, 01 Feb 2008 09:59:16 +0000</pubDate>
		<guid isPermaLink="false">http://rackerhacker.com/2008/01/24/ip_conntrack-table-full-dropping-packet/#comment-350</guid>
		<description>This solves the problem at this moment, but after a reboot the initial value will be restored.
To make this persistent you have to add a line like &#039;net.ipv4.ip_conntrack_max=131072&#039; to /etc/sysctl.conf
Some distros apparently don&#039;t have that file; there you should use the echo-line in a boot script</description>
		<content:encoded><![CDATA[<p>This solves the problem at this moment, but after a reboot the initial value will be restored.<br />
To make this persistent you have to add a line like 'net.ipv4.ip_conntrack_max=131072' to /etc/sysctl.conf<br />
Some distros apparently don't have that file; there you should use the echo-line in a boot script</p>
]]></content:encoded>
	</item>
</channel>
</rss>

