iptables查询自动加载nf_conntrack模块引起故障

本文介绍了iptables与ip_conntrack模块的关系及其对系统性能的影响。详细讲述了防火墙关闭状态下使用iptables命令可能带来的问题,并提供了nf_conntrack:tablefull,droppingpacket错误的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景:

ip_conntrack是linux NAT的一个跟踪连接条目的模块,与Iptables相关,ip _conntrack模块会使用一个哈希表记录 tcp 通讯协议的 established connection记录,当这个哈希表满了的时候,便会导致nf_conntrack: table full, dropping packet错误。

在防火墙关闭状态下,不要通过iptables指令(比如 iptables -nL)来查看当前状态!因为这样会导致防火墙被启动,而且规则为空。虽然不会有任何拦截效果,但所有连接状态都会被记录,浪费资源且影响性能并可能导致防火墙主动丢包!

测试:

1、防火墙在关闭状态下,使用iptables命令,会导致防火墙被启动:

2、通过iptables命令,防火墙被启动时,规则是为空的,不会像正常启动那样存在规则:


解决:

1、nf_conntrack: table full, dropping packet问题的解决方法:

引用:http://www.cnblogs.com/higkoo/articles/iptables_tunning_for_conntrack.html


问题:

1、iptables启动不了,且没有任何报错:

排查后发现原因是缺少iptables文件(/etc/sysconfig/iptables)

解决方法:添加一条iptables规则 :sudo iptables -A INPUT -i eth0 -p tcp -s 11.11.11.11 -j DROP (自动生成/etc/sysconfig/iptables文件)


cat /etc/sysconfig/iptables-config cat: /etc/sysconfig/iptables-config: Permission denied [yanyong_i@sys-hwm-sol-collect04 test_project]$ sudo cat /etc/sysconfig/iptables-config # Load additional iptables modules (nat helpers) # Default: -none- # Space separated list of nat helpers (e.g. 'ip_nat_ftp ip_nat_irc'), which # are loaded after the firewall rules are applied. Options for the helpers are # stored in /etc/modprobe.conf. IPTABLES_MODULES="" # Unload modules on restart and stop # Value: yes|no, default: yes # This option has to be 'yes' to get to a sane state for a firewall # restart or stop. Only set to 'no' if there are problems unloading netfilter # modules. IPTABLES_MODULES_UNLOAD="yes" # Save current firewall rules on stop. # Value: yes|no, default: no # Saves all firewall rules to /etc/sysconfig/iptables if firewall gets stopped # (e.g. on system shutdown). IPTABLES_SAVE_ON_STOP="no" # Save current firewall rules on restart. # Value: yes|no, default: no # Saves all firewall rules to /etc/sysconfig/iptables if firewall gets # restarted. IPTABLES_SAVE_ON_RESTART="no" # Save (and restore) rule and chain counter. # Value: yes|no, default: no # Save counters for rules and chains to /etc/sysconfig/iptables if # 'service iptables save' is called or on stop or restart if SAVE_ON_STOP or # SAVE_ON_RESTART is enabled. IPTABLES_SAVE_COUNTER="no" # Numeric status output # Value: yes|no, default: yes # Print IP addresses and port numbers in numeric format in the status output. IPTABLES_STATUS_NUMERIC="yes" # Verbose status output # Value: yes|no, default: yes # Print info about the number of packets and bytes plus the "input-" and # "outputdevice" in the status output. IPTABLES_STATUS_VERBOSE="no" # Status output with numbered lines # Value: yes|no, default: yes # Print a counter/number for every rule in the status output. IPTABLES_STATUS_LINENUMBERS="yes" # Reload sysctl settings on start and restart # Default: -none- # Space separated list of sysctl items which are to be reloaded on start. # List items will be matched by fgrep. #IPTABLES_SYSCTL_LOAD_LIST=".nf_conntrack .bridge-nf" 有什么问题
最新发布
06-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值