C/C++教程

CentOS 防火墙入门

本文主要是介绍CentOS 防火墙入门,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

CentOS7 以下的版本默认使用 iptables 做为防火墙,CentOS 7开始默认使用的是firewall作为防火墙

本文使用的系统是 CentOS7,所以下面讲解的是firewall的操作。

 

 1. 查看防火墙是否开启

firewall-cmd --state

默认是没开启的状态,如下图

 

 

 

2. 查看firewalld状态/开启/关闭/重启/开机自启动

systemctl start firewalld.service //开启
systemctl status firewalld // 查看状态
systemctl enable firewalld // 开机自启动
systemctl stop firewalld // 关闭

 

3. 查看防火墙规则

如果要查看iptables目前运行的规则,使用iptables -L可以列出

- 查看对外网电脑防火墙列外的端口号
firewall-cmd --zone=public --list-ports 

 

4. 设置规则

– 开放指定端口
firewall-cmd --zone=public --add-port=1936/tcp --permanent

– 关闭指定端口
firewall-cmd --zone=public --remove-port=1936/tcp --permanent

– 重启防火墙
firewall-cmd --reloadl

 

相关链接:

https://www.linuxprobe.com/chapter-08.html

这篇关于CentOS 防火墙入门的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!