Iptables's Conntrack table full makes it slow to visit the site

Source: Internet
Author: User
Tags disk usage iptables

Phenomenon: Suddenly found that access to the site is very slow, the server's CPU, memory and disk usage is normal

Analysis process and Solution: query/var/log/message log found such a record "Ip_conntrack table full dropping packet". Kernel use the Ip_conntrack module to record the status of the Iptables network packet and save it to the table (this table in memory), if the network is busy, such as high connection, high concurrent connection will lead to gradually occupy this table free space, the General tab Le very big not easy to fill up and can clean up themselves, table records will stay in the table to occupy space until the source IP sent a RST packet, but if there is an attack, the wrong network configuration, the problem of routing/router, the problem of the network card and so on, will cause the source IP sent this RST Package can not receive, so accumulated in the table, the more accumulation until the full, full after the iptables will lose the packet, the outside can not connect the server situation.

Solution: Iptables initiates the value of the current buckets and Conntrack_max in the log and how much memory each trace connection consumes:

This means that 304MB of memory will support 1,048,576 track connection records, so you need to configure the appropriate values according to the size of the server's memory.

Permanently modify Ip_conntrack_max and Hashsize

1 increase Ip_conntrack_max (set to 2^20, default value is 2^16=65536)

# vi/etc/sysctl.conf

Net.ipv4.ip_conntrack_max = 1048576

2) Increase hashsize (in i386 architecture, Hashsize = CONNTRACK_MAX/8)

# vi/etc/modprobe.conf

Options Ip_conntrack hashsize=131072

Then restart the Iptables service, and in messages you can see that the parameters are in effect:

# Service Iptables Restart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.