TCP_Wrappers

TCP_Wrappers配置

这里主要涉及到两个配置文件/etc/hosts.allow和/etc/hosts.deny。/usr/sbin/tcpd进程会根据这两个文件判断是否对访问请求提供服务。
/usr/sbin/tcpd进程先检查文件/etc/hosts.allow,如果请求访问的主机名或IP包含在此文件中,则允许访问。
如果请求访问的主机名或IP不包含在/etc/hosts.allow中,那么tcpd进程就检查/etc/hosts.deny。看请求访问的主机名或IP有没有包含在hosts.deny文件中。如果包含,那么访问就被拒绝;如果既不包含在/etc/hosts.allow中,又不包含在/etc/hosts.deny中,那么此访问也被允许。

例1:
# cat /etc/hosts.allow
sshd:192.168.100.0

# cat/etc/hosts.deny
sshd:ALL

只允许192.168.100.0/24这个网段访问

例2:
# cat /etc/hosts.allow
sshd:192.168.100.0/255.255.255.0 except 192.168.100.3
# cat/etc/hosts.deny
sshd:ALL

192.168.100.0/24这个网段内除了192.168.100.3这个主机无法连接过来,其它主机都可以通过ssh协议连接进来。

例3:
# cat /etc/hosts.allow
sshd:ALL except 192.168.100.2

# cat/etc/hosts.deny

除了192.168.100.2外,允许所有主机连接。


检查某种服务是否可以通过tcp_wrappers来进行限制:
[root@rhel1 ~]# which vsftpd
/usr/sbin/vsftpd
[root@rhel1 ~]# ldd /usr/sbin/vsftpd | grep libwrap
libwrap.so.0 => /lib64/libwrap.so.0 (0x00007f6d52faf000)

比如httpd就不能通过tcp_wrappers来进行控制:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值