5.8. inetd -/etc/inetd.conf文件

inetd,也称为超级服务器,会根据来自网络的请求加载网络程序。inetd.conf文件告诉 inetd 监听哪些端口,以及为每个端口启动哪个服务器。

将 Linux 系统连接到任何网络后,首先要查看的是您需要提供的服务。 应该禁用和卸载您不需要提供的服务,这样您就少了一件需要担心的事情,攻击者也少了一个可以寻找漏洞的地方。 查看您的/etc/inetd.conf文件,查看您的 inetd 程序正在提供的服务。 通过在行首添加#来注释掉不需要的服务,然后向您的 inetd 进程发送 SIGHUP 命令以将其更新到当前的inetd.conf文件。

  1. 将此文件的权限更改为 600。
                 [root@deep] /#chmod 600  /etc/inetd.conf
                 

  2. 确保所有者是 root 用户。
                 [root@deep] /# stat /etc/inetd.conf
                 
    
                 File: "/etc/inetd.conf"
                 Size: 2869         Filetype: Regular File
                 Mode: (0600/-rw-------)         Uid: (    0/    root)  Gid: (    0/    root)
                 Device:  8,6   Inode: 18219     Links: 1    
                 Access:	Wed	Sep	22	16:24:16	1999(00000.00:10:44)
                 Modify:	Mon	Sep	20	10:22:44	1999(00002.06:12:16)
                 Change:	Mon	Sep	20	10:22:44	1999(00002.06:12:16)
                 

  3. 编辑inetd.conf文件 vi/etc/inetd.conf文件,并禁用诸如 ftp、telnet、shell、login、exec、talk、ntalk、imap、pop-2、pop-3、finger、auth 等服务,除非您计划使用它们。 如果它们被关闭,风险就会小得多。
                 # 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
                 

  4.              [root@deep] /# killall  -HUP inetd
               

  5. 您可以采取的另一项安全措施来保护inetd.conf文件是将其设置为不可变的,使用 chattr 命令。 要将文件设置为不可变,只需执行以下命令
                 [root@deep] /# chattr  +i /etc/inetd.conf
                 
    这将防止对inetd.conf文件的任何意外或其他更改。 设置了不可变属性 i 的文件无法被修改、删除或重命名,无法创建到此文件的链接,也无法向其写入数据。 唯一可以设置或清除此属性的人是超级用户 root。 如果您以后希望修改 inetd.conf 文件,您需要取消设置不可变标志:要取消设置不可变标志,只需执行以下命令
                 [root@deep] /# chattr -i /etc/inetd.conf
                 

Note: 不要忘记在更改您的killall -HUP inetd文件后,向您的 inetd 进程发送 SIGHUP 信号inetd.conf文件。 您在选定主机上启用的服务取决于您希望主机提供的功能。 功能可以支持选定的网络服务、此计算机上托管的其他服务,或操作系统和应用程序的开发和维护。