Centos 的防火墙(firewalld,iptables)
Centos系统防火墙介绍
概述:
1.Filewalld(动态防火墙)作为redhat7系统中变更对于netfilter内核模块的管理工具;
2.iptables service 管理防火墙规则的模式(静态):用户将新的防火墙规则添加进 /etc/sysconfig/iptables 配置文件当中,再执行命令 /etc/init.d/iptables reload 使变更的规则生效。在这整个过程的背后,iptables service 首先对旧的防火墙规则进行了清空,然后重新完整地加载所有新的防火墙规则,如果加载了防火墙的模块,需要在重新加载后进行手动加载防火墙的模块;
3.firewalld 管理防火墙规则的模式(动态):任何规则的变更都不需要对整个防火墙规则列表进行重新加载,只需要将变更部分保存并更新到运行中的 iptables 即可;还有命令行和图形界面配置工具,它仅仅是替代了 iptables service 部分,其底层还是使用 iptables 作为防火墙规则管理入口。

Centos7以前的系统版本默认使用iptables服务来管理防火墙,Centos7系统及以后使用firewalld服务替代了iptables服务,但是依然可以使用iptables来管理内核的netfilter。其实iptables服务和firewalld服务都不是真正的防火墙,只是用来定义防火墙规则功能的管理工具,将定义好的规则交由内核中的netfilter(网络过滤器来读取)从而实现真正的防火墙功能。
参考:https://blog.csdn.net/xiazichenxi/article/details/80169927
FireWalld服务
介绍:
- 工具名称:firewalld
- firewalld的服务名称:firewalld
- firewalld的操作工具:firewall-cmd
使用:
1.安装firewalld:
yum -y install firewalld
#需要安装图形化界面时,安装firewalld-config
yum -y install firewalld-config
2.配置开机启动:
#开机启动
systemctl enable firewalld
#禁止启动
systemctl disable firewalld
3.启动firewalld:
#启动firewalld
systemctl start firewalld
#停止firewalld
systemctl stop firewalld
#重启firewalld
systemctl restart firewalld
4.配置文件
#直接修改配置文件
/lib/firewalld/ 用于默认和备用配置
/etc/firewalld/ 用于用户创建和自定义配置文件 覆盖默认配置
/etc/firewalld/firewall.conf 全局配置
Firewall-Cmd常用命令
#帮助命令
firewall-cmd --version 查看firewalld版本
firewall-cmd --help 查看firewall-cmd用法
man firewall-cmd #查看状态
firewall-cmd --state #查看firewalld的状态
systemctl status firewalld #查看firewalld的状态,详细
firewall-cmd --reload 重新载入防火墙配置,当前连接不中断
firewall-cmd --complete-reload 重新载入防火墙配置,当前连接中断 #添加服务或者端口
firewall-cmd --get-services 列出所有预设服务
firewall-cmd --list-services 列出当前服务
firewall-cmd --permanent --zone=public --add-service=smtp 启用服务
firewall-cmd --permanent --zone=public --remove-service=smtp 禁用服务
firewall-cmd --zone=public --list-ports
firewall-cmd --permanent --zone=public --add-port=8080/tcp 启用端口, --permanent 表示永久有效的配置, --zone表示配置的是公共区域
firewall-cmd --permanent --zone=public --remove-port=8080/tcp 禁用端口
运行时配置和永久配置
firewall-cmd –zone=public –add-service=smtp 运行时配置,重启后失效
firewall-cmd –permanent –zone=public –add-service=smtp 永久配置,不影响当前连接,重启后生效
firewall-cmd –runtime-to-permanent 将运行时配置保存为永久配置 #区域命令
firewall-cmd --get-zones 查看所有可用区域
firewall-cmd --get-active-zones 查看当前活动的区域,并附带一个目前分配给它们的接口列表
firewall-cmd --list-all-zones 列出所有区域的所有配置
firewall-cmd --zone=work --list-all 列出指定域的所有配置
firewall-cmd --get-default-zone 查看默认区域
firewall-cmd --set-default-zone=public 设定默认区域
Iptables服务
如果想使用iptables配置防火墙规则,要先安装iptables并禁用firewalld
1.安装iptables
yum install iptables-services 2.配置文件路径:
/etc/sysconfig/iptables 3.查看防火墙开启的端口详情列表:
iptables -vnL 4.重启iptables
service iptables restart
#重启防火墙使配置文件生效
systemctl restart iptables.service 5.关闭iptables
service iptables stop
systemctl stop iptables.service 6.设置iptables防火墙为开机启动项
systemctl enable iptables.service
systemctl disable iptables.service
开机启动方式:
vi /etc/rc.local
添加命令: iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 7.添加开放端口
配置文件[/etc/sysconfig/iptables]开启端口:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
添加80和3306端口
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT 动态命令开启端口:
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
Centos 的防火墙(firewalld,iptables)的更多相关文章
- Centos 7防火墙firewalld开放80端口(转)
开启80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent 出现success表明添加成功 命令含义: --zone #作用域 -- ...
- Linux Centos 开启防火墙 FirewallD is not running
转载自:http://www.z4zr.com/page/1006.html CentOS7用firewall命令“替代”了iptables.在这里我们需要区分“iptables服务”和“iptabl ...
- 腾讯云服务器CentOS 7防火墙firewalld管理
在腾讯云上买了个服务器(centOS7),部署了Tomcat(8080),Apache(80),MySQL(3306)等,一开始按照百度教程配置是把防火墙关闭了的.最近一段时间服务器总是莫名的被人修改 ...
- Linux centos修改防火墙为iptables
防火墙配置 CentOS 7默认使用的是firewall作为防火墙,这里改为iptables防火墙. firewall操作: # service firewalld status; #查看防火墙状态 ...
- (9)centos下防火墙firewalld设置
学习apache安装的时候需要打开80端口,由于centos 7版本以后默认使用firewalld后,网上关于iptables的设置方法已经不管用了,想着反正iptable也不会用,索性直接搬官方文档 ...
- Centos 7 防火墙firewalld命令
今天自己在Hyper-v下搭建三台Linux服务器集群,用于学习ELKstack(即大数据日志解决技术栈Elasticsearch,Logstash,Kibana的简称),下载的Linux版本为cen ...
- Centos 7防火墙firewalld开放80端口
开启80端口 1.firewall-cmd --zone=public --add-port=80/tcp --permanent 出现success表明添加成功 命令含义: --zone #作用域 ...
- Centos 7 防火墙 firewalld 简单使用说明
1.firewalld简介 firewalld是centos7的一大特性,最大的好处有两个:支持动态更新,不用重启服务:第二个就是加入了防火墙的“zone”概念 2.firewalld命令行界面管 ...
- Centos 7防火墙firewalld开放端口
firewall-cmd --zone=/tcp --permanent 出现success表明添加成功 命令含义:--zone #作用域--add-port=80/tcp #添加端口,格式为:端口/ ...
随机推荐
- iOS模拟器Custom Location被重置解决方案
转自王中周的技术博客 问题说明 在做地图类应用时,经常需要用到位置模拟功能.iOS模拟器提供了该功能,我们可以设置指定的经纬度,选中模拟器后,按照以下菜单层次进入即可设置: Debug --> ...
- 项目一、ajax上传数据(显示进度条)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 【l转】VS2015下解决:无法解析的外部符号 __imp___vsnprintf 及__iob_func
https://blog.csdn.net/hebbely/article/details/53780562
- 关于【C++项目:无法解析的外部符号】
1,基本原因,[链接器]->[附加库目录]没有填写相关库的路径.或没有在[链接器]->[输入]->[附加依赖项]中填写相关库的名称 2,高级原因:如果不是1的原因,那就有可能是平台与 ...
- Linux驱动开发6——DDR内存分配
1.kmalloc和kfree #include <linux/slab.h> void *kmalloc(size_t size, int flags); flag: GFP_ATOMI ...
- UEFI手札
基于Intel TianoCore衍生的EDK-II诞生的UEFI,用来取代Legacy BIOS. INF文件 Module Information File,模块描述文件.Module可以是可执行 ...
- c# 用DotNetZip来解压/压缩文件
//https://archive.codeplex.com/?p=dotnetzip //最新在Nuget 下载DotNetZip using Ionic.Zip; private void but ...
- 在window 10查看一下指定命令行工具所在的位置
很久之前安装过node,现在想要给node升级,通过where命令查看一下node的安装位置
- Prometheus Alertmanager Grafana 监控警报
Prometheus Alertmanager Grafana 监控警报 #node-exporter, Linux系统信息采集组件 #prometheus , 抓取.储存监控数据,供查询指标 #al ...
- django amdin后台改成中文