CentOS8.5系统访问限制

2 篇文章 0 订阅
2 篇文章 0 订阅

CentOS8.5 访问限制

CentOS7.x 使用的是hosts.allow和hosts.deny文件进行限制,到CentOS8.x已弃用hosts.allow和hosts.deny文件,可使用sshd_config文件和firewalld防火墙规则限制。

一、使用sshd_config进行限制

# 在/etc/ssh/sshd_config文件中添加限制
AllowUsers root@192.168.10.0/24
DenyUsers root@192.168.10.2

allow/deny按照一定顺序生效:
DenyUsers-->AllowUsers-->DenyGroups-->AllowGroups

二、使用firewalld防火墙规则进行限制

1、限制IP地址访问
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.10.0/24" port protocol="tcp" port="80" reject"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.10.0/24" port protocol="tcp" port="80" accept"
firewall-cmd --reload
firewall-cmd --zone=public --list-rich-rules
2、解除限制IP地址访问
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.10.0/24" port protocol="tcp" port="80" reject"
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.10.0/24" port protocol="tcp" port="80" accept"
firewall-cmd --reload
firewall-cmd --zone=public --list-rich-rules
3、限制端口访问
firewall-cmd --permanent --zone=public --add-port=100-500/tcp
firewall-cmd --permanent --zone=public --add-port=22/tcp
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
4、接触限制端口访问
firewall-cmd --permanent --zone=public --remove-port=100-500/tcp
firewall-cmd --permanent --zone=public --remove-port=22/tcp
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值