当前位置:网站首页>After the firewall iptable rule is enabled, the system network becomes slow
After the firewall iptable rule is enabled, the system network becomes slow
2022-08-05 07:03:00 【 】
Possible reason: the conntrack table of iptables is full, which leads to slow access to the website
Phenomenon: suddenly found that the website access is very slow, and the server's cpu, memory and disk usage are normal
ip_conntrack and ns_conntrack have the same meaning, butDifferent analysis processes and solutions on the old and new versions: Query the /var/log/message log and find such a record "ip_conntrack table full dropping packet".The kernel uses the ip_conntrack module to record the status of the iptables network packets, and save it in the table (this table is in memory). If the network condition is busy, such as high connection, high concurrent connection, etc., it will gradually occupy the available space of this table. Generally, this tableIt is very large and not easy to fill up and can be cleaned up by yourself. The records of the table will stay in the table and occupy space until the source IP sends an RST packet, but if there is an attack, wrong network configuration, problematic routing/router, there is a problemWhen the network card is not connected, the RST packet sent by the source IP will not be received, so it will accumulate in the table, and the more it accumulates, the more it will be until it is full.Case.
Solution: When Iptables starts, it will prompt the current value of buckets and conntrack_max in the log and how much memory each tracking connection needs to consume:
That is to say, 304MB memory will support 1048576 tracking connection records, so it is necessary toConfigure the appropriate value according to the memory size of the server.
Permanently modify ip_conntrack_max and hashsize
Increase ip_conntrack_max (set to 2^20, default is 2^16=65536)
#vi /etc/sysctl.conf
net.ipv4.ip_conntrack_max = 1048576Increase hashsize (on i386 architecture, HASHSIZE=CONNTRACK_MAX/8)
#vi /etc/modprobe.conf
options ip_conntrack hashsize=131072
Then restart iptables service, in messagesYou can see that the parameters have taken effect:
#service iptables restart
#cat /proc/sys/net/nf_conntrack_max defines the maximum value of connection tracking, it is recommended to increase this value as needed;
#cat /proc/net/nf_conntrack records all currently tracked connections
cat/proc/sys/net/netfilter/nf_conntrak_tcp_timeout_established ESTABLISHED timeout period, the default time is relatively long, it is recommended to reduce this value.
The limit of nf_conntrack connection tracking is controlled by the /proc/sys/net/nf_conntrack_max file, which can be modified or /etc/sysctl.conf/etc/sysctl.conf.
echo “65536” > /proc/sys/net/nf_conntrack_max
Possible reason 2: lack of dns related rules
iptables -I INPUT -p udp --sport 53 -j ACCEPT
iptables -I INPUT -p tcp --sport 53 -j ACCEPT
Cause 3: Routing problem https://support.huawei.com/enterprise/zh/knowledge/EKB1000059526
Reason 4: There is a lack of corresponding udp rules. For example, if there is NFS, you need to open the NFS-related udp link, otherwise the NFS link will be full, causing other links to be interrupted, resulting in slow access
https://www.liuyixiang.com/post/83843.html
https://www.haiyun.me/archives/iptables-conntrack-max.html
https://blog.51cto.com/jasonyong/280993
https://support.huawei.com/enterprise/zh/knowledge/EKB1000059526
https://www.docin.com/p-1065250766.html
https://www.163.com/dy/article/GE1TIRTL05373KLK.html
https://www.zsythink.net/archives/1493
https://www.cnblogs.com/yxh168/p/9676745.html
https://www.dandelioncloud.cn/article/details/1430922069444997121
边栏推荐
猜你喜欢
Source code analysis of Nacos configuration service (full)
Database table insert data
【网友真实投稿】为女友放弃国企舒适圈,转行软件测试12k*13薪
UDP group (multi)cast
typescript64-映射类型
原来使Maya Arnold也能渲染出高质量作品!超赞小技巧
(4) Rotating object detection data roLabelImg to DOTA format
DNSlog外带数据注入
技术分析模式(十)头肩图案
淘宝客APP带自营商城本地生活CPS外卖优惠电影票话费更新渠道跟单生活特权V3
随机推荐
UDP广播
【8】Docker中部署Redis
字节面试流程及面试题无私奉献,吐血整理
Technical Analysis Mode (7) Playing the Gap
(4) Rotating object detection data roLabelImg to DOTA format
铠侠携手Aerospike提升数据库应用性能
长度以及颜色单位基本概念
一天学会从抓包到接口测试,通过智慧物业项目深度解析
自媒体人一般会从哪里找素材呢?
香港国际珠宝展及香港国际钻石、宝石及珍珠展揭幕
基于快速行进平方法的水面无人船路径规划
LaTeX uses frame to make PPT pictures without labels
七夕!专属于程序员的浪漫表白
不太会讲爱,其实已经偷偷幸福很久啦----我们的故事
八大排序之堆排序
typescript61-泛型工具类型(pick)
软件测试必问面试题(附答案和解析)
Jenkins详细配置
JS控制只能输入数字并且最多允许小数点两位
花花省V5淘宝客APP源码无加密社交电商自营商城系统带抖音接口