Linux TCP Wrappers

CentOS-Logo

Linux中,许多网络服务针对客户机提供访问控制机制,而TCP Wrappers是应用服务与网络之间的一道特殊的防线,提供额外的安全保障。


测试环境

名称 IP地址
host01 192.168.28.128
host02 192.168.28.129
host03 192.168.28.130

配置文件

[root@host01 ~]# ls /etc/hosts.*
/etc/hosts.allow  /etc/hosts.deny

编辑配置文件

[root@host01 ~]# vim /etc/hosts.allow
sshd:192.168.28.129
[root@host01 ~]# vim /etc/hosts.deny
sshd:192.168.28.129
sshd:192.168.28.130

结果测试

  • 可以从129登录
[root@host02 ~]# ssh root@192.168.28.128
root@192.168.28.128's password: 
Last login: Tue Sep 17 02:23:49 2019 from 192.168.28.129
[root@host01 ~]# logout
Connection to 192.168.28.128 closed.
  • 不可从130登录
[root@host03 ~]# ssh root@192.168.28.128
ssh_exchange_identification: read: Connection reset by peer

访问基本原则

1.首先检查/etc/hosts.allow文件,匹配到策略,则允许访问。
2.否则检查/etc/hosts.deny文件,匹配到策略,则拒绝访问。
3.若是都找不到相匹配的策略,则默认允许访问。

原文地址:https://www.cnblogs.com/llife/p/11632903.html