注意: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. Android自定义用户控件简单范例(一)

    一款优秀的移动应用需要具有自己独特统一的风格,通常情况下UI设计师会根据产品需求和使用人群的特点,设计整体的风格,界面的元素和控件的互效果.而原生态的Android控件为开发人员提供的是最基本的积木元 ...

  2. Codeforces Round #250 (Div. 2)B. The Child and Set 暴力

    B. The Child and Set   At the children's day, the child came to Picks's house, and messed his house ...

  3. 【Hnoi2010】Bzoj2002 Bounce & Codevs2333 弹飞绵羊

    Position: http://www.lydsy.com/JudgeOnline/problem.php?id=3143 http://codevs.cn/problem/2333/ Descri ...

  4. P2453 [SDOI2006]最短距离 dp

    自己想出来了!这个dp比较简单,而且转移也很简单,很自然,直接上代码就行了. 题干: 一种EDIT字母编辑器,它的功能是可以通过不同的变换操作可以把一个源串X [l..m]变换为新的目标串y[1..n ...

  5. Maven远程中央仓库地址

    阿里云 - http://maven.aliyun.com/nexus/content/groups/public/ Apache Snapshots - https://repository.apa ...

  6. PCB SQL SERVER 发送邮件(异步改同步)

    采用SQL SERVER发送邮件是队列方式(异步)发送邮件,所以在我们执行发送邮件后,无法立即获取到邮件是否发送成功了,而在PCB行业实际应用中是需要立即获取发送邮件是否成功的状态来决定下一步逻辑该如 ...

  7. codevs1230元素查找(hash)

    1230 元素查找  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond     题目描述 Description 给出n个正整数,然后有m个询问,每个询问一个 ...

  8. poj3264Balanced Lineup(倍增ST表)

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 52328   Accepted: 24551 ...

  9. 浅析SpringDataJpa继承结构

    一.SpringDataJpa的含义: SpringDataJpa: 是Spring基于ORM框架.JPA规范封装的一套JPA应用框架,是SpringData中的一个子模块,可让开发者用极简的代码即可 ...

  10. memcache缓存系统

    一.缓存系统 静态web页面: 1.在静态Web程序中,客户端使用Web浏览器(IE.FireFox等)经过网络(Network)连接到服务器上,使用HTTP协议发起一个请求(Request),告诉服 ...