运行、停止、禁用firewalld

启动:# systemctl start  firewalld

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

停止:# systemctl disable firewalld

禁用:# systemctl stop firewalld

查看firewall是否运行,下面两个命令都可以

systemctl status firewalld.service
firewall-cmd --state

查看default zone和active zone

我们还没有做任何配置,default zone和active zone都应该是public

firewall-cmd --get-default-zone
firewall-cmd --get-active-zones

查看当前开了哪些端口

其实一个服务对应一个端口,每个服务对应/usr/lib/firewalld/services下面一个xml文件。

firewall-cmd --list-services

查看还有哪些服务可以打开

firewall-cmd --get-services

查看所有打开的端口:

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

更新防火墙规则:

firewall-cmd --reload

添加一个服务到firewalld

firewall-cmd --add-service=http //http换成想要开放的service

这样添加的service当前立刻生效,但系统下次启动就失效,可以测试使用。要永久开发一个service,加上 --permanent

firewall-cmd --permanent --add-service=http

如果要添加的端口并没有服务对应

就要新建一个服务,在/usr/lib/firewalld/services,随便拷贝一个xml文件到一个新名字,比如myservice.xml,把里面的

<?xml version="1.0" encoding="utf-8"?>

<service>
<short>Transmission-client</short>
<description>Transmission is a lightweight GTK+ BitTorrent client.</description>
<port protocol="tcp" port="51413"/>
</service>

short改为想要名字(这个名字只是为了人来阅读,没有实际影响。重要的是修改 protocol和port。修改完保存。我的经验是这是要重启firewalld服务,systemctl restart firewalld.service,否则可能提示找不到刚才新建的service。然后把新建的service添加到
firewalld

firewall-cmd --permanent --add-service=myservice

重启firewalld 生效

那怎么开启一个端口呢

添加
firewall-cmd --zone=public --add-port=80/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=80/tcp
删除
firewall-cmd --zone= public --remove-port=80/tcp --permanent

CentOS7为firewalld添加开放端口的更多相关文章

  1. CentOS7为firewalld添加开放端口及相关操作

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

  2. CentOS7 为firewalld添加开放端口

    1.运行.停止.禁用firewalld 启动:# systemctl start  firewalld 查看状态:# systemctl status firewalld 或者 firewall-cm ...

  3. CentOS 7 为firewalld添加开放端口及相关资料

    1.运行.停止.禁用firewalld 启动:# systemctl start  firewalld 查看状态:# systemctl status firewalld 或者 firewall-cm ...

  4. [转] CentOS 7 为firewalld添加开放端口及相关资料

    转自http://www.cnblogs.com/hubing/p/6058932.html 1.运行.停止.禁用firewalld 启动:# systemctl start  firewalld 查 ...

  5. CentOS下firewalld添加开放端口

    添加 firewall-cmd --zone=public --add-port=/tcp --permanent (--permanent永久生效,没有此参数重启后失效) 重新载入 firewall ...

  6. CentOS7使用firewalld防火墙配置端口

    安装启用firewalld防火墙 CentOS7默认的防火墙是firewalld 如果没有firewalld防火墙,可以执行yum install firewalld 命令进行安装 firewalld ...

  7. Centos7和Centos6防火墙开放端口配置方法(避坑教学)

    ▲这篇文章主要为大家详细介绍了Centos7防火墙开放端口的快速方法,感兴趣的小伙伴们可以参考一下! 一.CentOS 7快速开放端口: CentOS升级到7之后,发现无法使用iptables控制Li ...

  8. CentOS7使用iptables防火墙开放端口

    背景:在CentOS上面安装了mysql.svn.tomcat等软件,发现访问不了,用telnet命令查看端口,发现都不通: telnet IP 端口 CentOS7 默认使用firewalld防火墙 ...

  9. centos7通过firewalld更改sshd端口

    1.设置selinux端口 [root@hn ~]# semanage port -l|grep ssh -bash: semanage: 未找到命令 [root@hn ~]# whereis sem ...

随机推荐

  1. 数据库学习笔记 4 强大的SQL

    其实这篇文章应该至少一个星期前就应该更新了,但是最近小猿我和喜欢了好多年的女神牵手成功,所以这些天有点飘. ---创建表结构 create table tablename ( id int, name ...

  2. Unity3D项目程序加密-VirboxProtector加壳工具

    各位Unity3D的开发者,你还为你的代码被反编译而头疼, 混淆和加密已经失效,为内存dump代码而烦恼?是否辛苦制作的游戏被盗版被抄袭而烦恼? 是否害怕算法被别人参考要把算法写成C++而费劲周折? ...

  3. python中的str.strip()的用法

    python中字符串str的strip()方法 str.strip()就是把字符串(str)的头和尾的空格,以及位于头尾的\n \t之类给删掉. 例1:str=" ABC"prin ...

  4. jQuery学习笔记之extend方法小结

    在学习jQuery的时候,学习到了$.extend的主要用法,在此做一个简单的总结. (1)当只写一个对象自变量时,拓展的是jQuery的工具方法,如: $.extend({ aaa:function ...

  5. delphi JPG图片 旋转 切边 缩放

    unit UCutFigure_JPG; //JPG 切图 interface uses Windows, Messages, SysUtils, Variants, Classes, Graphic ...

  6. java 常用正则表达式总结

    邮政编码: ^[1-9]\d{5}$ QQ号码: ^[1-9]\d{4,10}$ 或者:[1-9][0-9]{4,11} 邮箱: ^[a-zA-Z_]{1,}[0-9]{0,}@(([a-zA-z0- ...

  7. Tomact高并发&Servlet线程处理

    Servlet/JSP技术和ASP.PHP等相比,由于其多线程运行而具有很高的执行效率.由于Servlet/JSP默认是以多线程模式执行的,所以,在编写代码时需要非常细致地考虑多线程的安全性问题.然而 ...

  8. 设计模式 --> MVC,MVP 和 MVVM 的图示

    MVC,MVP 和 MVVM 的图示 复杂的软件必须有清晰合理的架构,否则无法开发和维护.MVC(Model-View-Controller)是最常见的软件架构之一,业界有着广泛应用. 一.MVC M ...

  9. location和location.href跳转url的区别

    使用 location = url  跳转,如果本地之前已经载入过该页面并有缓存,那么会直接读取本地的缓存,缓存机制是由本地浏览器设置决定的.状态码为:  200 OK (from cache) . ...

  10. C语言作业--函数

    一.PTA实验作业 题目1: 400-499 中4出现的次数 1. 本题PTA提交列表 2. 设计思路 一.main函数 1.函数声明int fun(int x) 2.定义变量i,k,i表示输入的值, ...