Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101947637
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-05-05 17:00:23

 
 

TCP_Wrappers是工作起来如同TCP守护进程的安全工具。它们能够为systat、finger、FTP、telnet、rlogin、rsh、exec、tftp、talk及其它网络服务监视和过滤进入的请求。

TCP_Wrappers有一个TCP的守护进程叫tcpd。以telnet为例,每当有telnet的连接请求时,tcpd即会截获请求,先读取系统管理员所设置的访问控制文件,合乎要求,则会把这次连接原封不动的转给真正的telnet进程,由telnet完成后续工作;如果这次连接发起的ip不符合访问控制文件中的设置,则会中断连接请求,拒绝提供telnet服务。

TCP_Wrappers的主要配置文件为:/etc/hosts.allow和/etc/hosts.deny。

[root@ts3-142 ~]# cat /etc/hosts.allow 
#
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#

/usr/sbin/tcpd进程首先检查此文件,如果请求访问的主机名或IP包含在此文件中,则允许访问。

[root@ts3-142 ~]# cat /etc/hosts.deny 
#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!

如果请求访问的主机名或IP不包含在/etc/hosts.allow中,那么tcpd进程就检查/etc/hosts.deny。看请求访问的主机名或IP有没有包含在hosts.deny文件中。如果包含,那么访问就被拒绝;如果既不包含在/etc/hosts.allow中,又不包含在/etc/hosts.deny中,那么此访问也被允许。

访问控制需要加在/etc/hosts.allow和/etc/hosts.deny里,规则格式如下:

:[:

[root@ts3-142 ~]# cat /etc/hosts.allow 
#
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
in.telnetd:.turbolinux.com.cn
vsftpd:192.168.0.
sshd:192.168.0.0/255.255.255.0
[root@ts3-142 ~]# cat /etc/hosts.deny 
#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!
ALL:ALL

/etc/hosts.deny里的ALL:ALL表示,除非在/etc/hosts.allow里明确允许访问,否则一律拒绝。
/etc/hosts.allow里第一行in.telnetd:.turbolinux.com.cn表示,只有turbolinux.com.cn这个域里的主机允许访问TELNET服务,注意turbolinux.com.cn前面的那个点(.)。
/etc/hosts.allow里第二行表示,只有192.168.0这个网段的用户允许访问FTP服务,注意0后面的点(.)。
/etc/hosts.allow里第三行表示,只有192.168.0这个网段的用户允许访问SSH服务,注意这里不能写为192.168.0.0/24。虽然在CISCO路由器种这两中写法是等同的。
更多规则格式请参考TCP_Wrappers的MAN PAGE。

阅读(872) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~