CentOS 7 使用firewalld代替了原来的iptables,使用方法如下:

>>>关闭防火墙

systemctl stop firewalld.service            #停止firewall
systemctl disable firewalld.service        #禁止firewall开机启动

>>>开启端口

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

命令含义

--zone #作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议
--permanent #永久生效,没有此参数重启后失效

>>>重启防火墙

firewall-cmd --reload

其他常用命令:

firewall-cmd --state                          ##查看防火墙状态,是否是running
firewall-cmd --reload                          ##重新载入配置,比如添加规则之后,需要执行此命令
firewall-cmd --get-zones                      ##列出支持的zone
firewall-cmd --get-services                    ##列出支持的服务,在列表中的服务是放行的
firewall-cmd --query-service ftp              ##查看ftp服务是否支持,返回yes或者no
firewall-cmd --add-service=ftp                ##临时开放ftp服务
firewall-cmd --add-service=ftp --permanent    ##永久开放ftp服务
firewall-cmd --remove-service=ftp --permanent  ##永久移除ftp服务
firewall-cmd --add-port=80/tcp --permanent    ##永久添加80端口
iptables -L -n                                ##查看规则,这个命令是和iptables的相同的
man firewall-cmd                              ##查看帮助

更多命令,使用 firewall-cmd --help 查看帮助文件

>>> CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下

1、直接关闭防火墙

systemctl stop firewalld.service          #停止firewall
systemctl disable firewalld.service    #禁止firewall开机启动

2、设置 iptables service

yum -y install iptables-services
如果要修改防火墙配置,如增加防火墙端口3306
vi /etc/sysconfig/iptables
增加规则
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动

最后重启系统使设置生效即可。

CentOS 7防火墙服务FirewallD指南  http://www.linuxidc.com/Linux/2016-10/136431.htm

firewalld和iptables 详解  http://www.linuxidc.com/Linux/2017-03/141434.htm

CentOS7下Firewalld防火墙使用实例  http://www.linuxidc.com/Linux/2017-01/139637.htm

CentOS 7下FirewallD使用简介  http://www.linuxidc.com/Linux/2016-11/137093.htm

本文永久更新链接地址http://www.linuxidc.com/Linux/2017-11/148427.htm

CentOS 7 打开关闭FirewallD防火墙端口命令的更多相关文章

  1. CentOS 7.0 关闭firewalld防火墙指令 及更换Iptables防火墙

    CentOS 7.0 关闭firewalld防火墙指令 及更换Iptables防火墙 时间:2014-10-13 19:03:48  作者:哎丫丫  来源:哎丫丫数码网  查看:11761  评论:2 ...

  2. CentOS 7 开放防火墙端口命令

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

  3. CentOS 7 开放防火墙端口 命令(转载)

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

  4. linux 安装禅道 和 CentOS 7 开放防火墙端口 命令

    linux 安装禅道链接:  https://www.cnblogs.com/maohuidong/p/9750202.html CentOS 7 开放防火墙端口 命令 链接:https://www. ...

  5. linux命令启动关闭firewalld防火墙,添加端口

    firewalld管理防火墙常用命令   1.查看防火墙的状态 [root@localhost HMK]# firewall-cmd --state 查看防火墙的运行状态 not running [r ...

  6. (转)CentOS 7.0关闭默认防火墙启用iptables防火墙

    场景:在本地虚拟机上使用ftp软件需要进行相应的端口设置,不可避免要访问Cnetos的防火墙,默认firewall操作不方便,所以需要进行相应的替换. 1 配置防火墙,开启80端口.3306端口 1. ...

  7. Centos7 开放防火墙端口命令

    Centos 7 使用firewalld代替了原来的iptables,使用方法如下: >>>关闭防火墙 systemctl stop firewalld.service       ...

  8. CentOS 7.0关闭默认防火墙启用iptables防火墙

    转自:https://www.cnblogs.com/lixuwu/p/6087023.html 阅读目录 1 配置防火墙,开启80端口.3306端口 2 关闭SELINUX 3 CentOS 配置防 ...

  9. CentOS 7 开放防火墙端口 命令

    iptables防火墙 1.基本操作 # 查看防火墙状态 service iptables status   # 停止防火墙 service iptables stop   # 启动防火墙 servi ...

随机推荐

  1. 【转】mysql 索引过长1071-max key length is 767 byte

    问题 create table: Specified key was too long; max key length is 767 bytes 原因 数据库表采用utf8编码,其中varchar(2 ...

  2. 【php】https请求

    /** * 模拟提交参数,支持https提交 可用于各类api请求 * @param string $url : 提交的地址 * @param array $data :POST数组 * @param ...

  3. Oracle用户密码过期的处理方法

    受影响版本:Oracle11g以上版本.   导致密码消失的原因:Oracle 11g中默认的DEFAULT概要文件中口令有效期PASSWORD_LIFE_TIME默认值为180天.   当以客户端登 ...

  4. 问题-MethodAddress返回NIL?MethodAddress与published的关系?

    问题现象:有位朋友(397085381)在Q群里问“为什么书上的可以访问,而自己写的代码访问时为nil” 问题原因:因为要用“Self.MethodAddress('Test')”访问,方法必须放在“ ...

  5. 1. pyhanlp介绍和简单应用

    1. pyhanlp介绍和简单应用 2. 观点提取和聚类代码详解 1. 前言 中文分词≠自然语言处理! 中文分词只是第一步:HanLP从中文分词开始,覆盖词性标注.命名实体识别.句法分析.文本分类等常 ...

  6. [转]Oracle 树操作(select…start with…connect by…prior)

    原文地址:https://www.cnblogs.com/colder/p/4838574.html oracle树查询的最重要的就是select…start with…connect by…prio ...

  7. Map 与 JavaBean 的相互装换

    目的 为了方便使用 DbUtils,在插入数据时需要传入含有占位符的 SQL 语句和对应占位符的值(数组),封装代码如下: /** * 插入实体 */ public static <T> ...

  8. C语言 · 字符删除

    算法训练 字符删除   时间限制:1.0s   内存限制:512.0MB      问题描述 编写一个程序,先输入一个字符串str(长度不超过20),再输入单独的一个字符ch,然后程序会把字符串str ...

  9. <魔鬼投资学>读书笔记

    书在这里 太多的投资者沉溺于结果,但却忽略了过程 在任何一个存在不确定系的领域中,比如投资.管理球队或是赌马,最优秀的长期成功者都会更重视过程,而不是结果 投资过程的目的:认识一家公司股票现在价格与未 ...

  10. Go Revel - Routing(路由)

    `Routing`路由控制着请求应该由哪些控制器接受. 它在项目的`conf/routes`文件中定义. 格式为: (METHOD) (URL Pattern) (Controller.Action) ...