Modify: Mon Sep 20 10:22:44 1999(00002.06:12:16)
Change: Mon Sep 20 10:22:44 1999(00002.06:12:16)
第三步:编辑inetd.conf文档(vi /etc/inetd.conf),禁止任何无需的服务,如:ftp、 telnet、 shell、 login、 exec、talk、ntalk、 imap、 pop-2、pop-3、finger、auth,等等。假如您觉得某些服务有用,能够不禁止这些服务。但是,把这些服务禁止掉,系统受攻击的可能性就会小很多。改变后的inetd.conf文档的内容如下面所示:
# To re-read this file after changes, just do a 'killall -HUP inetd'
#
#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
#time stream tcp nowait root internal
#time dgram udp wait root internal
#
# These are standard services.
#
#ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
#telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd
#
# Shell, login, exec, comsat and talk are BSD protocols.
#
#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
#comsat dgram udp wait root /usr/sbin/tcpd in.comsat
#talk dgram udp wait root /usr/sbin/tcpd in.talkd
#ntalk dgram udp wait root /usr/sbin/tcpd in.ntalkd
#dtalk stream tcp wait nobody /usr/sbin/tcpd in.dtalkd
#
# Pop and imap mail services et al
#
#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 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 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 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
#
# Authentication
#
#auth stream tcp nowait nobody /usr/sbin/in.identd in.identd -l -e -o
#
# End of inetd.conf
注意:改变了inetd.conf文档之后,别忘了给inetd进程发一个SIGHUP信号(killall -HUP inetd)。
[root@deep /root]# killall -HUP inetd
第四步:
为了确保“inetd.conf”文档的安全,能够用chattr命令把他设成不可改变。把文档设成不可改变的只要用下面的命令:
[root@deep]# chattr i /etc/inetd.conf
这样能够避免“inetd.conf”文档的任何改变(意外或是别的原因)。一个有“i”属性的文档是不能被改变的:不能删除或重命名,不能创建这个文档的连接,不能往这个文档里写数据。只有系统管理员才能配置和清除这个属性。假如要改变inetd.conf文档,您必须先清除这个不允许改变的标志:
[root@deep]# chattr -i /etc/inetd.conf
12. TCP_WRAPPERS
在默认情况下,RedHat Linux允许任何的服务请求。用TCP_WRAPPERS来保护服务器的安全,使其免受外部的攻击,比想象的要简单和轻松得多。在“/etc/hosts.deny”文档中加入“ALL: ALL@ALL, PARANOID”以禁止任何电脑访问您的服务器,然后在“/etc/hosts.allow”文档中一个一个加入允许访问您的服务器的电脑。这种作法是最安全的。
TCP_WRAPPERS是由两个文档控制的,依次是:/etc/hosts.allow和/etc/hosts.deny。判断是依次进行的,具体的规则如下:
* 假如在在/etc/hosts.allow文档中有匹配的项(daemon, client),那么允许访问;
* 否则,查看/etc/hosts.deny,假如找到匹配的项,那么访问被禁止;
* 否则,访问被允许。
第一步:编辑hosts.deny文档(vi /etc/hosts.deny)加入下面这些行:
Access is denied by default.
# Deny access to everyone.
ALL: ALL@ALL, PARANOID #Matches any host whose name does not match its address, see bellow.
这样做的意思是:任何的服务、访问位置,假如没有被明确地允许,也就是在/etc/hosts.allow中很难找到匹配的项,就是被禁止的。
注意:加上“PARANOID”参数之后,假如要在服务器上使用telnet或ftp服务,就要在服务器的“/etc/hosts”文档中加入允许使用telnet和ftp服务的客户端电脑的名字和IP地址。否则,在显示登录提示之前,因为DNS的域名解析,可能要等上几分钟时间。
第二步:编辑hosts.allow文档(vi /etc/hosts.allow)。例如,能够加入下面这些行(被授权访问的电脑要被明确地列出来):
sshd: 208.164.186.1 gate.openarch.com
被授权访问的电脑的IP地址是:208.164.186.1,主机名是:gate.openarch.com,允许使用的服务是:sshd。
第三步:tcpdchk是检查TCP_WAPPERS配置的程式。他检查TCP_WAPPERS的配置,并报告他能够发现的问题或潜在的问题。在任何的配置都完成了之后,请运行tcpdchk程式:
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




