[ linux ] 工作中常用的防火墙操作

简介: 之前写防火墙简介,有粉丝私信我:Linux的相关防火墙操作在这里我总结了一些Linux关于防火墙的常用操作总结的可能不是很全面,但在工作中是绝对够了

1. 防火墙的基本使用



systemctl status firewalld  #查看防火墙状态

firewall-cmd --state   #查看防护墙状态

systemctl stop firewalld #关闭防火墙

systemctl start firewalld  #开启防火墙

systemctl restart firewalld  #重启防火墙


2. 服务操作



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


3. 配置firewalld-cmd



/etc/firewalld/zones  #配置规则

/etc/firewalld/firewalld.conf  #主配置文件

firewall-cmd --list-all  #查看所有规则


添加服务firewall-cmd --add-service=http --permanent

移除服务firewall-cmd --remove-service=http --permanent

查看版本: firewall-cmd --version

查看帮助: firewall-cmd --help

显示状态: firewall-cmd --state

查看所有打开的端口: firewall-cmd --zone=public --list-ports

更新防火墙规则: firewall-cmd --reload

查看区域信息:  firewall-cmd --get-active-zones

查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0

拒绝所有包:firewall-cmd --panic-on

取消拒绝状态: firewall-cmd --panic-off

查看是否拒绝: firewall-cmd --query-panic


端口操作:



firewall-cmd --zone=public --add-port=5000/tcp --permanent  #开放5000端口

firewall-cmd --reload   #重载服务

firewall-cmd --list-ports  #查看已经开放的端口

firewall-cmd --remove-port=5555/tcp   #移除端口

相关文章
|
12天前
|
存储 安全 数据管理
探索Linux的挂载操作🌈
在Linux这个强大的操作系统中,挂载操作是一个基本而重要的概念。它涉及到文件系统、设备和数据访问,对于理解Linux的工作方式至关重要。那么,挂载操作究竟是什么,为什么我们需要它,如果没有它,我们将面临什么问题呢?让我们一起深入探讨。
探索Linux的挂载操作🌈
|
22天前
|
Linux Windows
Linux之基本指令操作
Linux之基本指令操作
|
1月前
|
Linux C语言
Linux系统下C语言的队列操作
Linux系统下C语言的队列操作
23 0
|
2月前
|
存储 Linux API
Linux应用开发基础知识——文件IO操作(三)
Linux应用开发基础知识——文件IO操作(三)
54 2
Linux应用开发基础知识——文件IO操作(三)
|
28天前
|
存储 算法 Shell
【Shell 命令集合 磁盘维护 】Linux 对软盘进行格式化操作 fdformat命令使用指南
【Shell 命令集合 磁盘维护 】Linux 对软盘进行格式化操作 fdformat命令使用指南
32 0
|
28天前
|
Shell Linux C语言
【Shell 命令集合 磁盘管理 】Linux 控制光驱或可移动媒体设备的弹出和关闭操作 eject命令使用教程
【Shell 命令集合 磁盘管理 】Linux 控制光驱或可移动媒体设备的弹出和关闭操作 eject命令使用教程
35 1
|
1月前
|
存储 安全 网络协议
使用 firewall-cmd 管理 Linux 防火墙端口
本文将介绍如何使用 firewall-cmd 工具在 Linux 系统中进行简单端口管理,包括开放、查询、关闭等操作。通过实例展示相关命令的用法,希望能对大家有所帮助。
|
28天前
|
算法 Shell Linux
【Shell 命令集合 文档编辑 内建命令】Linux数值运算和赋值操作 let命令使用指南
【Shell 命令集合 文档编辑 内建命令】Linux数值运算和赋值操作 let命令使用指南
26 0
|
Linux C++
【Linux】—— 在Linux上进行读写文件操作
【Linux】—— 在Linux上进行读写文件操作
|
1月前
|
监控 算法 Linux
Linux 操作系统常用命令与操作指南
本文将为大家介绍Linux操作系统中的常用命令和操作。这些命令对于初学者和Linux用户都非常重要,掌握它们将大大提高在Linux环境下的工作效率。