随笔 - 70,  文章 - 0,  评论 - 1,  阅读 - 97430

centos 7 中没有iptables 和service iptables save 指令使用失败

1.任意运行一条iptables防火墙规则配置命令:

iptables -P OUTPUT ACCEPT  

2.对iptables服务进行保存:

service iptables save  

如果上述命令执行失败报出:The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

解决方法:
#systemctl stop firewalld               关闭防火墙

#systemctl disable firewalld.service        #禁止firewall开机启动
#yum install iptables-services            安装或更新服务
#systemctl enable iptables                启动iptables
# systemctl start iptables                  打开iptables

#service iptables save                      保存

3.重启iptables服务:

service iptables restart

执行完毕之后/etc/syscofig/iptables文件就有了

成品例句

iptables –A INPUT –s 192.168.0.188 –p tcp  --dport 80 –j ACCEPT

来自188的tcp 80端口放行

iptables –A OUTPUT –d 192.168.0.188 –p tcp  --dport 80 –j ACCEPT

传输给188ip的tcp的80端口放行

 

丢弃默认链连接

#iptables -P INPUT DROP                                            

#iptables -p OUTPUT DROP                            

#iptables -P FORWARD DROP

 

 

 

管理规则

            -A:附加一条规则,添加丰链的尾部

            -I CHAIN [NUM]:插入一条规则插入为对应CHAIN上的第NUM条

            -D CHAIN [NUM]:删除指定链中的第NUM规则

            -R CHAIN [NUM]:替换指定的规则

管理链

            -F [CHAIN]清空指定规则链,如果省略CHAIN则可买实现删除对应的所有链

            -P CHAIN:设定指定链默认策略

            -N:自定义一个新的空链

            -X:删除一个自定义的空链

            -Z:置零指定链中所有规则的计数器

            -E:重命名自定义的链

查看类:

            -L :显示指定表中的规则

            -n:以数字显示主机换

            -x:显示计数器的精确值

            -v:显示详细信息

            --line-numbers:显示规则号码

posted on   JasonChen1030  阅读(3236)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示