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. c与c++相互调用机制分析与实现

    c++通常被称为Better c,多数是因为c++程序可以很简单的调用c函数,语法上基本实现兼容.最常用的调用方式就是c++模块调用c实现的dll导出函数,很简单的用法,使用extern " ...

  2. Notepad++中支持Markdown

    最近在学习Markdown语言的使用,很想在XP主机上使用Markdown的离线编辑器,但MarkdownPad.作业部分的离线客户端都不能再XP上运行,需要.Net 4.5 以上版本,可惜一台老主机 ...

  3. SQL 迭代查询语句

    SQL迭代查询 PL/SQL with ORG_Tree(ObjectId,parentID) as ( select a.ObjectId,a.parentID from Ot_Organizati ...

  4. LeetCode: Linked List Cycle II 解题报告

    Linked List Cycle II Given a linked list, return the node where the cycle begins. If there is no cyc ...

  5. API:详解 pandas.read_csv

    pandas.read_csv 作为常用的读取数据的常用API,使用频率非常高,但是API中可选的参数有哪些呢? pandas项目代码 答案是: .read_csv(filepath_or_buffe ...

  6. chmod 权限 命令详细用法

    指令名称 : chmod 使用权限 : 所有使用者 使用方式 : chmod [-cfvR] [--help] [--version] mode file... 说明 : Linux/Unix 的档案 ...

  7. 固定高度div,随内容自动变高css定义方法

    *{ font-size:12px; margin:0; padding:0;}方法1:#testBox{border:1px solid #cccccc;padding:5px;width:220p ...

  8. JAVA-JSP内置对象之response对象实现页面跳转

    相关资料:<21天学通Java Web开发> response对象 实现页面跳转1.可以通过response对象的sendRedirect()方法设置页面重定向,从而实现页面跳转.2.这种 ...

  9. red hat enterprise linux 6

    i386(32位):http://rhel.ieesee.net/uingei/rhel-server-6.3-i386-dvd.iso迅雷快传:http://kuai.xunlei.com/d/PF ...

  10. Mybatis generator 自动生成代码(2)

    最近准备开始做一个项目,需要开始手动创建sql,于是将Mybatis generator 工具功能强化了下. 首先,这里引入到版本一点的包 <dependency> <groupId ...