注意: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. poj 1741 楼教主男人八题之中的一个:树分治

    http://poj.org/problem? id=1741 Description Give a tree with n vertices,each edge has a length(posit ...

  2. BNUOJ 13098 约瑟夫环问题

    C. Josephus Problem 题目链接:http://www.bnuoj.com/v3/contest_show.php?cid=7095#problem/C 题目描述   The hist ...

  3. algorithm库———count&&countif

    algorithm头文件定义了一个count的函数,其功能类似于find.这个函数使用一对迭代器和一个值做参数,返回这个值出现次数的统计结果. 编写程序读取一系列int型数据,并将它们存储到vecto ...

  4. PCB MongoDB 索引

    在索引在数据库中非常重要,当然在MongoDB也是一样啦. 一.获取索引 db.ppeflow.getIndexes() 初始化,每个集都默认_id字段为主键objectid,索引名为_id_ 二.创 ...

  5. E20170805-hm

    mechanize vt. 使机械化; 用机械装置;

  6. 0606-工厂模式、单例模式、DBDA的单例和完整功能

    工厂模式:只要指定类名,就可以据此获取一个该类的对象. 单例模式:某个类,只允许其“创建”出一个对象. 单例的方法:三私一公(一个私有化对象,一个私有化构造方法,一个私有化克隆方法,一个公共方法返回对 ...

  7. web自动化测试—selenium操作游览器属性

    # coding=utf-8'''web游览器属性: 页面最大化 maximize_window() 获取当前页面地址 current_url 代码 page_source title title 后 ...

  8. $CF1141C Polycarp Restores Permutation$

    \(problem\) 这题的大致意思就是已知数值差值 求1-n的排列 如果能构成排列 则输出这个排列.如果不能则输出-1 排列的值都是 大于1 而小于n的 而且没有相同的数字. 这题最关键的是 怎么 ...

  9. BZOJ 2300凸包+离线

    思路: 倒着加显然吧  动态维护这个凸包就好了 //By SiriusRen #include <bits/stdc++.h> using namespace std; ; int n,m ...

  10. hdu2027

    http://acm.hdu.edu.cn/showproblem.php?pid=2027 #include<iostream> #include<stdio.h> #inc ...