CentOS7 端口的开放关闭查看都是用防火墙来控制的,具体命令如下:

查看防火墙状态:(active (running) 即是开启状态)

[root@WSS bin]# systemctl firewalld status
Unknown operation 'firewalld'.
[root@WSS bin]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 四 2019-07-11 09:37:11 CST; 7h ago
Docs: man:firewalld(1)
Main PID: 44370 (firewalld)
Tasks: 2
CGroup: /system.slice/firewalld.service
└─44370 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid 7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete FORWARD...hain?).
7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete FORWARD...hain?).
7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete FORWARD...hain?).
7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete FORWARD...t name.
7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete FORWARD...t name.
7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete INPUT -...hain?).
7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete INPUT -...hain?).
7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete OUTPUT ...hain?).
7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete INPUT -...hain?).
7月 11 09:37:13 WSS firewalld[44370]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete INPUT -...hain?).
Hint: Some lines were ellipsized, use -l to show in full.
[root@WSS bin]#

查看已开放端口:(8080和3306 即是已开放端口)

[root@WSS bin]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens3 ens4
sources: 
services: ssh dhcpv6-client
ports: 8080/tcp 3306/tcp
protocols: 
masquerade: no
forward-ports: 
source-ports: 
icmp-blocks: 
rich rules:

[root@WSS bin]#

防火墙开放端口:(开放端口后需重载防火墙)

[root@WSS bin]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@WSS bin]#
[root@WSS bin]# firewall-cmd --reload
success
[root@WSS bin]#

命令含义:

–zone #作用域

–add-port=80/tcp #添加端口,格式为:端口/通讯协议

–permanent #永久生效,没有此参数重启后失效

firewall-cmd --reload 并不中断用户连接,即不丢失状态信息

firewalld的基本使用

启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
配置firewalld-cmd

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic

Centos7 防火墙开放端口,查看状态,查看开放端口的更多相关文章

  1. Linux查看端口使用状态、关闭端口方法

    前提:首先你必须知道,端口不是独立存在的,它是依附于进程的.某个进程开启,那么它对应的端口就开启了,进程关闭,则该端口也就关闭了.下次若某个进程再次开启,则相应的端口也再次开启.而不要纯粹的理解为关闭 ...

  2. linux下如何关闭防火墙、查看当前的状态、开放端口

    从配置菜单关闭防火墙是不起作用的,索性在安装的时候就不要装防火墙查看防火墙状态:/etc/init.d/iptables status暂时关闭防火墙:/etc/init.d/iptables stop ...

  3. Centos7开启防火墙并且使MYSQL外网访问开放3306端口

    http://www.cnblogs.com/kreo/p/4368811.html CentOS7默认防火墙是firewalle,不是iptables #先检查是否安装了iptables servi ...

  4. centos7防火墙开放端口等命令

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

  5. CentOS7防火墙开启与关闭以及开放6379,3306,80等端口

    CentOS7用firewall防火墙替代了原来的iptables,所以我们应该使用firewall的一些命令.如下:1.关闭防火墙 systemctl stop firewalld.service ...

  6. Centos7防火墙快速开放端口配置方法

    ▲这篇文章主要为大家详细介绍了Centos7防火墙开放端口的快速方法,感兴趣的小伙伴们可以参考一下! Firewalld服务是红帽RHEL7系统中默认的防火墙管理工具,特点是拥有运行时配置与永久配置选 ...

  7. linux centos7 防火墙及端口开放相关命令

    一.防火墙相关命令 1.查看防火墙状态 : systemctl status firewalld.service 注:active是绿的running表示防火墙开启 2.关闭防火墙 :systemct ...

  8. CentOs7 防火墙的开放与关闭及端口的设定

    1.查看firewall服务状态 systemctl status firewalld 2.查看firewall的状态 firewall-cmd --state 3.开启.重启.关闭.firewall ...

  9. CentOS 6、CentOS7 防火墙开放指定端口

    当我们在CentOS服务器中装了一些开发环境(如 tomcat.mysql.nginx 等...)时,希望能从外界访问,就需要配置防火墙对指定端口开放. CentOS 6.51.开放指定端口/sbin ...

随机推荐

  1. Java并发编程(二):volatile关键字

    volatile是Java虚拟机提供的轻量级的同步机制.volatile关键字有如下两个作用,一句话概括就是内存可见性和禁止重排序. 1)保证被volatile修饰的共享变量对所有线程总是可见的,也就 ...

  2. 深入理解windows 消息机制

    深入理解Windows消息机制 今天我们来学一学Windows消息机制,我们知道在传统的C语音程序中,当我们需要打开一个文件时,我们可以调用fopen()函数,这个函数最后又会调用操作系统提供的函数以 ...

  3. 20194651—自动生成四则运算题第一版报告chris

    1.需求分析: (1)自动生成四则运算算式(+ - *  /),或两则运算(+  -). (2)剔除重复算式. (3)题目数量可定制. (4)相关参数可控制. (5)生成的运算题存储到外部文件中. 2 ...

  4. POJ_1006_中国剩余

    http://poj.org/problem?id=1006 中国剩余定理用来解求模方程组,用到了逆元. 这题三个数互质,直接用扩展欧几里德可得逆元. #include<iostream> ...

  5. 2019牛客多校2 F Partition problem(dfs)

    题意: n<=28个人,分成人数相同的两组,给你2*n*2*n的矩阵,如果(i,j)在不同的组里,竞争力增加v[i][j],问你怎么分配竞争力最 4s 思路: 枚举C(28,14)的状态,更新答 ...

  6. Golang设置https访问,以及http如何重定向到https

    设置https访问: 原始代码为http监听: func main() { server := &http.Server{ Addr: ":8080", ... } go ...

  7. Go语言实现:【剑指offer】和为S的两个数字

    该题目来源于牛客网<剑指offer>专题. 输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的. 对应每个测试案 ...

  8. Github 小白简单教学

    Git和Github简单教程   原文链接:Git和Github简单教程 网络上关于Git和GitHub的教程不少,但是这些教程有的命令太少不够用,有的命令太多,使得初期学习的时候需要额外花不少时间在 ...

  9. 磁盘文件系统管理与LVM逻辑卷

    一.磁盘以及分区管理 无论是Linux系统还是Windows系统.当现有硬盘的规划不能满足当前需求时.我们就需要将其重新规划和调整 实现上述操作我们就需要用到fdisk磁盘及分区管理工具.此工具是大多 ...

  10. 深入了解MySQL,一篇简短的总结

    MySQL的基本语法 这里作为MySQL部分模块的深入了解,大部分都是理论方面的笔记,不会写具体用法. 具体用法会记录在下面这个随笔分类下,不过暂时还没更新完,等过段时间会更新下事务.存储过程.索引等 ...