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

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类:

2008-03-21 15:04:18


Configuring TCP Wrappers on UnixWare 7 and OpenServer 5

1.        Tcp Wapper基础知识介绍 
Tcp_Wapper是在 Solaris, HP_UX,SCO UNIX以及 Linux中广泛流行的免费软件。它被设计为一个介于外来服务请求和系统服务回应的中间处理软件。最常见的用法是与inetd一起使用。当Inetd接收到一个外来服务请求的时候,并不是直接调用,而是调用TCP Wrapper(可执行文件tcpd),TCP Wrapper根据这个所请求的服务和针对这个服务所定制的存取控制规则来判断对方是否有使用这个服务的权限,如果有,TCP Wrapper将该请求按照配置文件定义的规则转交给相应的守护进程去处理同时记录这个请求动作,然后自己就等待下一个请求的处理。 
  TCP Wrapper机制的主要目的在于,来自客户端的请求只被允许同一个独立的守护进程(xinetd)直接通信,而它请求的目标服务被TCP Wrapper包裹起来,这样就提高了系统的安全性和系统管理的方便性。Tcp wrapper随着应用逐渐成为一种标准的Unix安全工具,成为unix守护程序inetd的一个插件。通过Tcp wrapper,管理员可以设置对inetd提供的各种服务进行监控和过滤,以保证系统的安全性。



2.        Installing TCP Wrappers
UnixWare7.1.1后的版本TCP Wrappers已经集成到系统中,不需要单独安装,配置即可.
TCP Wrappers on OpenServer 5 systems
a.  获取 TCP Wrapper package for OpenServer 5 systems from:

        http://ftp.porcupine.org/pub/security/tcp_wrappers_7.6.tar.gz        

b.       因为OSR5下的TCP Wrappers是原程序代码.故OSR5 系统必须安装开发环境才能完成编译,安装步骤不做具体描述了.

c.        拷贝原文件到本地路经.解压缩
#gunzip tcp_wrappers_7.6.tar.gz
#tar xvf tcp_wrappers_7.6.tar
编译源程序
make REAL_DAEMON_DIR=/etc sco-os5

d.        拷贝生成命令到系统/etc目录
#cp tcpd /etc/tcpd   tcpd是所有internet服务的主要访问控制守护进程
#cp tcpdchk /etc/tcpdchk   一个检查 tcpd wrapper 设置和提供错误信息
#cp tcpdmatch /etc/tcpdmatch   用来预知 tcp wrapper 如何控制一个服务的特殊请求
注意:还有其它命令可用,这里不一一列举.具体可上网查询.



3.       Configuring TCP Wrappers
(1) On the OpenServer 5 system
   a. 配置inetd网络守护进程
     inetd.conf是inetd守护进程的配置文件。inetd.conf文件告诉inetd守护进程监听哪些网络端口,为每个端口启动哪个服务。如果我们要想将telnet、ftp 交由tcpd管控,需要修改/etc/inetd.conf。
     would be changed to:
     #ftp    stream  tcp     nowait  root    /etc/ftpd       ftpd –a     (修改前)
      ftp    stream  tcp     nowait  root    /etc/tcpd       ftpd –a      (修改后)
      #telnet  stream  tcp     nowait  NOLUID  /etc/telnetd    telnetd     (修改前)
      telnet  stream  tcp     nowait  NOLUID  /etc/tcpd       telnetd     (修改后)
   修改后重新启动网络守护进程。
       kill -HUP $(cat /etc/inetd.pid)
  b.  配置访问控制
    /etc/hosts.allow    定义计算机允许的访问
     /etc/hosts.deny     定义指定应该拒绝的连接 
注意:如果某个系统同时出现在两个文件里,hosts.allow是优先的。另外,如果运行最严格的TCP Wrappers安全,用户可以在/etc/hosts.deny文件力包含一行“ALL:ALL”,它会禁止所有由TCP Wrappers处理的输入访问。然后用户就可以在/etc/hosts.allow里为特定客户程序打开服务程序的端口。 
/etc/hosts.allow和/etc/hosts.deny的格式是完全一样的,当然同样的项目在两个文件中具有相反的作用。这些项目的基本格式是: 
Service-names :client-list [:shell-command] 
我们这里只测试管理telnetd和ftpd两个服务进程,请看如下两个文件:
  # vi /etc/hosts.allow
  telnetd:202.96.1.140 202.96.5.129:allow
  ftpd:202.96.5. EXCEPT 202.96.5.140 202.96.5.129:allow
注:telnetd行告诉TCP wrappers接受来自于202.96.5.140和202.96.5.129机器的telnet连接.
     ftpd行告诉TCP wrappers接受来自于202.96.5网段中除202.96.5.140和202.96.5.129之外的所有计算机的FTP连接.
  #vi /etc/hosts.deny
  telnetd:all:deny
  ftpd:all:deny
注:禁止所有telnet、ftp未经TCP Wrappers处理的访问
(2)  On the UnixWare7 system
   a. UW7系统已经配置好了TCP Wrappers,我们不需要在配置/etc/inet/inetd.conf.
    b. 配置访问控制
       /etc/inet/hosts.allow    定义计算机允许的访问
       /etc/inet/hosts.deny     定义指定应该拒绝的连接
     文件格式与OSR5相同
     Service-names :client-list [:shell-command] 
     我们这里只测试管理telnetd和ftpd两个服务进程,请看如下两个文件:
       #vi /etc/inet/hosts.allow
        in.telnetd:202.96.5.140 202.96.5.129.allow
        in.ftpd: 202.96.5. EXCEPT 202.96.5.140 202.96.5.129:allow
       #vi /etc/inet/hosts.deny
        in.telnetd:all:deny
        in.ftpd:all:deny
      注:写法内容同OpenServer 5.


4.        Testing TCP Wrapper configurations
  a. On the OpenServer 5 system
   # /etc/tcpdchk -v

Using network configuration file: /etc/inetd.conf

>>> Rule /etc/hosts.allow line 1:

daemons:  telnetd

clients:  202.96.5.140 202.96.5.129

command: allow

access:   granted



>>> Rule /etc/hosts.allow line 2:

daemons:  ftpd

clients:  202.96.5. EXCEPT 202.96.5.140 202.96.5.129

command: allow

access:   granted



>>> Rule /etc/hosts.deny line 1:

daemons:  telnetd

clients:  all

command: deny

access:   denied



>>> Rule /etc/hosts.deny line 2:

daemons:  ftpd

clients:  all

command: deny

access:   denied

# /etc/tcpdmatch telnetd 202.96.5.140

client:   address  202.96.5.140

server:   process  telnetd

matched:  /etc/hosts.allow line 1

command: allow

access:   granted

# /etc/tcpdmatch ftpd 202.96.5.129

client:   address  202.96.5.129

server:   process  ftpd

matched:  /etc/hosts.deny line 2

command: deny

access:   denied   
  
     b. On the UnixWare 7 system 
       # /usr/sbin/tcpdchk -v

Using network configuration file: /etc/inet/inetd.conf



>>> Rule /etc/inet/hosts.allow line 46:

daemons:  in.telnetd

clients:  202.96.5.140 202.96.5.129

option:   allow

access:   granted



>>> Rule /etc/inet/hosts.allow line 47:

daemons:  in.ftpd

clients:  202.96.5. EXCEPT 202.96.5.140 202.96.5.129

option:   allow

access:   granted



>>> Rule /etc/inet/hosts.deny line 46:

daemons:  in.telnetd

clients:  all

option:   deny

access:   denied



>>> Rule /etc/inet/hosts.deny line 47:

daemons:  in.ftpd

clients:  all

option:   deny

access:   denied 

# /usr/sbin/tcpdmatch in.telnetd 202.96.5.140

client:   address  202.96.5.140

server:   process  in.telnetd

matched:  /etc/inet/hosts.allow line 46

option:   allow

access:   granted



# /usr/sbin/tcpdmatch in.ftpd 202.96.5.129

client:   address  202.96.5.129

server:   process  in.ftpd

matched:  /etc/inet/hosts.deny line 47

option:   deny

access:   denied
         

5.     上面介绍只是TCP Wrapper一些简单功能,它还提供有许多其它特性。
如果想有更强大的功能可参考TCP Wrappers官方网站。



6.    已测试通过的系统

      Openserver 5.0.6   5.0.7

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