分类: 系统运维
2011-03-22 07:46:08
IP_conntrack表示连接跟踪数据库(conntrack
database),代表NAT机器跟踪连接的数目,连接跟踪表能容纳多少记录是被一个变量控制的,它可由内核中的ip-
sysctl函数设置。每一个跟踪连接表会占用350字节的内核存储空间,时间一长就会把默认的空间填满,就会报错:
ip_conntrack: table full, dropping packet
那么默认空间时多少?我以redhat为例在内存为64MB的机器上时4096,内存为128MB是 8192,内存为256MB是16376,那末就能在/proc/sys/net/ipv4/ip_conntrack_max里查看、设置。
编辑 /etc/sysctl.conf
增加:
#ip_conntrack: table full, dropping packet.
net.ipv4.ip_conntrack_max = 6553600
net.ipv4.netfilter.ip_conntrack_max = 6553600
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180
加上其它的设置,我的/etc/sysctl.conf中,完整增加如下:
# by newstar
# Use TCP syncookies when needed
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries=3
net.ipv4.tcp_syn_retries=3
net.ipv4.tcp_max_syn_backlog=2048
# Enable TCP window scaling
net.ipv4.tcp_window_scaling: = 1
# Increase TCP max buffer size
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.rmem_default = 2097152
net.core.wmem_default = 2097152
# Increase autotuning TCP buffer limits
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
# Increase number of ports available
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000
#ip_conntrack: table full, dropping packet.
net.ipv4.ip_conntrack_max = 6553600
net.ipv4.netfilter.ip_conntrack_max = 6553600
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180
net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 120
net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 60
net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 120
net.ipv4.neigh.default.gc_thresh1 = 10240
net.ipv4.neigh.default.gc_thresh2 = 40960
net.ipv4.neigh.default.gc_thresh3 = 81920
现在我也正在测试,不知道是否可以解决 ip_conntrack: table full, dropping packet 让他不再来。