Linux CentOS 7 防火墙/端口设置【转发】
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 防火墙/端口设置【转发】的更多相关文章
- Linux CentOS 7 防火墙/端口设置
CentOS升级到7之后用firewall代替了iptables来设置Linux端口, 下面是具体的设置方法: []:选填 <>:必填 [<zone>]:作用域(block.d ...
- Linux 7.x 防火墙&端口
Linux 7.x 防火墙&端口 查看当前防火墙的状态: # firewall-cmd --state 也可以使用指令:systemctl status firewall.service 启动 ...
- CentOS 7 防火墙端口配置
CentOS 7 防火墙端口配置查看防火墙是否开启systemctl status firewalld 若没有开启则开启systemctl start firewalld 查看所有开启的端口firew ...
- Linux系统 开通防火墙端口
Redhat 7内核 Linux系统 开通防火墙端口 使用systemctl 1.查看防火墙状态,root用户登录,执行命令systemctl status firewalld 2.开启防火墙:sy ...
- Linux CentOS中防火墙的关闭及开启端口
注:CentOS7之前用来管理防火墙的工具是iptable,7之后使用的是Firewall 样例:在CentOS7上安装tomcat后,在linux本机上可以访问tomcat主页,http://ip: ...
- CentOS 8.0与CentOS7.0 防火墙端口设置
一,开放端口号 firewall-cmd --zone=public --add-port=8080/tcp --permanent #开启8080端口 firewall-cmd --zone=pu ...
- Linux系统关闭防火墙端口
1. 打开防火墙端口 # iptables -I INPUT -p tcp --dport -j ACCEPT # iptables -I INPUT -p tcp --dport -j ACCEPT ...
- Linux CentOS 7 防火墙与端口设置操作
CentOS升级到7之后用firewall代替了iptables来设置Linux端口, 下面是具体的设置方法: []:选填 <>:必填 [<zone>]:作用域(block.d ...
- Linux 下防火墙端口设置
方式1: /sbin/iptables -I INPUT -p tcp --dport 8011 -j ACCEPT #开启8011端口 /etc/rc.d/init.d/ipta ...
随机推荐
- Java实现 蓝桥杯VIP 基础练习 报时助手
题目描述 给定当前的时间,请用英文的读法将它读出来. 时间用时h和分m表示,在英文的读法中,读一个时间的方法是: 如果m为0,则将时读出来,然后加上"o'clock",如3:00读 ...
- 安装fail2ban,防止ssh爆破及cc攻击
背景:之前写过shell脚本防止服务器ssh爆破,但是对于服务器的cpu占用较多,看来下资料安装fail2ban 可以有效控制ssh爆破 1:fail2ban 安装(环境:centos6 宝塔) y ...
- netty集群(一)-服务注册发现
上篇文章介绍了如何搭建一个单机版本的netty聊天室:https://www.jianshu.com/p/f786c70eeccc. 一.需要解决什么问题: 当连接数超过单机的极限时,需要将netty ...
- [CQOI2007]矩形
题目 点这里看题目. 分析 插头 DP ,考虑枚举一下两块之间的分割线,本质上就是两个端点都在边界上的路径. DP 过程中,我们将没有端点在边界上面的路径称为 1 路径,反之叫 2 路径 ...
- ThreadLocal源码解析-Java8
目录 一.ThreadLocal介绍 1.1 ThreadLocal的功能 1.2 ThreadLocal使用示例 二.源码分析-ThreadLocal 2.1 ThreadLocal的类层级关系 2 ...
- Android学习笔记点击事件和触摸事件的区别
当我们点击手机屏幕的时候Android系统不仅会触发单击事件,还会触发触摸事件.在Android中它会先触发触摸事件,如果这个触摸事件没有被消费掉再去触发单击事件 代码示例: MainActivty. ...
- 迁移AndroidX
1. 前言 AndroidX replaces the original support library APIs with packages in the androidx namespace. O ...
- 解决mysql插入数据l出现"the table is full"的问题
需要修改Mysql的配置文件my.ini,在[mysqld]下添加/修改两行:tmp_table_size = 256Mmax_heap_table_size = 256M
- Windows 程序设计(3) 关于字符串
1. 宽窄字节的区别及重要性 1.1 宽窄字节简介: C语言/C++语言,使用的字符串指针就是 char* 类型,C++中的字符串是 string,内部也是对 char* 的封装 窄字节 其实最早的系 ...
- ImportError: cannot import name _remove_dead_weakref
出现这个错误, 和python环境有关. 电脑有多个版本造成的. python3 有这个_remove_dead_weakref python 2.7.10 并没有_remove_dead_weakr ...