博客
关于我
linux防火墙查看状态firewall、iptable
阅读量:150 次
发布时间:2019-02-28

本文共 1544 字,大约阅读时间需要 5 分钟。

CentOS7 防火墙配置指南

CentOS7 的防火墙配置与之前版本存在显著差异,主要使用 firewall 替代了之前的 iptables。以下将详细介绍 CentOS7 下的防火墙配置方法。


一、iptables 防火墙

1. iptables 基本操作

查看防火墙状态

service iptables status

停止防火墙

service iptables stop

启动防火墙

service iptables start

重启防火墙

service iptables restart

####永久关闭防火墙

chkconfig iptables off

永久关闭后重启

chkconfig iptables on

2. 开启 80 端口

打开防火墙配置文件

vim /etc/sysconfig/iptables

添加 80 端口规则

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

保存并重启防火墙

service iptables restart

二、firewall 防火墙

1. 查看 firewall 服务状态

systemctl status firewalld
  • 状态显示为 active (running) 则表示 firewall 服务已启动。
  • 状态显示为 inactive (dead) 则表示 firewall 服务已停止。

2. 查看 firewall 状态

firewall-cmd --state

3. 操作 firewall 服务

启动 firewall 服务

service firewalld start

重启 firewall 服务

service firewalld restart

关闭 firewall 服务

service firewalld stop

永久关闭 firewall 服务

systemctl disable firewalld

4. 查看防火墙规则

firewall-cmd --list-all

5. 端口管理

查询端口状态

firewall-cmd --query-port=8080/tcp

打开 80 端口

firewall-cmd --permanent --add-port=80/tcp

移除 8080 端口

firewall-cmd --permanent --remove-port=8080/tcp

重启防火墙

firewall-cmd --reload

3. firewall 常用命令参数说明

  • --permanent:表示设置为持久有效。
  • --add-port:用于添加指定端口。
  • --remove-port:用于移除指定端口。
  • --query-port:用于查询指定端口状态。

4. 切换防火墙类型

1. 关闭 firewall 并使用 iptables

systemctl stop firewalldsystemctl disable firewalld

2. 安装 iptables 服务

yum install iptables-services

3. 修改防火墙配置文件

vim /etc/sysconfig/iptables

添加常用端口(如 80、8080、3306 等)

-A INPUT -m state --state NEW -m tcp -p tcp --dport [端口号] -j ACCEPT

保存并重启防火墙

systemctl restart iptables.service

5. 防火墙开机启动设置

systemctl enable iptables.service

转载地址:http://knyj.baihongyu.com/

你可能感兴趣的文章
Mac book pro打开docker出现The data couldn’t be read because it is missing
查看>>
MAC M1大数据0-1成神篇-25 hadoop高可用搭建
查看>>
mac mysql 进程_Mac平台下启动MySQL到完全终止MySQL----终端八步走
查看>>
Mac OS 12.0.1 如何安装柯美287打印机驱动,刷卡打印
查看>>
MangoDB4.0版本的安装与配置
查看>>
Manjaro 24.1 “Xahea” 发布!具有 KDE Plasma 6.1.5、GNOME 46 和最新的内核增强功能
查看>>
mapping文件目录生成修改
查看>>
MapReduce程序依赖的jar包
查看>>
mariadb multi-source replication(mariadb多主复制)
查看>>
MariaDB的简单使用
查看>>
MaterialForm对tab页进行隐藏
查看>>
Member var and Static var.
查看>>
memcached高速缓存学习笔记001---memcached介绍和安装以及基本使用
查看>>
memcached高速缓存学习笔记003---利用JAVA程序操作memcached crud操作
查看>>
Memcached:Node.js 高性能缓存解决方案
查看>>
memcache、redis原理对比
查看>>
memset初始化高维数组为-1/0
查看>>
Metasploit CGI网关接口渗透测试实战
查看>>
Metasploit Web服务器渗透测试实战
查看>>
MFC模态对话框和非模态对话框
查看>>