发信人: cent.bbs@bbs.cst.sh.cn (forcent), 信区: cnlinux
标  题: Firewall HOWTO 6
发信站: 生命玄机站 (Tue Jul  7 06:33:57 1998)
转信站: Lilac!ustcnews!cstshnews!lifebbs


发信人: tjb (老六), 信区: Linux
标  题: Firewall HOWTO 6
发信站: BBS 水木清华站 (Tue Jul  7 20:22:12 1998)

<a href="http://202.200.37.100">tjb.ml.org</a>

防火墙和代理伺服器 - HOWTO : 安装TIS代理伺服器
Previous: IP filtering 的设置(IPFWADM)
Next: SOCKS代理伺服器
  ------------------------------------------------------------------------

7. 安装TIS代理伺服器

7.1. 取得软件

TIS FWTK软件可从下列网址得到∶ftp://ftp.tis.com/. 千万记住∶从TIS下载软件
後,首先阅读README。TIS fwtk存放在伺服器的一个隐藏目录内,需要发电子邮件给
fwtk-request@tis.com 并在信文内填入SEND才能得知隐藏的目录的名字。Subject栏内
不必填入任何内容。在回覆的电子邮件内会告知存放软件的目录的名字,有效时间为12
小时,得赶快下载。 在编写本文时,FWTK的最新版本为2.0(beta)。除了几个小地方
之外,这个版本在编辑时没有问题,运行时也正常,此处就以这一版本为例。如有最後
定本时,将在以後的HOWTO中增订。 安装FWTK时,首先在 /usr/src下建立fwtk-2.0目
录。将FWTK(fwtk-2.0.tar.gz)放在这个目录内解压(tar zxf fwtk-2.0.tar.gz)。
FWTK并无代理SSL的网路文件,Jean-Christophe Touvet写了一些附加资料,可从
ftp://ftp.edelweb.fr/pub/contrib/fwtk/ssl-gw.tar.Z取得。 Eric Wedel写了修订
本,其中包括使用网景(Netscape)的新闻伺服器。这套软件可从下列网址取得∶
ftp://mdi.meridian-data.com/pub/tis.fwtk/ssl-gw/ssl-gw2.tar.Z 以下以Eric
Wedel的版本为例。 要安装,只要在/usr/src/fwtk-2.0目录内建立一个 ssl-gw目录,
把文档放在其中即可。 在安装这个网关时,得要作些改动才能进行编辑。 首先改变
ssl-gw.c档,其中遗漏了必要的include档。

  #if defined(__linux)
  #include        <sys/ioctl.h>
  #endif

其次,也没有Makefile档。不妨从其他网关目录拷贝一个,然後将网关的名字改为
ssl-gw。

7.2. 编辑TIS FWTK
版本2.0的FWTK比以往任何一个版本都易于编辑。不过在编辑以前还需要对BETA版本作
一些更动。希望这些更动会加附到最後定本中。 修改方法如下∶首先进入
/usr/src/fwtk/fwtk目录,拷贝Makefile.config.linux档,以此档替代
Makefile.config档。 不要运行FIXMAKE。虽然在说明中建议执行这个程序。但运行後
会破坏每一个目录中的makefile。 修改fixmake的方法是在每一个Makefile的sed指令
的include行中添加‘.’和"。按下例更改,便可运行无碍。

  sed 's/^include[        ]*\([^  ].*\)/include \1/' $name .proto > $name

然後需要编辑Makefile.config档,但首先得作两项修改。 Makefile.config档中的
source目录应改为进行编辑的/usr/src,因此FWTKSRCDIR应作相应的改变。

  FWTKSRCDIR=/usr/src/fwtk/fwtk

有些Linux系统使用gdbm数据库。Makefile.config使用dbm。例如,RedHat 3.0.3就使
用dbm,因此需要作出相应更动。

  DBMLIB=-lgdbm

最後需要改x-gw。BETA版内socket.c中的下列数行必需删除。
  #ifdef SCM_RIGHTS  /* 4.3BSD Reno and later */
                       + sizeof(un_name->sun_len) + 1
  #endif

如在FWTK源目录中添加ssl-gw,则在Makefile的目录单中也要加上ssl-gw。

  DIRS=   smap smapd netacl plug-gw ftp-gw tn-gw rlogin-gw http-gw x-gw ssl-gw

完成上述修改後,运行make。

7.3. 安装TIS FWTK

运行make install。 默认的安装目录是/usr/local/etc。可以改到更加安全可靠的目
录进行安装,但也可以不改,也可将其特权改为chmod 700。 现在开始设定防火墙。

7.4. 设置TIS FWTK

好!下面就比较有趣了!设定的系统要能调用这些新功能,并建立管制表管理这些功
能。 以下的说明并不是为了要重写TIS FWTK的使用手册,其目的只是为了显示可行的
设定、可能遇到的问题和解决的办法。 有三个文档组成这些controls。
   * /etc/services
        o 告诉系统所定功能在何埠号

   * /etc/inetd.conf
        o 当服务埠有动作时告诉inetd启动那个程式

   * /usr/local/etc/netperm-table
        o 告诉FWTK同意和拒绝来往的用户

要FWTK发挥作用,应彻底编辑这些档案。编辑这些功能档而不正确设定 inetd.conf或
netperm-table,可能使系统完全无法作用。

7.4.1. netperm-table档

这个档控制何人可以使用TIS FWTK的功能。首先应该想到防火墙两边的需求。网路外面
的用户在进入网路之前应首先表明身份,但网路内部的用户则可直接通过。 在表明身
份时,防火墙使用一个称为authsrv的程式,其中存有用户的ID和密码。netperm-table
中的authentication部分控制这一数据库存放何处和谁可取用。 要不让人取用这一功
能并不容易,在premit-hosts这一行中使用“*”,以致每人都能取用这一功能。这一
行的正确设定应该是“authsrv: premit-hosts localhost”,但似乎不起作用。
  #
  # Proxy configuration table:  代理伺服器设置表
  #
  # Authentication server and client rules
  authsrv:      database /usr/local/etc/fw-authdb
  authsrv:      permit-hosts *
  authsrv:      badsleep 1200
  authsrv:      nobogus true
  # Client Applications using the Authentication server
  *:            authserver 127.0.0.1 114

要启动数据库,以root在/var/local/etc内运行./authsrv,设立管理者的使用记录。
实际操作如下∶ 阅读FWTK文档了解如何添加用户和用户组。

    #
    # authsrv
    authsrv# list
    authsrv# adduser admin "Auth DB admin"
    ok - user added initially disabled
    authsrv# ena admin
    enabled    authsrv# proto admin pass
    changed
    authsrv# pass admin "plugh"
    Password changed.
    authsrv# superwiz admin
    set wizard
    authsrv# list
    Report for users in database
    user   group  longname           ok?    proto   last
    ------ ------ ------------------ -----  ------  -----
    admin         Auth DB admin      ena    passw   never
    authsrv# display admin
    Report for user admin (Auth DB admin)
    Authentication protocol: password
    Flags: WIZARD
    authsrv# ^D
    EOT
    #

Telnet的网关(tn-gw)控制直接了当,应首先设定。 例如,允许在保护网路内的用户
不表明身份直接通过(permit-hosts 196.1.2.* -passok)。但其他用户必需提供用户ID和密码才可使用代理伺服器(permit-hosts * -auth)。 此外,有一个系统
(196.1.2.202)也可直接使用防火墙。这只要设定inetacl-in.telnetd的内容即可。
Telnet的timeout时间应该短暂。

  # telnet gateway rules:
  tn-gw:                denial-msg      /usr/local/etc/tn-deny.txt
  tn-gw:                welcome-msg     /usr/local/etc/tn-welcome.txt
  tn-gw:                help-msg        /usr/local/etc/tn-help.txt
  tn-gw:                timeout 90
  tn-gw:                permit-hosts 196.1.2.* -passok -xok
  tn-gw:                permit-hosts * -auth
  # Only the Administrator can telnet directly to the Firewall via Port 24
  netacl-in.telnetd: permit-hosts 196.1.2.202 -exec /usr/sbin/in.telnetd

r-command如同telnet的同一方式设定。

  # rlogin gateway rules:
  rlogin-gw:    denial-msg      /usr/local/etc/rlogin-deny.txt
  rlogin-gw:    welcome-msg     /usr/local/etc/rlogin-welcome.txt
  rlogin-gw:    help-msg        /usr/local/etc/rlogin-help.txt
  rlogin-gw:    timeout 90  rlogin-gw:    permit-hosts 196.1.2.* -passok -xok
  rlogin-gw:    permit-hosts * -auth -xok
  # Only the Administrator can telnet directly to the Firewall via Port
  netacl-rlogind: permit-hosts 196.1.2.202 -exec /usr/libexec/rlogind -a

任何人均不得直接进入防火墙,其中包括FTP,因此,不要把FTP伺服器放在防火墙上。
再者,permit-hosts行允许保护网路内的任何人自由进入网际网路,其他人则必需表明
身份。下文附上送到和收到的每份文档的记录(-log { retr stor })。 FTP的
timeout开关控制在多少时间後停止试接,以及在多少时间没有动作後,放弃试接。

  # ftp gateway rules:
  ftp-gw:               denial-msg      /usr/local/etc/ftp-deny.txt
  ftp-gw:               welcome-msg     /usr/local/etc/ftp-welcome.txt
  ftp-gw:               help-msg        /usr/local/etc/ftp-help.txt
  ftp-gw:               timeout 300
  ftp-gw:               permit-hosts 196.1.2.* -log { retr stor }
  ftp-gw:               permit-hosts * -authall -log { retr stor }

通过WWW、gopher和浏览器进行的ftp由http-gw控制。最上面的两行建立一个目录,用
于储存经由防火墙的ftp和WWW文件。在本例中,这些文件属root所有,因此放在只有
root能够进入的目录内。 WWW的连接应该短暂。它控制使用者在连接不通时的等待时间。

  # www and gopher gateway rules:
  http-gw:      userid          root
  http-gw:      directory       /jail
  http-gw:      timeout 90
  http-gw:      default-httpd   www.afs.net
  http-gw:      hosts           196.1.2.* -log { read write ftp }
  http-gw:      deny-hosts      *

ssl-gw实际上是一个任何人都可通过的网关。应当当心设定。在本例中,任何保护网路
中的用户,除127.0.0.* 和192.1.1.* 外,均可连接网路外的任何伺服器,并只能使用
443至563 埠号。443至563埠号一般称为SSL埠号。

  # ssl gateway rules:
  ssl-gw:   timeout 300
  ssl-gw:   hosts           196.1.2.* -dest { !127.0.0.* !192.1.1.* *:443:563 }
  ssl-gw:   deny-hosts      *

下面的例子说明如何利用plug-gw连接到新闻伺服器。在本例中,保护网路内的用户只
允许连接到一个系统,即连接到它的新闻埠。 第二行使新闻伺服器将其资料送到保护网路。 对新闻伺服器的timeout时间设定应该比较长,因为多数用户大都联机阅读新
闻。


  # NetNews Pluged gateway
  plug-gw:        timeout 3600
  plug-gw: port nntp 196.1.2.* -plug-to 199.5.175.22 -port nntp
  plug-gw: port nntp 199.5.175.22 -plug-to 196.1.2.* -port nntp

Finger网关的设定至为简单。保护网路内的用户只要首先登录,就可使用防火墙上的
finger程式。任何其他人就只收到一段message。

  # Enable finger service --------设定finger功能
  netacl-fingerd: permit-hosts 196.1.2.* -exec /usr/libexec/fingerd
  netacl-fingerd: permit-hosts * -exec /bin/cat /usr/local/etc/finger.txt

在这份HOWTO中,没有设定Mail和X-windows功能。如任何人有这方面的实例,请发
email给我。

7.4.2. inetd.conf的设置档
下面附上/etc/inetd.conf的全部文档。所有不需要的功能都用#符号注销。在这份全部
文档中显示取消了何种功能,以及显示如何设定新的防火墙功能。


  #echo stream  tcp  nowait  root               internal
  #echo dgram   udp  wait    root       internal
  #discard              stream  tcp  nowait  root       internal
  #discard              dgram   udp  wait    root       internal
  #daytime              stream  tcp  nowait  root       internal
  #daytime              dgram   udp  wait    root       internal
  #chargen              stream  tcp  nowait  root       internal
  #chargen              dgram   udp  wait    root       internal
  # FTP firewall gateway --------FTP防火墙网关
  ftp-gw      stream  tcp  nowait.400  root  /usr/local/etc/ftp-gw  ftp-gw
  # Telnet firewall gateway------Telnet防火墙网关
  telnet        stream  tcp  nowait      root  /usr/local/etc/tn-gw /usr/local/etc/tn-gw
  # local telnet services------用户的telnet功能
  telnet-a    stream  tcp  nowait      root  /usr/local/etc/netacl in.telnetd
  # Gopher firewall gateway------Gopher防火墙网关
  gopher        stream  tcp  nowait.400  root  /usr/local/etc/http-gw /usr/local/etc/http-gw
  # WWW firewall gateway------WWW防火墙网关
  http  stream  tcp  nowait.400  root  /usr/local/etc/http-gw /usr/local/etc/http-gw
  # SSL firewall gateway------SSL防火墙网关
  ssl-gw  stream  tcp     nowait  root /usr/local/etc/ssl-gw   ssl-gw
  # NetNews firewall proxy (using plug-gw)------NetNews防火墙代理伺服器(使用plug-gw)
  nntp    stream  tcp     nowait  root    /usr/local/etc/plug-gw plug-gw nntp
  #nntp stream  tcp     nowait  root    /usr/sbin/tcpd  in.nntpd
  # SMTP (email) firewall gateway------SMTP(email)防火墙网关
  #smtp stream  tcp     nowait  root    /usr/local/etc/smap smap
  #
  # Shell, login, exec and talk are BSD protocols------ Shell, login, exec and talk均属BSD协议
  #
  #shell        stream  tcp     nowait  root    /usr/sbin/tcpd  in.rshd
  #login        stream  tcp     nowait  root    /usr/sbin/tcpd  in.rlogind
  #exec stream  tcp     nowait  root    /usr/sbin/tcpd  in.rexecd
  #talk dgram   udp     wait    root    /usr/sbin/tcpd  in.talkd
  #ntalk        dgram   udp     wait    root    /usr/sbin/tcpd  in.ntalkd
  #dtalk        stream  tcp     waut    nobody  /usr/sbin/tcpd  in.dtalkd
  #
  # Pop and imap mail services et al------Pop和imap mail功能
  #
  #pop-2   stream  tcp  nowait  root  /usr/sbin/tcpd    ipop2d
  #pop-3   stream  tcp  nowait  root  /usr/sbin/tcpd    ipop3d
  #imap    stream  tcp  nowait  root  /usr/sbin/tcpd    imapd
  #
  # The Internet UUCP service------网际网路UUCP功能
  #
  #uucp    stream  tcp  nowait  uucp  /usr/sbin/tcpd  /usr/lib/uucp/uucico -l
  #
  # Tftp service is provided primarily for booting.  Most sites
  # run this only on machines acting as "boot servers." Do not uncomment
  # this unless you *need* it.  ----- Tftp功能主要用于启动。一般只有作为"boot
  #伺服器"时才需要tftp。因此,不要取消注销(#)符号。
  #
  #tftp dgram   udp     wait    root    /usr/sbin/tcpd  in.tftpd
  #bootps       dgram   udp     wait    root    /usr/sbin/tcpd  bootpd
  #
  # Finger, systat and netstat give out user information which may be
  # valuable to potential "system crackers."  Many sites choose to disable
  # some or all of these services to improve security.------ Finger,
  # systat and netstat会向骇客提供可贵的资料。许多网站取消一些或全部功能,以增安全。
  #
  # cfinger is for GNU finger, which is currently not in use in RHS Linux
  # cfinger是GNU finger,目前在RHS Linux中并不使用。
  #  finger        stream  tcp  nowait  root   /usr/sbin/tcpd  in.fingerd
  #cfinger      stream  tcp  nowait  root   /usr/sbin/tcpd  in.cfingerd
  #systat       stream  tcp  nowait  guest  /usr/sbin/tcpd  /bin/ps -auwwx
  #netstat      stream  tcp  nowait  guest  /usr/sbin/tcpd  /bin/netstat -f inet
  #
  # Time service is used for clock syncronization.-----时间功能用于设定时间的同步。  
  #
  #time stream  tcp  nowait  root  /usr/sbin/tcpd  in.timed
  #time dgram   udp  wait    root  /usr/sbin/tcpd  in.timed
  #
  # Authentication-----查验用户身份
  #
  auth          stream  tcp  wait    root  /usr/sbin/tcpd  in.identd -w -t120
  authsrv       stream  tcp  nowait  root  /usr/local/etc/authsrv authsrv
  #  # End of inetd.conf-----inetd.cong设置档结束
7.4.3. /etc/services档

当用户连接到防火墙时,会接到一个已知的埠(小于1024)。例如,telnet接到埠23。
inetd deamon接到连接的动作,查看/etc/services上这些功能的名字。然後,它会启
动/etc/inetd.conf档中这个名字所指定的程式。 有时使用的功能并不在
/etc/services档中。这些功能可指定到任何想指定的埠。例如,管理员的telnet埠
(telnet-a)可设定到埠24,也可设定到埠2323,悉听尊便。如果管理员(指你本人)
要直接连接到防火墙,则需telnet到埠24而非埠23。如按照下例设定netperm-table,
则只能从保护的网路中的一个系统设定。
  telnet-a         24/tcp
  ftp-gw          21/tcp           # this named changed
  auth            113/tcp   ident    # User Verification
  ssl-gw           443/tcp

  ------------------------------------------------------------------------
防火墙和代理伺服器 - HOWTO : 安装TIS代理伺服器
Previous: IP filtering 的设置(IPFWADM)
Next: SOCKS代理伺服器
--
  2m                      m
  2m;36m    一壶浊酒喜相逢    4m  m
  2m;33m 古今多少事均赋笑谈中 4m  m
  2m                      4m  m
    4m                      m

m7m※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.200.37.100]m

--
QUIET UNDER PRESSURE
CALM  UNDER PRESSURE
GRACE UNDER PRESSURE

※ 来源:·生命玄机 bbs.cst.sh.cn·[FROM: 202.127.16.22]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:213.240毫秒