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 --reload

1、检查端口状态

yes:已开通

no:未开通

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

查看已开放的端口

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

2、启用端口

success:执行成功

warning:警告xxx

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

3、禁用端口 

success:执行成功

warning:警告xxx

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

4、防火墙相关

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

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

firewall-cmd --reload
firewall-cmd --complete-reload

查看防火墙状态

firewall-cmd --state

查看、打开、关闭应急模式(应急模式阻断所有网络连接,防止出现紧急状况)

firewall-cmd --query-panic
firewall-cmd --panic-on
firewall-cmd --panic-off

打开、关闭、重启防火墙

systemctl stop firewalld
systemctl start firewalld
systemctl restart firewalld

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

systemctl enable firewalld
systemctl disable firewalld

原文:https://www.cnblogs.com/taiyonghai/p/5825578.html

Linux CentOS 7 防火墙/端口设置【转发】的更多相关文章

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

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

  2. Linux 7.x 防火墙&端口

    Linux 7.x 防火墙&端口 查看当前防火墙的状态: # firewall-cmd --state 也可以使用指令:systemctl status firewall.service 启动 ...

  3. CentOS 7 防火墙端口配置

    CentOS 7 防火墙端口配置查看防火墙是否开启systemctl status firewalld 若没有开启则开启systemctl start firewalld 查看所有开启的端口firew ...

  4. Linux系统 开通防火墙端口

    Redhat 7内核 Linux系统  开通防火墙端口 使用systemctl 1.查看防火墙状态,root用户登录,执行命令systemctl status firewalld 2.开启防火墙:sy ...

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

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

  6. CentOS 8.0与CentOS7.0 防火墙端口设置

    一,开放端口号 firewall-cmd --zone=public --add-port=8080/tcp --permanent  #开启8080端口 firewall-cmd --zone=pu ...

  7. Linux系统关闭防火墙端口

    1. 打开防火墙端口 # iptables -I INPUT -p tcp --dport -j ACCEPT # iptables -I INPUT -p tcp --dport -j ACCEPT ...

  8. Linux CentOS 7 防火墙与端口设置操作

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

  9. Linux 下防火墙端口设置

    方式1:     /sbin/iptables -I INPUT -p tcp --dport 8011 -j ACCEPT  #开启8011端口      /etc/rc.d/init.d/ipta ...

随机推荐

  1. Java实现 LeetCode 1013 将数组分成和相等的三个部分

    1013. 将数组分成和相等的三个部分 给你一个整数数组 A,只有可以将其划分为三个和相等的非空部分时才返回 true,否则返回 false. 形式上,如果可以找出索引 i+1 < j 且满足 ...

  2. java实现复制网站内容

    复制网站内容 复制代码 本程序将网站"www.baidu.com"首页的内容复制保存在文件test.html中.写了如下代码,请完善之: import java.net.*; im ...

  3. ntpq无法查询同步信息,显示The specified class was not found

    年初时工班发现工作站和服务器都没办法用ntpq看时钟同步了,如下图所示.输入ntpq-p 就显示"The specified class was not found" 通过排查,发 ...

  4. Hadoop之hadoop fs和hdfs dfs、hdfs fs三者区别

      适用范围 案例 备注 小记 hadoop fs 使用范围最广,对象:可任何对象       hadoop dfs 只HDFS文件系统相关       hdfs fs 只HDFS文件系统相关(包括与 ...

  5. Spring AOP学习笔记02:如何开启AOP

    上文简要总结了一些AOP的基本概念,并在此基础上叙述了Spring AOP的基本原理,并且辅以一个简单例子帮助理解.从本文开始,我们要开始深入到源码层面来一探Spring AOP魔法的原理了. 要使用 ...

  6. Android 图片裁剪踩坑

      今天做图库图片的裁剪遇到了不少坑,今天记录一下,以下坑位供各位看官参考: 如果有不对之处,欢迎各位看官留言评论! 图片裁剪踩坑锦囊: 问题一:相册裁剪权限问题 解:这个简单,对于Android6. ...

  7. 君荣 TS--8200 消费机显示说明

     Err 001——不在消费时段内Err 002——非本系统卡Err 003——余额不足Err 004——级别未开放Err 005——卡已挂失Err 006——有效期未生效Err 007——已过有效期 ...

  8. 如何在Centos7安装rabbitmq的PHP扩展

    1.先安装rabbitmq-c, wget https://github.com/alanxz/rabbitmq-c/releases/download/v0.8.0/rabbitmq-c-0.8.0 ...

  9. PHP 直接插入排序

    php数组下标从0开始,所以第一步就是数组长度加1,数组元素全部后移一位,把下标0对应值设置为哨兵.结果顺序排序完成后,删除哨兵. function insert_sort($arr) { //这里可 ...

  10. pip速度过慢解决方法

    国内源: 新版ubuntu要求使用https源,要注意. 清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.c ...