开启80端口

firewall-cmd --zone=public --add-port=80/tcp --permanent 

出现success表明添加成功

移除某个端口

firewall-cmd --zone=public --remove-port=80/tcp --permanent

firewall-cmd --list-all 查看防火墙打开的所有端口
 

命令含义:

--zone #作用域

--add-port=80/tcp  #添加端口,格式为:端口/通讯协议

--permanent   #永久生效,没有此参数重启后失效

重启防火墙

systemctl restart firewalld.service
 

1、运行、停止、禁用firewalld

启动:# systemctl start  firewalld

查看状态:# systemctl status firewalld 或者 firewall-cmd --state

停止:# systemctl disable firewalld

禁用:# systemctl stop firewalld

2、配置firewalld

查看版本:$ firewall-cmd --version

查看帮助:$ firewall-cmd --help

查看设置:

显示状态:$ firewall-cmd --state

查看区域信息: $ 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 --reload

# firewall-cmd --complete-reload

两者的区别就是第一个无需断开连接,就是firewalld特性之一动态添加规则,第二个需要断开连接,类似重启服务

将接口添加到区域,默认接口都在public

# firewall-cmd --zone=public --add-interface=eth0

永久生效再加上 --permanent 然后reload防火墙

设置默认接口区域

# firewall-cmd --set-default-zone=public

立即生效无需重启

打开端口(貌似这个才最常用)

查看所有打开的端口:

# firewall-cmd --zone=dmz --list-ports

加入一个端口到区域:

# firewall-cmd --zone=dmz --add-port=8080/tcp

若要永久生效方法同上

打开一个服务,类似于将端口可视化,服务需要在配置文件中添加,/etc/firewalld 目录下有services文件夹,这个不详细说了,详情参考文档

# firewall-cmd --zone=work --add-service=smtp

移除服务

# firewall-cmd --zone=work --remove-service=smtp

端口转发

将本服务的8056端口转发到ip地址为XXX.XX.XX.XXX的3356端口上,只能使用IP地址,不能使用主机名:

firewall-cmd --permanent --zone=public --add-forward-port=port=8056:proto=tcp:toaddr=xxx.xx.xx.xxx:toport=3356

firewall-cmd --list-ports --列出所有信息

firewall-cmd --remove-port=8056/tcp --临时删除端口
firewall-cmd --zone=public --remove-port=8005/tcp --permanent --永久删除卡对外开放的端口
firewall-cmd --permanent --zone=public --remove-forward-port=port=8056:proto=tcp:toaddr=xxx.xx.xx.xxx:toport=3356 --删除转发规则

Centos7 防火墙firewalld配置的更多相关文章

  1. CentOS7防火墙firewalld 和 CentOS6防火墙iptables的一些配置命令

    CentOS7 防火墙 一.防火墙的开启.关闭.禁用.查看状态命令 (1)启动防火墙:systemctl start firewalld (2)关闭防火墙:systemctl stop firewal ...

  2. 5分钟理解Centos7防火墙firewalld

    版权声明:本内容为原创内容,转载请声明出处. 原文地址:http://www.excelib.com/article/287/show firewalld简介 Centos7中默认将原来的防火墙ipt ...

  3. fedora/centos7防火墙FirewallD详解

    1 使用 FirewallD 构建动态防火墙 1.1 “守护进程” 1.2 静态防火墙(system-config-firewall/lokkit) 1.3 使用 iptables 和 ip6tabl ...

  4. centos7防火墙firewalld拒绝某ip或者某ip段访问服务器任何服务

    安装firewall后(LINUX7系统一般情况下默认已安装),防火墙默认配置是只打开SSH端口的,也就是22端口,如果SSH的端口已更改成别的端口了,请切记一定在启动firewall前先修改对应服务 ...

  5. CentOS7防火墙firewalld的配置

    开机启动的开启与禁止 # 开机启动 systemctl enable firewalld # 禁止开机启动 systemctl disable firewalld 基本操作 # 查看状态 system ...

  6. CentOS7 防火墙firewalld详细操作

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld  停止: systemctl disab ...

  7. Centos7 防火墙 firewalld 实用操作

    一.前言 Centos7以上的发行版都试自带了firewalld防火墙的,firewalld去带了iptables防火墙.其原因是iptables的防火墙策略是交由内核层面的netfilter网络过滤 ...

  8. Centos7 防火墙常用配置及说明

    一. Centos7和Centos6 防火墙的区别: 使用的工具不一样了.Centos6 使用的是iptables ,Centos7 使用的是filewall iptables 用于过滤数据包,属于网 ...

  9. CentOS7防火墙firewalld使用

    1.firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status f ...

随机推荐

  1. 数据库insert update select语句

    http://database.51cto.com/art/200903/113939_1.htm                   (更新语句) http://blog.csdn.net/chan ...

  2. 笔试算法题(22):二分法求旋转数组最小值 & 骰子值概率

    出题:将一个数组最开始的k个(K小于数组大小N)元素照搬到数组末尾,我们称之为数组的旋转:现在有一个已经排序的数组的一个旋转,要求输出旋转数组中的最小元素,且时间复杂度小于O(N): 分析: 时间复杂 ...

  3. js 技巧 (三)

    //无模式的提示框 function modelessAlert(Msg) {    window.showModelessDialog("javascript:alert("&q ...

  4. Vue如何引入jquery实现平滑滚动到指定位置效果

    在以往的做法里首选jquery的animate实现,但是Vue里并没有这个方法.如何在Vue项目中实现点击导航平滑滚动到指定位置,为了这效果我是快要崩溃了,上网查阅了很久发现并没有真正意义上解决这个问 ...

  5. php.ini中date.timezone设置分析

    date.timezone设置php5默认date.timezone为utc,改为date.timezone = PRC即可解决时间相差八小时的问题,但我在php的官方文档中看了半天也没找到这个参数啊 ...

  6. 乱记结论之OI常用四大数列

    一.斐波那契数列 $f(0)=1,f(1)=1,f(i)=f(i-1)+f(i-2) \ \ \ \ (i>=2)$ 经典的解释是兔子生小孩,第0年一对兔子,一对兔子需要一年长大,后面每年都生小 ...

  7. VS调试STL问题总结

    ---恢复内容开始--- 以前写代码总觉用自己写的东西比较牛逼,vector?stack?为什么不自己实现.后来才认识到这是个幼稚的想法!首先每次都自己实现是一种重复劳动:其次,自己写的话很难保证没有 ...

  8. 从零开始写STL-容器-list

    从零开始写STL-容器-list List 是STL 中的链表容器,今天我们将通过阅读和实现list源码来解决一下问题: List内部的内存结构是如何实现的? 为什么List的插入复杂度为O(1)? ...

  9. Binary Tree Preorder Traversal (非递归实现)

    具体思路参见:二叉树的非递归遍历(转) 先序遍历(根左右). 即把每一个节点当做根节点来对待. /** * Definition for binary tree * struct TreeNode { ...

  10. 激活IDEA 2019.1

    First step: 先下载jar包JetbrainsCrack.jar,把它放到你认为合适的文件夹内, 我放在了安装目录C:\Program Files\JetBrains\IntelliJ ID ...