<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[静怡家园]]></title> 
<link>http://www.zhanghaijun.com/index.php</link> 
<description><![CDATA[书山有路勤为径，学海无涯苦作舟！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[静怡家园]]></copyright>
<item>
<link>http://www.zhanghaijun.com/post//</link>
<title><![CDATA[iptables ip_conntrack_max 调整]]></title> 
<author>碟舞飞扬 &lt;webmaster@zhanghaijun.com&gt;</author>
<category><![CDATA[服务器类]]></category>
<pubDate>Thu, 26 Feb 2009 06:40:37 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//</guid> 
<description>
<![CDATA[ 
	一、概念<br/>====================<br/>－允许的最大跟踪连接条目：CONNTRACK_MAX（默认值是 2^16=65536 ）<br/>－存储跟踪连接条目列表的哈西表的大小：HASHSIZE<br/>－每个哈西表的条目（叫一个bucket），包含了一个链接起来的跟踪连接条目<br/>－哈希表大小HASHSIZE，表现为 条目bucket的多少，在iptables启动时在日志中会显示。<br/>图表形象解释：<br/><a href="http://www.zhanghaijun.com/attachment.php?fid=221" target="_blank"><img src="http://www.zhanghaijun.com/attachment.php?fid=221" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>例如，系统默认配置下，启动 iptables 时的信息如下：<br/>ip_conntrack version 2.4 (8192 buckets, 65536 max) - 304 bytes per conntrack<br/>二、实战：调大 conntrack_max 参数（2.6内核）<br/>====================================================================<br/>1）增大 ip_conntrack_max（设置为 2^20，默认值是 2^16=65536）<br/># vi /etc/sysctl.conf <br/>net.ipv4.ip_conntrack_max = 1048576<br/>2）增大 hashsize （在i386架构上，HASHSIZE = CONNTRACK_MAX / 8）<br/># vi /etc/modprobe.conf <br/>options ip_conntrack hashsize=131072<br/>然后重启 iptables 服务，在 messages中可以看到参数已生效：<br/># service iptables restart <br/># tail /var/log/messages <br/>Feb 27 04:02:02 dispatcher syslogd 1.4.1: restart. <br/>Feb 27 17:45:01 dispatcher auditd[3924]: Audit daemon rotating log files <br/>Mar 1 11:47:13 dispatcher kernel: Removing netfilter NETLINK layer. <br/>Mar 1 11:47:13 dispatcher kernel: ip_tables: (C) 2000-2006 Netfilter Core Team <br/>Mar 1 11:47:13 dispatcher kernel: Netfilter messages via NETLINK v0.30. <br/>Mar 1 11:47:13 dispatcher kernel: ip_conntrack version 2.4 (131072 buckets, 1048576 max) - 228 bytes per conntrack<br/>注：只修改 net.ipv4.ip_conntrack_max = 1048576 ，重启iptables服务，messages信息中 (8192 buckets, 65536 max) 不变。<br/>Tags - <a href="http://www.zhanghaijun.com/tags/ip_conntrack_max/" rel="tag">ip conntrack max</a> , <a href="http://www.zhanghaijun.com/tags/iptables/" rel="tag">iptables</a>
]]>
</description>
</item><item>
<link>http://www.zhanghaijun.com/post//#blogcomment</link>
<title><![CDATA[[评论] iptables ip_conntrack_max 调整]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>