Centos7 关闭防火墙(Firewalld ),使用防火墙(iptables)

1、直接关闭防火墙

systemctl stop firewalld.service; #停止firewall

systemctl disable firewalld.service; #禁止firewall开机启动

2、安装并启动 iptables service,以及设置开机自启

yum -y install iptables-services;#安装iptables

systemctl start iptables;#启动iptables

systemctl enable iptables;#自启动iptables

systemctl start ip6tables;#启动ip6tables(不需要可以跳过)

systemctl enable ip6tables;#自启动ip6tables(不需要可以跳过)

3、配置iptables service

vi /etc/sysconfig/iptables;#如增加防火墙端口3306和一些常用端口 80、8080等

增加规则:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT;
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT;
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT;
保存退出后。

3、重启 iptables service,

systemctl restart iptables.service #重启防火墙使配置生效

4、最后重启系统使设置生效即可

reboot;

 

posted @   草莓芒果  阅读(2258)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示