📄 防火墙简介.htm
字号:
DB admin) <BR>Authentication protocol: password <BR>Flags: WIZARD
<BR>authsrv# ^D <BR>EOT <BR>#
<BR>Telnet的网关(tn-gw)控制直接了当,应首先设定。例如,允许在保护网路内的用户不表明身份直接通过(permit-hosts
196.1.2.* -passok)。但其他用户必需提供用户ID和密码才可使用代理伺服器(permit-hosts *
-auth)。此外,有一个系统(196.1.2.202)也可直接使用防火墙。这只要设定inetacl-in.telnetd的内容即可。
Telnet的timeout时间应该短暂。 <BR># telnet gateway rules: <BR>tn-gw: denial-msg
/usr/local/etc/tn-deny.txt <BR>tn-gw: welcome-msg
/usr/local/etc/tn-welcome.txt <BR>tn-gw: help-msg
/usr/local/etc/tn-help.txt <BR>tn-gw: timeout 90 <BR>tn-gw: permit-hosts
196.1.2.* -passok -xok <BR>tn-gw: permit-hosts * -auth <BR># Only the
Administrator can telnet directly to the Firewall via Port 24
<BR>netacl-in.telnetd: permit-hosts 196.1.2.202 -exec
/usr/sbin/in.telnetd <BR>r-command如同telnet的同一方式设定。 <BR># rlogin gateway
rules: <BR>rlogin-gw: denial-msg /usr/local/etc/rlogin-deny.txt
<BR>rlogin-gw: welcome-msg /usr/local/etc/rlogin-welcome.txt
<BR>rlogin-gw: help-msg /usr/local/etc/rlogin-help.txt <BR>rlogin-gw:
timeout 90 <BR>rlogin-gw: permit-hosts 196.1.2.* -passok -xok
<BR>rlogin-gw: permit-hosts * -auth -xok <BR># Only the Administrator
can telnet directly to the Firewall via Port <BR>netacl-rlogind:
permit-hosts 196.1.2.202 -exec /usr/libexec/rlogind -a
<BR>任何人均不得直接进入防火墙,其中包括FTP,因此,不要把FTP伺服器放在防火墙上。再者,permit-hosts行允许保护网路内的任何人自由进入网际网路,其他人则必需表明身份。下文附上送到和收到的每份文档的记录(-log
{ retr stor })。 FTP的timeout开关控制在多少时间後停止试接,以及在多少时间没有动作後,放弃试接。 <BR># ftp
gateway rules: <BR>ftp-gw: denial-msg /usr/local/etc/ftp-deny.txt
<BR>ftp-gw: welcome-msg /usr/local/etc/ftp-welcome.txt <BR>ftp-gw:
help-msg /usr/local/etc/ftp-help.txt <BR>ftp-gw: timeout 300 <BR>ftp-gw:
permit-hosts 196.1.2.* -log { retr stor } <BR>ftp-gw: permit-hosts *
-authall -log { retr stor }
<BR>通过WWW、gopher和浏览器进行的ftp由http-gw控制。最上面的两行建立一个目录,用于储存经由防火墙的ftp和WWW文件。在本例中,这些文件属root所有,因此放在只有root能够进入的目录内。
WWW的连接应该短暂。它控制使用者在连接不通时的等待时间。 <BR># www and gopher gateway rules:
<BR>http-gw: userid root <BR>http-gw: directory /jail <BR>http-gw:
timeout 90 <BR>http-gw: default-httpd <A href="http://www.afs.net/"
target=_blank>http://www.afs.net/</A> <BR>http-gw: hosts 196.1.2.* -log
{ read write ftp } <BR>http-gw: deny-hosts *
<BR>ssl-gw实际上是一个任何人都可通过的网关。应当当心设定。在本例中,任何保护网路中的用户,除127.0.0.* 和192.1.1.*
外,均可连接网路外的任何伺服器,并只能使用443至563 埠号。443至563埠号一般称为SSL埠号。 <BR># ssl gateway
rules: <BR>ssl-gw: timeout 300 <BR>ssl-gw: hosts 196.1.2.* -dest {
!127.0.0.* !192.1.1.* *:443:563 } <BR>ssl-gw: deny-hosts *
<BR>下面的例子说明如何利用plug-gw连接到新闻伺服器。在本例中,保护网路内的用户只允许连接到一个系统,即连接到它的新闻埠。第二行使新闻伺服器将其资料送到保护网路。对新闻伺服器的timeout时间设定应该比较长,因为多数用户大都联机阅读新闻。
<BR><BR># NetNews Pluged gateway <BR>plug-gw: timeout 3600 <BR>plug-gw:
port nntp 196.1.2.* -plug-to 199.5.175.22 -port nntp <BR>plug-gw: port
nntp 199.5.175.22 -plug-to 196.1.2.* -port nntp
<BR>Finger网关的设定至为简单。保护网路内的用户只要首先登录,就可使用防火墙上的finger程式。任何其他人就只收到一段message。
<BR><BR># Enable finger service --------设定finger功能 <BR>netacl-fingerd:
permit-hosts 196.1.2.* -exec /usr/libexec/fingerd <BR>netacl-fingerd:
permit-hosts * -exec /bin/cat /usr/local/etc/finger.txt
<BR>在这份HOWTO中,没有设定Mail和X-windows功能。如任何人有这方面的实例,请发email给我。
<BR><BR>inetd.conf的设置档
<BR>下面附上/etc/inetd.conf的全部文档。所有不需要的功能都用#符号注销。在这份全部文档中显示取消了何种功能,以及显示如何设定新的防火墙功能。
<BR><BR><BR>#echo stream tcp nowait root internal <BR>#echo dgram udp
wait root internal <BR>#discard stream tcp nowait root internal
<BR>#discard dgram udp wait root internal <BR>#daytime stream tcp nowait
root internal <BR>#daytime dgram udp wait root internal <BR>#chargen
stream tcp nowait root internal <BR>#chargen dgram udp wait root
internal <BR># FTP firewall gateway --------FTP防火墙网关 <BR>ftp-gw stream
tcp nowait.400 root /usr/local/etc/ftp-gw ftp-gw <BR># Telnet firewall
gateway------Telnet防火墙网关 <BR>telnet stream tcp nowait root
/usr/local/etc/tn-gw /usr/local/etc/tn-gw <BR># local telnet
services------用户的telnet功能 <BR>telnet-a stream tcp nowait root
/usr/local/etc/netacl in.telnetd <BR># Gopher firewall
gateway------Gopher防火墙网关 <BR>gopher stream tcp nowait.400 root
/usr/local/etc/http-gw /usr/local/etc/http-gw <BR># WWW firewall
gateway------WWW防火墙网关 <BR>http stream tcp nowait.400 root
/usr/local/etc/http-gw /usr/local/etc/http-gw <BR># SSL firewall
gateway------SSL防火墙网关 <BR>ssl-gw stream tcp nowait root
/usr/local/etc/ssl-gw ssl-gw <BR># NetNews firewall proxy (using
plug-gw)------NetNews防火墙代理伺服器(使用plug-gw) <BR>nntp stream tcp nowait root
/usr/local/etc/plug-gw plug-gw nntp <BR>#nntp stream tcp nowait root
/usr/sbin/tcpd in.nntpd <BR># SMTP (email) firewall
gateway------SMTP(email)防火墙网关 <BR>#smtp stream tcp nowait root
/usr/local/etc/smap smap <BR># <BR># Shell, login, exec and talk are BSD
protocols------ Shell, login, exec and talk均属BSD协议 <BR># <BR>#shell
stream tcp nowait root /usr/sbin/tcpd in.rshd <BR>#login stream tcp
nowait root /usr/sbin/tcpd in.rlogind <BR>#exec stream tcp nowait root
/usr/sbin/tcpd in.rexecd <BR>#talk dgram udp wait root /usr/sbin/tcpd
in.talkd <BR>#ntalk dgram udp wait root /usr/sbin/tcpd in.ntalkd
<BR>#dtalk stream tcp waut nobody /usr/sbin/tcpd in.dtalkd <BR># <BR>#
Pop and imap mail services et al------Pop和imap mail功能 <BR># <BR>#pop-2
stream tcp nowait root /usr/sbin/tcpd ipop2d <BR>#pop-3 stream tcp
nowait root /usr/sbin/tcpd ipop3d <BR>#imap stream tcp nowait root
/usr/sbin/tcpd imapd <BR># <BR># The Internet UUCP
service------网际网路UUCP功能 <BR># <BR>#uucp stream tcp nowait uucp
/usr/sbin/tcpd /usr/lib/uucp/uucico -l <BR># <BR># Tftp service is
provided primarily for booting. Most sites <BR># run this only on
machines acting as "boot servers." Do not uncomment <BR># this unless
you *need* it. -----
Tftp功能主要用于启动。一般只有作为"boot伺服器"时才需要tftp。因此,不要取消注销(#)符号。 <BR># <BR>#tftp
dgram udp wait root /usr/sbin/tcpd in.tftpd <BR>#bootps dgram udp wait
root /usr/sbin/tcpd bootpd <BR># <BR># Finger, systat and netstat give
out user information which may be <BR># valuable to potential "system
crackers." Many sites choose to disable <BR># some or all of these
services to improve security.------ Finger, systat and
netstat会向骇客提供可贵的资料。许多网站取消一些或全部功能,以增安全。 <BR># <BR># cfinger is for GNU
finger, which is currently not in use in RHS Linux <BR># cfinger是GNU
finger,目前在RHS Linux中并不使用。 <BR># <BR>finger stream tcp nowait root
/usr/sbin/tcpd in.fingerd <BR>#cfinger stream tcp nowait root
/usr/sbin/tcpd in.cfingerd <BR>#systat stream tcp nowait guest
/usr/sbin/tcpd /bin/ps -auwwx <BR>#netstat stream tcp nowait guest
/usr/sbin/tcpd /bin/netstat -f inet <BR># <BR># Time service is used for
clock syncronization.-----时间功能用于设定时间的同步。 <BR># <BR>#time stream tcp
nowait root /usr/sbin/tcpd in.timed <BR>#time dgram udp wait root
/usr/sbin/tcpd in.timed <BR># <BR># Authentication-----查验用户身份 <BR>#
<BR>auth stream tcp wait root /usr/sbin/tcpd in.identd -w -t120
<BR>authsrv stream tcp nowait root /usr/local/etc/authsrv authsrv <BR>#
<BR># End of inetd.conf-----inetd.cong设置档结束 <BR><BR>/etc/services档
<BR><BR>当用户连接到防火墙时,会接到一个已知的埠(小于1024)。例如,telnet接到埠23。inetd
deamon接到连接的动作,查看/etc/services上这些功能的名字。然後,它会启动/etc/inetd.conf档中这个名字所指定的程式。有时使用的功能并不在/etc/services档中。这些功能可指定到任何想指定的埠。例如,管理员的telnet埠(telnet-a)可设定到埠24,也可设定到埠2323,悉听尊便。如果管理员(指你本人)要直接连接到防火墙,则需telnet到埠24而非埠23。如按照下例设定netperm-table,则只能从保护的网路中的一个系统设定。
<BR><BR><BR><BR>telnet-a 24/tcp <BR>ftp-gw 21/tcp # this named changed
<BR>auth 113/tcp ident # User Verification <BR>ssl-gw 443/tcp
<BR><BR><BR>--------------------------------------------------------------------------------
<BR><BR>7. SOCKS代理伺服器 <BR>7.1 设定代理伺服器 <BR>SOCKS代理伺服器可从 <A
href="ftp://sunsite.unc.edu/pub/Linux/system/Network/misc/socks-linux-"
target=_blank>ftp://sunsite.unc.edu/pub/Linux/system/Network/misc/socks-linux-</A>
src.tgz取得。该档内也有一个称为"socks-conf"的设置档可作参考。可把该档解压,然後根据其中的说明使用该档。但使用时并不简单,应首先确定Makefile档正确无误。在
/etc/inetd.conf中应该增添代理伺服器。因此,应该增加以下一行。 <BR><BR>socks stream tcp nowait
nobody /usr/local/etc/sockd sockd <BR>这样伺服器才会在需要时运行。 <BR><BR>7.2 设置代理伺服器
<BR>SOCKS需要两个设置档进行设定。一个设置档设定进入取用的权限,另一个设置档设定路径,以便找到适当的代理伺服器。权限档应在伺服器上,路径档应在每一台UNIX机上。DOS机和Macintosh机都会确定自行的路径。
<BR><BR><BR>权限档
<BR>在socks4.2(beta)版中,权限档称为"sockd.conf",应该只有两行,一行允许(permit),一行拒绝(deny)。每行都有三项设定:
<BR><BR>识别标示行(permit/deny) <BR>IP地址行 <BR>修改地址行
<BR>识别标示用于permit或deny。应该有单独的permit行和单独的deny行。 IP地址使用标准的4byte方式表示,如I.E.
192.168.2.0.。修改地址行也是标准的4位元
IP地址,用来作为netmask。将这个地址想成32位元的数字。如果是1,则核对的地址的相应位置应符合IP地址中相应的位元。例如,此行的地址为∶
<BR>permit 192.168.2.23 255.255.255.255
<BR>则只允许每一位元相符的地址,即192.168.2.23。如果地址为∶ <BR><BR>permit 192.168.2.0
255.255.255.0
<BR>则会允许192.168.2.0至192.168.2.255之间的每一个地址,即整个C级的地址。不得有下列这种地址出现∶
<BR>permit 192.168.2.0 0.0.0.0
<BR>这会允许每一地址使用,不论其地址为何。因此,允许每一个应该允许的地址,然後拒绝其余地址。如允许192.168.2.xxx范围中的每一用户,可用下列方式表示∶
<BR>permit 192.168.2.0 255.255.255.0 <BR>deny 0.0.0.0 0.0.0.0
<BR>注意deny行中的第一个"0.0.0.0"。由于地址以0.0.0.0修改,因此IP为何都没有影响。用0作为IP地址,因为便于打字。
特别的用户可以给予或拒绝使用的权限。这可通过iden的查验来实现。由于不是所有系统都支持iden,其中包括Trumpet
Winsock,所以此处不预备多加说明。随同socks提供的说明以够使用。 <BR><BR>路径档
<BR>SOCKS中的路径档称为"socks.conf",极易与权限档混淆。路径档让SOCKS用户知道何时用socks,何时不用。例如,在示□的网路中192.168.2.3并不需要使用socks与192.168.2.1防火墙对话。通过Ethernet,它们之间有直接的连接。又127.0.0.1自动设为loopback。因此也不需要用socks同自己对话。它有三行输入∶
<BR><BR><BR>deny <BR>direct <BR>sockd
<BR>Deny行告诉socks何时拒绝一项请求。在此添入的内容同sockd.conf的内容相同,地址标示行、IP地址和修改地址行。一般而言,权限档sockd.conf也与此有关,修改地址部分则用0.0.0.0。如果不打算连到任何地方,在此可作出修改。
<BR>在direct行下列入不使用sock的地址。所有这些地址都可直接联上网路,无须经过代理伺服器。在这里又有三个位置要填∶identifier、address和modifier。例如∶
<BR><BR>direct 192.168.2.0 255.255.255.0 <BR>Sockd行告诉电脑那一个用户的电脑上有socks
server daemon。该行内容如下∶ <BR><BR><BR>sockd @=<SERVERLIST> <IP
address><MODIFIER><BR>注意@=
填入的内容。利用这种方法可以填入一系列代理伺服器的IP地址。在这里只用一个代理伺服器的地址为例。但可以列上多个伺服器的地址,以便加大容量,并当有伺服器失灵时,有其他的伺服器顶替。
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -