教你搭建一个安全的Linux服务器(2)

http://www.itjxue.com  2015-07-17 01:30  来源:未知  点击次数: 

  */etc/host.conf文件:

  该文件指定如何解析主机名。Linux通过解析器库来获得主机名对应的IP地址。下面是一个“/etc/host.conf”的示例:

  order bind,hosts

  multi on

  ospoof on

  “order bind,hosts”指定主机名查询顺序,这里规定先使用DNS来解析域名,然后再查询“/etc/hosts”文件(也可以相反)。

  “multi on”指定是否“/etc/hosts”文件中指定的主机可以有多个地址,拥有多个IP地址的主机一般称为多穴主机。

  “nospoof on”指不允许对该服务器进行IP地址欺骗。IP欺骗是一种攻击系统安全的手段,通过把IP地址伪装成别的计算器,来取得其它计算器的信任。

  */etc/sysconfig/network文件

  该文件用来指定服务器上的网络配置信息,下面是一个示例:

  NETWORK=yesRORWARD_IPV4=yesHOSTNAME=deep.openarch.comGAREWAY=0.0.0.0GATEWAYDEV=NETWORK=yes/no 网络是否被配置;FORWARD_IPV4=yes/no 是否开启IP转发功能HOSTNAME=hostname hostname表示服务器的主机名GAREWAY=gw-ip gw-ip表示网络网关的IP地址GAREWAYDEV=gw-dev gw-dw表示网关的设备名,如:etho等

  注意:为了和老的软件相兼容,“/etc/HOSTNAME”文件应该用和HOSTNAME=hostname相同的主机名。

  */etc/hosts文件

  当机器激活时,在可以查询DNS以前,机器需要查询一些主机名到IP地址的匹配。这些匹配信息存放在/etc/hosts文件中。在没有域名服务器情况下,系统上的所有网络程序都通过查询该文件来解析对应于某个主机名的IP地址。

  下面是一个“/etc/hosts”文件的示例:

  IP Address Hostname Alias127.0.0.1 Localhost Gate.openarch.com208.164.186.1 gate.openarch.com Gate

  最左边一列是主机IP信息,中间一列是主机名。任何后面的列都是该主机的别名。一旦配置完机器的网络配置文件,应该重新激活网络以使修改生效。使用下面的命令来重新激活网络:/etc/rc.d/init.d/network restart

  * /etc/inetd.conf文件

  众所周知,作为服务器来说,服务端口开放越多,系统安全稳定性越难以保证。所以提供特定服务的服务器应该尽可能开放提供服务必不可少的端口,而将与服务器服务无关的服务关闭,比如:一台作为www和Ftp服务器的机器,应该只开放80 和25端口,而将其它无关的服务如:finger auth等服务关掉,以减少系统漏洞。

  而inetd,也叫作“超级服务器”,就是监视一些网络请求的守护进程,其根据网络请求来调用相应的服务进程来处理连接请求。inetd.conf则是inetd的配置文件。inetd.conf文件告诉inetd监听哪些网络端口,为每个端口激活哪个服务。在任何的网络环境中使用Linux系统,第一件要做的事就是了解一下服务器到底要提供哪些服务。不需要的那些服务应该被禁止掉,最好卸载掉,这样黑客就少了一些攻击系统的机会。查看“/etc/inetd.conf”文件,了解一下inetd提供哪些服务。用加上注释的方法(在一行的开头加上#号),禁止任何不需要的服务,再给inetd进程发一个SIGHUP信号。

  第一步:把文件的权限限改成600。

  [root@deep]# chmod 600 /etc/inetd.conf

  第二步:确信文件的所有者是root。

  [root@deep]# stat /etc/inetd.conf

  第三步:编辑“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.#共2页。

(责任编辑:IT教学网)

更多

推荐linux服务器文章