注意:firewalld服务有两份规则策略配置记录,配置永久生效的策略记录时,需要执行"reload"参数后才能立即生效

  • Permanent:永久生效的
  • RunTime:现在正在生效的

1.查看当前区域

[root@ecs-7bec-0002 bin]# chkconfig iptables off
public

2.查看防火墙状态,需要注意的是,设置端口规则时防火墙必须是启动状态

[root@ecs-7bec-0002 ~]# systemctl status firewalld     //返回信息提示防火墙未启动
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)      //dead代表关闭状态
Docs: man:firewalld(1)
[root@ecs-7bec-0002 ~]# systemctl start firewalld     //启动防火墙
[root@ecs-7bec-0002 ~]# systemctl status firewalld     
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2018-10-09 19:38:36 CST; 2s ago
Docs: man:firewalld(1)
Main PID: 9269 (firewalld)
CGroup: /system.slice/firewalld.service
└─9269 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Oct 09 19:38:36 ecs-7bec-0002 systemd[1]: Starting firewalld - dynamic firewall daemon...
Oct 09 19:38:36 ecs-7bec-0002 systemd[1]: Started firewalld - dynamic firewall daemon.

3.配置需要开发的端口

[root@ecs-7bec-0002 ~]# firewall-cmd --zone=public --add-port=端口号/tcp --permanent
success

4.执行命令使端口生效

[root@ecs-7bec-0002 ~]# firewall-cmd --reload
success

5.查看端口是否生效

[root@ecs-7bec-0002 ~]# firewall-cmd --zone=public --query-port=端口号/tcp
yes

6.防火墙其他操作

[root@ecs-7bec-0002 ~]# firewall-cmd --list-port    //查看所有开发端口
3306/tcp 80/tcp
[root@ecs-7bec-0002 ~]# firewall-cmd --zone=public --remove-port=8080/tcp --permanent      删除一个端口
success
[root@ecs-7bec-0002 ~]# firewall-cmd --reload      //使新配置的端口规则生效
success
[root@ecs-7bec-0002 ~]# firewall-cmd --version      //查看版本
0.4.3.2
[root@ecs-7bec-0002 ~]# firewall-cmd --state
running
[root@ecs-7bec-0002 ~]# firewall-cmd --get-active-zones    //查看所在区域
public
interfaces: eth0

 

Centos 7中,防火墙配置端口规则的更多相关文章

  1. 如何在CentOS系统中安装配置SNMP服务

    CentOS(Community Enterprise Operating System,中文意思是:社区企业操作系统)是Linux发行版之一,现在有一大部分服务器在使用此操作系统:SNMP(简单网络 ...

  2. setup 命令中防火墙配置选项无法打开

    故障提示 1.1 如何让setup 命令中防火墙配置生效 1.1.1 CentOS系统找不到setup命令工具的解决方法 yum -y install setuptool #安装setup命令工具 y ...

  3. centos 7 中防火墙的关闭问题

    新安装的centos 7 发现有些程序端口是关闭的,想到了防火墙和selinux  selinx 好关闭 /etc/sysconfig/selinux 中 追加 SELINUX=disabled 防火 ...

  4. CentOS 7中防火墙 firewall-cmd命令

    在 CentOS 7 iptable 防火墙已经被 firewall替代 1.暂时开放FTP服务 firewall-cmd --add-service=ftp 2.永久开放FTP服务 firewall ...

  5. centOS服务器-firewall防火墙开放端口

    前言 日常开发中,我们常常会因为服务器各种端口未开放出现各种问题,下面我们就来简单了解下服务器上的端口开放!!! 作为一个后台开发,日常接触最多的除了代码就是服务器了: 产品:谁谁, 线上有个功能报错 ...

  6. centOS和redHat防火墙开放端口

    发现在CentOS 7上开放端口用iptables没效果(或者是sodino没找到正确的命令,传说Centos7 下默认的防火墙是 Firewall,替代了之前的 iptables)… 使用firew ...

  7. CentOS 7.x 防火墙开放端口相关用法记录

    前言 防火墙对服务器起到一定的保护作用,所以了解一些相关的操作是很有必要的. 在CentOS 7.x中,有了一种新的防火墙策略,FireWall , 还记得在6.x中用的还是iptables. 这几天 ...

  8. CentOS 6.8 防火墙配置

    系统: CentOS release 6.8 (Final) iptables v1.4.7 执行命令: #清除所有规则 iptables -F #开放redis端口 iptables -A INPU ...

  9. CentOS7 中防火墙配置

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

随机推荐

  1. ios17--自定义控件2改进

    控制器: // // XMGViewController.h #import <UIKit/UIKit.h> @interface XMGViewController : UIViewCo ...

  2. windowActionModeOverlay

    windowActionModeOverlay: android:windowActionModeOverlay=“true|false”  : actionmode 弹出时覆盖部分布局      若 ...

  3. cookie domain and cookie path

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie Domain=<domain-value> Opt ...

  4. XAML实例教程系列 - 类型转换器(Type Converter)七

    XAML实例教程系列 - 类型转换器(Type Converter) 分类: Windows 8 Silverlight2012-06-25 13:40 961人阅读 评论(0) 收藏 举报 butt ...

  5. 【线程安全】—— 单例类双重检查加锁(double-checked locking)

    1. 三个版本单例类的实现 版本1:经典版 public class Singleton { public static Singleton getInstance() { if (instance ...

  6. cookie应用(一周内免登陆)

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  7. windows下 redis/tomcat 服务自启动

    //设置redis服务自启动 //根据个人配置执行语句.   redis-server --service-install redis.windows.conf --loglevel verbose ...

  8. css为什么叫层叠样式表

    ------------------------------------------------------------------------------------ 层叠就是浏览器对多个样式来源进 ...

  9. Zabbix Server参数文件详解

    Zabbix的配置文件一般有三种: zabbix_server.conf:zabbix server的配置文件 zabbix_proxy.conf:zabbix proxy的配置文件 zabbix_a ...

  10. 【转】Linux下history命令用法

    转自:http://blog.sina.com.cn/s/blog_5caa94a00100gyls.html 如果你经常使用 Linux 命令行,那么使用 history(历史)命令可以有效地提升你 ...