Linux 防火墙 相关配置

 


iptables 相关操作

复制代码
 1 # 查看防火墙状态
 2  
 3 service iptables status
 4  
 5 # 停止防火墙
 6  
 7 service iptables stop
 8  
 9 # 启动防火墙
10  
11 service iptables start
12  
13 # 重启防火墙
14  
15 service iptables restart
16  
17 # 永久关闭防火墙
18  
19 chkconfig iptables off
20  
21 # 永久关闭后重启
22  
23 chkconfig iptables on
复制代码

 

firewalld相关操作

复制代码
//屏蔽
systemctl mask firewalld
//取消
systemctl unmask firewalld
//启动
systemctl start firewalld
//状态
systemctl status firewalld 
//停止
systemctl stop firewalld
//禁用
systemctl disable firewalld
//开机启用
systemctl enable firewalld.service
//开机禁用
systemctl disable firewalld.service
//查看开机启用
systemctl is-enabled firewalld.service
//查看已启动的服务
systemctl list-unit-files|grep enabled
//查看启动失败的服务
systemctl --failed
//查询特定端口是否开放
firewall-cmd --query-port=80/tcp
//开放特定端口
firewall-cmd --permanent --add-port=80/tcp
//关闭特定端口
firewall-cmd --permanent --remove-port=8080/tcp
//查看已开放的端口
firewall-cmd --list-ports
//重启防火墙
firewall-cmd --reload
复制代码

 

 

无iptables文件解决:

在RHEL 7 / CentOS 7中,firewalld被引入来管理iptables,CentOS7开始,默认是没有iptables的,而是使用firewall防火墙。本文将屏蔽掉firewall,使用iptables

Centos7版本解决方法:

1、停止并屏蔽firewalld服务:

停止:

systemctl stop firewalld

屏蔽:

systemctl mask firewalld

2、安装iptables-service软件包:

yum install iptables-services

3、在引导时启用iptables服务:

systemctl enable iptables

4、启动iptables服务:

systemctl start iptables

5、保存防火墙规则:

service iptables save
posted @   啄木鸟伍迪  阅读(393)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
//火箭 GenerateContentList();

喜欢请打赏

扫描二维码打赏

了解更多

点击右上角即可分享
微信分享提示