| 
		    
                    
   
四、禁止网络服务 
  
1、禁止inetd 服务 
  
由internet服务器过程inetd启动的网络服务是由两个配置文件/etc/inet/services和/etc/inet/inetd.conf来配置的。/etc/inet/services文件指定每个服务的端口号和端口类型,该配置文件的部分示例如下: 
… 
ftp 21/tcp 
telnet 23/tcp 
smtp 25/tcp mail 
… 
/etc/inet/inetd.conf文件指定服务对应的系统服务程序,该配置文件部分示例如下: 
… 
ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd 
telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd 
… 
当要停止某个服务,如ftp、telnet等时,只要注释掉文件/etc/inet/services和/etc/inet/inetd.conf中的相应条目,也就是在那一行的开头加上#字符,然后让inetd重新读配置文件,过程示例如下: 
# ps -ef |grep inetd 
root 149 1 0 Jan 18 ? 0:00 /usr/sbin/inetd -s 
root 24621 24605 0 15:53:01 pts/1 0:00 grep inetd 
# kill ?CHUP 149 
以上第一条命令是为了获得inetd的进程号,示例中输出的第二列内容就是进程号(149),然后将该进程号填入第二条命令的相应位置。 
可以使用lsof ?Ci来查看监听进程和端口信息: 
# lsof -i 
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 
syslogd 261 root 5u inet 0x10191e868 0t0 UDP *:syslog (Idle) 
rpcbind 345 root 4u inet 72,0x73 0t0 UDP *:portmap (Idle) 
rpcbind 345 root 6u inet 72,0x73 0t0 UDP *:49158 (Idle) 
rpcbind 345 root 7u inet 72,0x72 0t0 TCP *:portmap (LISTEN) 
sendmail: 397 root 5u inet 0x10222b668 0t0 TCP *:smtp (LISTEN) 
snmpdm 402 root 3u inet 0x10221a268 0t0 TCP *:7161 (LISTEN) 
snmpdm 402 root 5u inet 0x10222a268 0t0 UDP *:snmp (Idle) 
snmpdm 402 root 6u inet 0x10221f868 0t0 UDP *:* (Unbound) 
mib2agt 421 root 0u inet 0x10223e868 0t0 UDP *:* (Unbound) 
swagentd 453 root 6u inet 0x1019d3268 0t0 UDP *:2121 (Idle) 
  
2、禁止其他服务 
  
防止syslogd网络监听 
安装PHCO_21023补丁可以给syslogd加上-N参数防止网络监听. 编辑/sbin/init.d/syslogd修改为 /usr/sbin/syslogd -DN. 
禁止SNMP服务 
编辑SNMP启动文件: 
/etc/rc.config.d/SnmpHpunix 
Set SNMP_HPUNIX_START to 0: SNMP_HPUNIX_START=0 
/etc/rc.config.d/SnmpMaster 
Set SNMP_MASTER_START to 0: SNMP_MASTER_START=0 
/etc/rc.config.d/SnmpMib2 
Set SNMP_MIB2_START to 0: SNMP_MIB2_START=0 
/etc/rc.config.d/SnmpTrpDst 
Set SNMP_TRAPDEST_START to 0: SNMP_TRAPDEST_START=0 
禁止sendmail进程 
编辑/etc/rc.config.d/mailservs: 
export SENDMAIL_SERVER=0 
禁止rpcbind进程 
# rm /sbin/rc1.d/K600nfs.core 
# rm /sbin/rc2.d/S400nfs.core 
# mv /usr/sbin/rpcbind /usr/sbin/rpcbind.DISABLE 
  
		    
                      
		      
		      
		    |