首页 技术 正文
技术 2022年11月17日
0 收藏 984 点赞 4,880 浏览 1227 个字

安装启用firewalld防火墙

CentOS7默认的防火墙是firewalld

如果没有firewalld防火墙,可以执行yum install firewalld 命令进行安装

firewalld防火墙启用与关闭

启动systemctl start firewalld

关闭systemctl stop firewalld

查看状态systemctl status firewalld

查看状态firewall-cmd --state

开机启用systemctl enable firewalld

开机禁用systemctl disable firewalld

添加开放端口

查看开放了哪些端口

firewall-cmd --zone=public --list-ports

添加端口

firewall-cmd --add-port=443/tcp --permanent //永久添加443端口,协议为tcp
firewall-cmd --reload //重新加载

删除端口

firewall-cmd --zone=public --remove-port=80/tcp --permanent //删除tcp下的80端口

参数介绍:

firewall-cmd:是Linux提供的操作firewall的一个工具(注意没有字母“d”);

–permanent:表示设置为持久;

–add-port:标识添加的端口

–remove-port:标识删除的端口

配置文件

firewalld的默认区域配置文件位置在/etc/firewalld/zones/下的.xml文件中,如下图:

另外,firewall中有Zone的概念,可以将具体的端口制定到具体的zone配置文件中。

例如:添加8010端口

firewall-cmd --zone=public --permanent --add-port=8010/tcp
// --zone=public:指定的zone为public;

systemctl

systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务:systemctl start firewalld.service

关闭一个服务:systemctl stop firewalld.service

重启一个服务:systemctl restart firewalld.service

显示一个服务的状态:systemctl status firewalld.service

在开机时启用一个服务:systemctl enable firewalld.service

在开机时禁用一个服务:systemctl disable firewalld.service

查看服务是否开机启动:systemctl is-enabled firewalld.service

查看已启动的服务列表:systemctl list-unit-files|grep enabled

查看启动失败的服务列表:systemctl --failed

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,086
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,561
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,410
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,183
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,820
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,903