firewalld系列一:自定义zone与ipset
目录
自定义zone
自定义ipset
案例一:centos8源地址访问限制
案例二:(留个小尾巴,后面会接续介绍firewalld预定义zone的作用)
开篇先讲一下写本文的由来:了解/etc/hosts.allow和/etc/hosts.deny的同学肯定知道,这是用来做源地址访问控制的两个配置文件。实质上,是由TCP_Wrappers实现的安全访问控制;凡是包含有libwrap.so库文件的程序就会受TCP_Wrappers的安全控制。所以,这也是它的局限性。更甚,CentOS8已经舍弃了TCP_Wrappers(tcp_wrappers-libs包),即便我们手动进行安装,也不会生效;原因就是CentOS8自带的ssh等软件不再集成libwrap.so库。
那么,没有了TCP_Wrappers怎么做源地址访问控制呢?答案是通过系统自带防火墙,无论iptables还是firewalld都能做到(见案例一)。当然,一些软件本身也自带了访问控制功能(比如:ssh的Match指令)
注:TCP_Wrappers是一个工作在网络传输层的安全工具,它对有状态连接的特定服务进行安全检测并实现访问控制。
自定义zone
# 添加/删除zone
firewall-cmd --new-zone=mysshzone --permanent
firewall-cmd --delete-zone=mysshzone --permanent
# 查询所有zone列表
firewall-cmd --get-zones
block dmz drop external home internal mysshzone public trusted work
# 显示生效的zone
firewall-cmd --get-active-zone
mysshzonesources: 192.168.186.103 192.168.10.182 ipset:4mysshzone
publicinterfaces: ens192
trustedsources: 192.168.10.124
## 查看zone信息
firewall-cmd --info-zone=mysshzone
### 上面命令效果同:
firewall-cmd --zone=mysshzone --list-all
# 查看所有zone的详细配置
firewall-cmd --list-all-zones
## zone添加/删除源地址
firewall-cmd --permanent --zone=mysshzone --add-source=192.168.186.103
firewall-cmd --permanent --zone=mysshzone --remove-source=192.168.186.103
## zone绑定/解绑ipset
firewall-cmd --permanent --zone=mysshzone --add-source=ipset:4mysshzone
firewall-cmd --permanent --zone=mysshzone --remove-source=ipset:4mysshzone
自定义ipset
## 查看ipset列表
firewall-cmd --permanent --get-ipsets
4mysshzone
## 查看ipset详细信息
firewall-cmd --permanent --info-ipset=4mysshzone
4mysshzonetype: hash:ipoptions: entries: 192.168.186.125
## 查看ipset配置文件存放路径
firewall-cmd --permanent --path-ipset=4mysshzone
/etc/firewalld/ipsets/4mysshzone.xml
### 查看ipset XML文件
cat /etc/firewalld/ipsets/4mysshzone.xml
<?xml version="1.0" encoding="utf-8"?>
<ipset type="hash:ip"><entry>192.168.186.125</entry>
</ipset>
## 删除ipset
firewall-cmd --delete-ipset=4mysshzone --permanent
## 创建ipset
firewall-cmd --new-ipset=4mysshzone --type=hash:ip --permanent
## ipset添加/删除entry
firewall-cmd --permanent --ipset=4mysshzone --add-entry=192.168.186.125
firewall-cmd --permanent --ipset=4mysshzone --remove-entry=192.168.186.125
firewall-cmd --permanent --ipset=4mysshzone --add-entry=192.168.186.1/24 #type: hash:ip可以加网段
## 获取所有ipset的entry
firewall-cmd --permanent --ipset=4mysshzone --get-entries
192.168.186.125
192.168.186.1/24
## 验证某IP是否在该ipset的entry中,并不会匹配网段范围
firewall-cmd --permanent --ipset=4mysshzone --query-entry=192.168.186.125
yes
### 不能匹配到192.168.186.1/24
firewall-cmd --permanent --ipset=4mysshzone --query-entry=192.168.186.12
no## 查看所有ipset类型
firewall-cmd --get-ipset-types
hash:ip hash:ip,mark hash:ip,port hash:ip,port,ip hash:ip,port,net hash:mac hash:net hash:net,iface hash:net,net hash:net,port hash:net,port,net
案例一:centos8源地址访问限制
# 安全加固
firewall-cmd --new-zone=mysshzone --permanent
firewall-cmd --delete-zone=mysshzone --permanent
## 语法: --add-source=source[/mask]|MAC|ipset:ipset
firewall-cmd --permanent --zone=mysshzone --add-source=192.168.186.103
firewall-cmd --permanent --zone=mysshzone --add-port=22/tcp
firewall-cmd --reload
案例二:(留个小尾巴,后面会接续介绍firewalld预定义zone的作用)
# 避免管理客户端被关在防火墙之外,设置白名单
firewall-cmd --permanent --zone=trusted --add-source=192.168.10.124
firewall-cmd --reload
firewalld系列一:自定义zone与ipset相关推荐
- Linux日常运维管理技巧(三)iptables规则备份和恢复、firewalld的9个zone、任务计划cron、chkconfig系统服务管理、添加服务命令、systemctl管理服务
目录 Linux防火墙-netfilter iptables规则备份和恢复 Linux防火墙-firewalled firewalld的9个zone firewalld关于zone的操作 firewa ...
- iptables规则备份和恢复、firewalld的9个zone、firewalld关于zone和service操作
2019独角兽企业重金招聘Python工程师标准>>> 保存和备份iptables规则 service iptables save //会把规则保存到/etc/sysconfig/i ...
- firewalld的9个zone、firewalld关于zone和service的操作
firewalld的9个zone centos7 默认的防火墙工具为firewalld 打开firewalld [root@localhost ~]# systemctl disable iptabl ...
- iptables规则备份恢复,firewalld的9个zone
2019独角兽企业重金招聘Python工程师标准>>> 10月29日任务 10.19 iptables规则备份和恢复 10.20 firewalld的9个zone 10.21 fir ...
- Firewalld的区域(zone)
Firewalld 的区域(zone) 概述 区域(zone)是针对特定位置或场景(例如家庭.公共.受信任等)可能具有的各种信任级别的规则集. 不同的区域(zone)可允许不同的网络服务和入站流量的类 ...
- SharePoint 2013 图文开发系列之自定义字段
原文:SharePoint 2013 图文开发系列之自定义字段 SharePoint使用的优势,就在于开箱即用.快速搭建,SharePoint自身为我们提供了很多字段类型,已经很丰富了.但是,在实际应 ...
- RNN 循环神经网络系列 5: 自定义单元
原文地址:RECURRENT NEURAL NETWORK (RNN) – PART 5: CUSTOM CELLS 原文作者:GokuMohandas 译文出自:掘金翻译计划 本文永久链接:gith ...
- SpringBoot 2.0 系列003 -- 自定义Parent
为什么80%的码农都做不了架构师?>>> SpringBoot 2.0 系列003 --自定义Parent 默认我们使用SpringBoot的方式是通过SB的parent项目的 ...
- 信创办公–基于WPS的PPT最佳实践系列 (自定义版式)
信创办公–基于WPS的PPT最佳实践系列 (自定义版式) 目录 应用背景 相关知识 操作步骤 应用背景 在PPT幻灯片当中,拥有11种版式,我们可以在任何一个页面当中单击鼠标右键,选中[版式]功能即可 ...
- Vue 进阶系列丨自定义指令实现按钮权限功能
Vue 进阶系列教程将在本号持续发布,一起查漏补缺学个痛快!若您有遇到其它相关问题,非常欢迎在评论中留言讨论,达到帮助更多人的目的.若感本文对您有所帮助请点个赞吧! 2013年7月28日,尤雨溪第一次 ...
最新文章
- 刻骨铭心的startActivityForResult三级跳获得第三个Activity中返回的数据
- python下载不了-python安装不了
- 推荐系统算法-Apriori
- 引用和指针的差别,数组和指针的差别
- RK3288_Android7.1写一个GPIO驱动控制LED灯亮灭
- c#过滤字符串中相同的字符串只保留一个
- Qt + 运动控制 (固高运动控制卡)【1】环境准备,框架搭建
- mysql更改数据库密码
- 信号与频谱之正弦信号和复信号
- 保龄球计分程序java_保龄球计分——java代码实现
- java项目-第150期ssm网络视频播放器-java毕业设计_计算机毕业设计
- RDD优化--RDD共享变量(广播变量与累加器)
- ACM-ICPC 2021 亚洲区域赛 昆明站
- office 文档 在线查看
- js实现搜索框智能搜索提示,类似百度搜索
- 股票自选股基本函数大全-5
- 非对称加密 公钥解密_了解非对称公钥加密
- itss认证费用多少钱
- 出自ios深入浅出专栏(内购)
- nmake编译libraw
热门文章
- 实现简易植物大战僵尸修改器的历程(2)
- Win32多语言IME开发概述
- 个人小程序/京东推广链接/长链接/短连接/跳转到京东购物小程序
- 总结一些pr的快捷键,让你的剪辑速度翻倍~
- 2021SC@SDUSC Zxing开源代码(八)Data Matrix二维码(一)
- 亚马逊为证券市场树立标杆 拆股已不再受追捧
- latex 符号以及命令
- ios 隔空投安装ipa_iOS App 在线安装 .IPA文件
- 项目中碰见的错误(三) 对路径的访问被拒绝
- 计算机描绘的基因结构图,傻瓜式图文教程:Genecards基因信息检索与分析、基因结构图绘制.........