首页 > 其他分享 >服务器nf_conntrack(CT)表满导致虚拟机丢包

服务器nf_conntrack(CT)表满导致虚拟机丢包

时间:2023-10-04 17:11:20浏览次数:31  
标签:丢包 max 虚拟机 nf connection conntrack table netfilter

现象

虚拟机各种奇怪丢包(TCP的连接)
然后看到虚拟机所在CVK的dmesg里,有如下:
dmesg kern -l err,warn -T (/var/log/messages里也有)

提示:
nf_conntrack: nf_conntrack: table full, dropping packet

从日志看意思是:内核 netfilter 模块 conntrack 相关参数配置不合理,导致新连接被 drop 掉

原因

The iptables connection-tracking module uses a portion of the system memory to track connections in a table. The size of this table is set when the conntrack module is loaded, and is determined automatically based on the available system RAM. For example, a system with 256MB RAM will typically have a conntrack table of 8192 entries by default.
Expect 250 to 400 bytes of memory use per active connection.
The table full, dropping packet message means that the connection tracking table is full and a new entry for a new connection cannot be made because there is no more room. As a result, the packet fails connection tracking firewall check and is dropped by the firewall. The solution is to increase the number of connection tracking entries.

解决方法

  • 查看当前的ct表行数:
cat /proc/sys/net/netfilter/nf_conntrack_count
conntrack -L |wc -l
  • 查看当前的nf_conntrack参数
sysctl net.netfilter.nf_conntrack_max
cat /proc/sys/net/netfilter/nf_conntrack_max

修复方法分两步, 一是即时生效,二是修改配置文件

即时生效

1、 在物理服务器执行: sysctl -w net.netfilter.nf_conntrack_max=1024000
2、 调整CT hash size: echo 256000 > /sys/module/nf_conntrack/parameters/hashsize

关于ct表行数大小的限制和Hash表的size比例如下:

最好是2的N次方

On RHEL 6 and newer, the rule of thumb is hashsize = conntrack_max / 4

On RHEL 5, the rule of thumb is hashsize = conntrack_max / 8

配置文件


lsmod|grep nf_conntrack
or
cat /proc/modules |grep nf_conntrack

确认是否有该模块;
然后修改配置文件: 在/etc/sysctl.conf里添加
net.netfilter.nf_conntrack_max = 1024000
在/etc/modprobe.d/下新建一个nf_conntrack.conf(文件名关系不大)的配置文件 编辑文件/etc/modprobe.d/nf_conntrack.conf,添加如下内容并保存:
options nf_conntrack expect_hashsize=256000 hashsize=256000

标签:丢包,max,虚拟机,nf,connection,conntrack,table,netfilter
From: https://www.cnblogs.com/ishmaelwanglin/p/17742480.html

相关文章

  • ARM 架构的 JVM(Java 虚拟机)最高的免费版本是 OpenJDK 17
    目前(截至2023年9月),ARM架构的JVM(Java虚拟机)最高的免费版本是OpenJDK17。OpenJDK17是JavaSE17的开源实现,由Oracle和其他开源贡献者共同维护。你可以在ARM架构的设备上安装和使用OpenJDK17,它包含了JavaSE17的所有功能和改进。要在ARM架构的设备上安装Op......
  • 论文阅读:Semi-supervised point cloud segmentation using self-training with label
    Semi-supervisedpointcloudsegmentationusingself-trainingwithlabelconfidencepredictionLi等人(2021b)基于伪标签置信度预测的半监督分割方法,额外设计判别网络(discriminatornetwork),该网络目标是区分预测结果和真实标注,并对无标注点云的预测结果输出置信度预测,对判别网络......
  • printf 和scanf的用法(最终版)
    一 格式化输入函数scanfscanf函数的功能是格式化输入任意数据列表,其一般调用格式为:scanf(格式控制符,地址列表)【说明】(1)地址列表中给出各变量的地址,可以为变量的地址,以&开头,也可以为数组,字符串的首地址。(2)格式控制符由%和格式符组成,作用......
  • 一 . 格式化输出函数 scanf
    scanf函数的功能是格式化输出任意数据列表,其一般调用格式为:scanf(格式控制符,地址列表)。【说明】(1)地址列表中给出各变量的地址,可以为变量的地址,以&开头,也可以为数组,字符串的首地址。(2)格式控制符由%和格式符组成,作用是将要输入的字符按指定的格式输入如%d,%c......
  • scanf&printf
         ......
  • printf scanf
               ......
  • Configure oh my zsh
    aptinstallzshsh-c"$(curl-fsSLhttps://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"REF: https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH pugins:gitclonehttps://github.com/zsh-users/zsh-autosuggestions.git......
  • confluence搭建
    confluence搭建及注意事项安装连接:https://www.liuwg.com/archives/centos79-xia-yum-an-zhuang-mysql80mysql用户名密码rootu8FI(oeiuf!oKwiki安装文档https://zhuanlan.zhihu.com/p/638418693atlassian-extras-decoder-v2-3.4.1.jaratlassian-extras-decoder-v2-......
  • VMWare 虚拟机 CPU 设置里针对 CPU 的 Intel VT-x 选项功能介绍
    虚拟化技术是现代计算的关键组成部分,它使多个虚拟机(VM)可以在单个物理主机上运行,每个虚拟机都似乎是独立的计算机。VMware作为虚拟化技术领域的领导者之一,提供了强大的虚拟化解决方案,其中一个重要的组成部分就是对CPU虚拟化的支持。在VMware虚拟机设置选项中,选择启用虚拟化引擎的......
  • 关于 VMware 虚拟机中的 SVGA II 虚拟设备
    VMwareSVGAII是VMware虚拟机中用于图形显示的虚拟显卡设备的一种。它是一种虚拟设备,专门为在虚拟机环境中提供图形支持而设计的。VMwareSVGAII虚拟设备的作用是模拟物理计算机上的图形适配器,允许虚拟机实例在虚拟化的环境中进行图形处理和显示。在本文中,我将详细解释VMwar......