[转帖]Linux firewalld 防火墙使用
目录
firewall 简述
- Centos7默认的防火墙是 firewall,替代了以前的 iptables
- firewall使用更加方便、功能也更加强大一些
- firewalld 服务引入了一个信任级别的概念来管理与之相关联的连接与接口。它支持 ipv4 与 ipv6,并支持网桥,采用 firewall-cmd (command) 或 firewall-config (gui) 来动态的管理 kernel netfilter 的临时或永久的接口规则,并实时生效而无需重启服务。
firewall 版本
- 查看版本:firewall-cmd --version
firewall 安装
- 像使用iptables一样,firewall同样需要安装
- 需要注意的是某些系统已经自带了firewall的,如果查看版本没有找到,则可以进行yun安装
- 安装指令: yum install firewalld
firewalld 基本使用
- firewall与iptables一样都是服务,所以可以使用systemctl服务管理工具来操作
查看防火墙状态
- 1、查看firewall服务状态: systemctl status firewalld
关闭防火墙
- 2、停止firewall服务:systemctl stop firewalld
开启防火墙
- 3、启动firewall服务:systemctl start firewalld
重启防火墙
- 重启firewall服务:systemctl restart firewalld
查看防火墙是否开机自启
- 4、查看firewall服务是否开机启动:systemctl is-enabled firewalld
开机自启防火墙
- 5、开机时启动firewall服务:systemctl enable firewalld.service
开机禁用防火墙
- 6、开机时禁用firewall服务:systemctl disable firewalld.service
firewalld-cmd 基本使用
- 1、上面所说的 firewall 可以看成整个防火墙服务,而firewall-cmd可以看成是其中的一个功能,可用来管理端口
查看 firewall-cmd 状态
- 2、查看firewall状态,即查看 firewall 防火墙程序是否正在运行: firewall-cmd --state
查看已打开端口
- 3、查看所有已经打开的端口: firewall-cmd --zone=public --list-ports
开启指定端口
- 4、开启一个端口:firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent 永久生效,没有此参数重启后失效)
- 5、重新加载firewall,修改配置后,必须重新加载才能生效:firewall-cmd --reload
[root@localhost ~]# firewall-cmd --zone=public --list-port /tcp /tcp /tcp /tcp [root@localhost ~]# firewall-cmd --zone=/tcp --permanent success [root@localhost ~]# firewall-cmd --reload success [root@localhost ~]# firewall-cmd --zone=public --list-port /tcp /tcp /tcp /tcp /tcp
关闭指定端口
- 关闭9876端口:firewall-cmd --zone=public --remove-port=9898/tcp --permanent(--permanent 表示永久生效,没有此参数重启后失效)
- 重新加载 firewall,修改配置后,必须重新加载才能生效:firewall-cmd --reload
[root@localhost ~]# firewall-cmd --zone=public --list-ports /tcp /tcp /tcp /tcp [root@localhost ~]# firewall-cmd --zone=/tcp --permanent success [root@localhost ~]# firewall-cmd --reload success [root@localhost ~]# firewall-cmd --zone=public --list-ports /tcp /tcp /tcp [root@localhost ~]
修改文件操作端口
- firewall-cmd对端口的操作,如开放端口等信息,都放在在"/etc/firewall/zones/public.xml"中记录
- 所以直接修改此文件也是可以的
注意事项
- 如下所示,CentOS 7.2 Linux系统防火墙明明开启了指定的端口,tomcat服务器端口也指定正确,启动没有任何问题,最后从windows浏览器访问的时候,却只有80端口有效,其余的端口全部访问失败
- 最后原因居然是因为系统是阿里云服务器,而它的后台为了安全,封掉了其它端口的访问,所以即使防火墙修改了也没用,解决办法是登录阿里云服务器后台,修改它的安全组策略即可
[转帖]Linux firewalld 防火墙使用的更多相关文章
- Linux firewalld 防火墙
Linux firewalld 防火墙 简介 RHEL 7 系统中集成了多款防火墙管理工具,其中 firewalld(Dynamic Firewall Manager of Linux system ...
- linux firewalld 防火墙操作命令
查看防火墙的状态systemctl status firewalldTomcat默认使用8080端口,如果防火墙开启,需要开通8080端口firewall-cmd --zone=public --ad ...
- 使用 firewalld 构建 Linux 动态防火墙
firewalld 是新一 Linux 代防火墙工具,它提供了支持网络 / 防火墙区域 (zone) 定义网络链接以及接口安全等级的动态防火墙管理工具.它也支持允许服务或者应用程序直接添加防火墙规则的 ...
- linux系统中firewalld防火墙管理工具firewall-config(GUI图形用户界面)
firewall-config是firewalld防火墙管理工具的GUI(图形用户界面)版本,几乎可以实现所有以命令行来执行的操作. firewall-config的界面如下图(在终端直接运行fire ...
- 第7章 Iptables与Firewalld防火墙。
第7章 Iptables与Firewalld防火墙. Chapter7_听较强节奏的音乐能够让您更长时间的投入在学习中. <Linux就该这么学> 00:00/00:00 ...
- 第8章 Iptables与Firewalld防火墙
章节简述: 红帽RHEL7系统已经用firewalld服务替代了iptables服务,新的防火墙管理命令firewall-cmd与图形化工具firewall-config. 本章节基于数十个防火墙需求 ...
- SpringCloud的应用发布(四)vmvare+linux,防火墙和selinux
一.vmvare网络配置为nat模式 二.vmvare的网络设置为桥接bridge模式 1.linux 网卡的ip获取方式dhcp 三.关闭linux的防火墙和selinux 1.临时关闭防火墙 sy ...
- CentOS7使用firewalld防火墙配置端口
安装启用firewalld防火墙 CentOS7默认的防火墙是firewalld 如果没有firewalld防火墙,可以执行yum install firewalld 命令进行安装 firewalld ...
- CentOS7、REHL7的firewalld防火墙使用简单说明
title: CentOS7.REHL7的firewalld防火墙使用简单说明 categories: Linux tags: - Linux timezone: Asia/Shanghai date ...
随机推荐
- 02、JDBC查询
① 向数据库发送SQL查询语句 首先使用Statement声明一个SQL语句对象,然后让已创建的连接对象con调用方法createStatement()创建SQL语句对象. Statement sql ...
- 实现HTML调用打开本地软件文件
有时候我们想要实现一个功能,就是在HTML页面点击一个链接就能调用打开本地可执行文件.就像腾讯QQ.迅雷这种. 而实现这种功能其实也很简单,就是需要我们添加修改注册表,实现自定义URL Protoco ...
- 【MySQL】备份和恢复
语法 mysqldump -uslave -p -h127.0.0.1 --single-transaction --set-gtid-purged=OFF database1 table1 tabl ...
- oracle 查询角色具有的权限
select * from dba_tab_privs where GRANTEE='角色名';
- 极简让ingress-nginx最新版(0.25.0)跑起来
裸步骤: 一,manadatory.yaml apiVersion: v1 kind: Namespace metadata: name: ingress-nginx labels: app.kube ...
- maven 配置文件
<properties> <project.builder.sourcesEncoding>UTF-8</project.builder.sourcesEncoding& ...
- vs2017无法查看类图
问题描述: 在解决方案右键项目,没有查看->查看类图选项 问题根据: VS安装时没有安装VS扩展中的类设计器 解决方案: 运行安装包,找到Other Tols勾选Visual Studio ex ...
- 02-docker入门-docker常用的一些命令
在这里,有必要先对ducker在做一次介绍 ducker 是一个容器. 容器内部运行的是一个系统. 系统内部安装好了要调试 / 发布的工程,然后这个系统被打包成了一个镜像. ducker 就是这个镜像 ...
- 14-cmake语法-循环
循环: foreach set(VAR a b c) foreach(f ${VAR}) message(${f}) endforeach() while set(VAR 5) while(${VAR ...
- nginx 搭建上传服务器
nginx webdav 服务器搭建 该模块可以为Http webDAV 增加PUT,DELETE,MKCOL,COPY和MOVE等方法.模块在默认编译的情况下是不被包含的,需要指定编译 ./conf ...