CentOS升级到7之后用firewall代替了iptables来设置Linux端口,

下面是具体的设置方法:

[]:选填

<>:必填

[<zone>]:作用域(block、dmz、drop、external、home、internal、public、trusted、work)

<port>:端口号

[-<port>]:或者端口范围

<protocol>:端口协议(tcp、udp)协议目前支持这四种类型

[<seconds>]:过期时间,使用N秒后自动关闭(秒)

[--permanent]:永久设置,在重启后依然保证设置可用,如果不加此项,重启后端口会恢复关闭状态

注:设置端口后要重启防火墙使其生效 firewall-cmd --complete-reload

1、检查端口状态

yes:已开通

no:未开通

  1. firewall-cmd --query-port=<port>[-<port>]/<protocol>
  1. firewall-cmd [--zone=<zone>] --query-port=<port>[-<port>]/<protocol>
  1. firewall-cmd [--permanent] [--zone=<zone>] --query-port=<port>[-<port>]/<protocol>

查看已开放的端口

  1. firewall-cmd --zone=public --list-ports

2、启用端口

success:执行成功

warning:警告xxx

  1. firewall-cmd --add-port=<port>[-<port>]/<protocol>
  1. firewall-cmd [--zone=<zone>] --add-port=<port>[-<port>]/<protocol> [--timeout=<seconds>]
  1. firewall-cmd [--permanent] [--zone=<zone>] --add-port=<port>[-<port>]/<protocol>

3、禁用端口 

success:执行成功

warning:警告xxx

  1. firewall-cmd --remove-port=<port>[-<port>]/<protocol>
  1. firewall-cmd [--zone=<zone>] --remove-port=<port>[-<port>]/<protocol>
  1. firewall-cmd [--permanent] [--zone=<zone>] --remove-port=<port>[-<port>]/<protocol>

4、防火墙重启

--reload:不改变状态的条件下重启防火墙

--complete-reload:状态信息将会丢失,当防火墙有问题时可以使用,如,状态信息和防火墙规则都正常却无法建立任何链接的情况等

  1. firewall-cmd --reload
  2. firewall-cmd --complete-reload
  1. 例子

6、查看防火墙状态

命令1:firewall-cmd --state

命令2:systemctl status firewalld

7、查看、打开、关闭应急模式

(应急模式阻断所有网络连接,防止出现紧急状况)

  1. firewall-cmd --query-panic

  1. firewall-cmd --panic-on

firewall-cmd --panic-off

8、打开、关闭、重启防火墙 

  1. systemctl stop firewalld
  2. systemctl start firewalld
  3. systemctl restart firewalld

 9、开启/关闭 开机自启动防火墙

  1. systemctl enable firewalld
  2. systemctl disable firewalld
  3.  
  4. 查询防火墙服务是否开机启动:
    systemctl is-enabled firewalld

10、其他操作

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
查看区域信息:  firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=网卡名称

查询已经启动的服务列表:systemctl list-unit-files|grep enabled
 

查询启动失败的服务列表:systemctl --failed

 
 
  1.  
  1.  

Linux CentOS 7 防火墙与端口设置操作的更多相关文章

  1. 物理机连接虚拟机中的数据库及Windows添加防火墙允许端口详细操作步骤

    公司项目中因为会使用到SQL server数据库,但是自己电脑无论安装2008R2或者2014版本都不成功,我想可能是和之前安装的一些Windows的软件存在冲突. 于是便单独创建了一台虚拟机,在虚拟 ...

  2. CentOS 7 防火墙和端口配置

    centos 7 防火墙和端口配置--解决 RHEL 7/ CentOS 7/Fedora 出现Unit iptables.service failed to load # 第一步,关闭firewal ...

  3. Linux CentOS中防火墙的关闭及开启端口

    注:CentOS7之前用来管理防火墙的工具是iptable,7之后使用的是Firewall 样例:在CentOS7上安装tomcat后,在linux本机上可以访问tomcat主页,http://ip: ...

  4. centos7 防火墙与端口设置、linux端口范围

    防火墙 启动防火墙: systemctl start firewalld 查看防火墙状态: systemctl status firewalld 关闭防火墙: systemctl stop firew ...

  5. CentOS 7防火墙开放端口快速方法

    这篇文章主要为大家详细介绍了Centos7.1防火墙开放端口的快速方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下   例如安装Nagios后,要开放5666端口与服务器连接,命令如下: [ro ...

  6. linux CentOS中文输入法安装及设置

    摘自百度空间,不错,一次搞定! centos 6.3用yum安装中文输入法 1.需要root权限,所以要用root登录 ,或su root 2.yum install "@Chinese S ...

  7. Linux CentOS 7 防火墙/端口设置

    CentOS升级到7之后用firewall代替了iptables来设置Linux端口, 下面是具体的设置方法: []:选填 <>:必填 [<zone>]:作用域(block.d ...

  8. Linux CentOS 7 防火墙/端口设置【转发】

    CentOS升级到7之后用firewall代替了iptables来设置Linux端口, 下面是具体的设置方法: []:选填 <>:必填 [<zone>]:作用域(block.d ...

  9. linux防火墙与端口设置

    1.编辑iptables文件 # sudo vi /etc/sysconfig/iptables 添加如下一行 -A INPUT -p tcp -m state --state NEW -m tcp ...

随机推荐

  1. 远程访问禅道开源版数据库(基于docker)

    navicat访问基于docker搭建的禅道的数据库,报错”2003 can't connect to MySQL server on '' (10061 'unknown error')“ 一.开启 ...

  2. 【POJ - 3262】Protecting the Flowers(贪心)

    Protecting the Flowers 直接中文 Descriptions FJ去砍树,然后和平时一样留了 N (2 ≤ N ≤ 100,000)头牛吃草.当他回来的时候,他发现奶牛们正在津津有 ...

  3. 今天发现一个Window系统服务增删改查神器:NSSM

    官网地址:https://nssm.cc Win10系统下这个:https://nssm.cc/ci/nssm-2.24-101-g897c7ad.zip 官方的帮助,英语的,可以大概看一下: htt ...

  4. Linux中权限控制ACL命令

    很多小伙伴觉得,Linux的权限管理命令不就是chown和chmod命令吗,什么时候有了ACL了? 什么是ACLACL是访问控制列表(Access Control List)的缩写,主要的目的是在提供 ...

  5. Sentence Screen Fitting

    Given a rows x cols screen and a sentence represented by a list of words, find how many times the gi ...

  6. DOS ftp

    C:\>ftp /? 将文件传送到运行 FTP 服务器服务(经常称为后台程序)的计算机以及将文件从该计算机传出.可以交互使用 Ftp. FTP [-v] [-d] [-i] [-n] [-g] ...

  7. PAT A1002 A+B for Polynomials(25)

    AC代码 转载自https://www.cnblogs.com/zjutJY/p/9413766.html #include <stdio.h> #include<string.h& ...

  8. PAT B1020 月饼(25)

    题目描述 月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼.现给定所有种类月饼的库存量.总售价.以及市场的最大需求量,请你计算可以获得的最大收益是多少. 注意:销售时允许取出一部 ...

  9. Python链表操作(实现)

    Python链表操作 在Python开发的面试中,我们经常会遇到关于链表操作的问题.链表作为一个非常经典的无序列表结构,也是一个开发工程师必须掌握的数据结构之一.在本文中,我将针对链表本身的数据结构特 ...

  10. MyBatis学习存档(1)——入门

    一.简介 MyBatis的前身是iBatis,本是Apache的一个开源的项目 MyBatis是一个数据持久层(ORM)框架,把实体类和SQL语句之间建立了映射关系,是一种半自动化的ORM实现 MyB ...