一、概述
瞬态(Transient)服务被xinetd进程所管理。xinetd服务(yum install xinetd)是用SystemV脚本管理的。它监控由/etc/xinet.d/目录中的文件配置的服务所使用的端口(如你安装了telnet,并且在这里创建了配置文件,xinetd就会监听端口23)。在/etc/xinetd.conf文件中默认的或适用于全局性的设置。xinetd答复它管理的端口上的进入请求,然后调用相应的应用程序。
命令chkconfig可激活或者取消已安装的xinetd服务。然而,不像其他独立的服务(由启动脚本启动的),这些瞬态服务不为给定的运行级别配置,但决定xinetd是否来管理这些端口和到这些服务的链接。
如:
[root@patrick sbin]# chkconfig telnet off
[root@patrick sbin]# chkconfig --list telnet
telnet off
[root@patrick sbin]# chkconfig telnet on
[root@patrick sbin]# chkconfig --list telnet
telnet on
这个守护进程提供基于主机的验证、资源记录、计时访问和地址重定向等许多配置选项。这些选项可能是某个服务持有的,或者是适用于xinetd管理的所有服务。xinetd适用/etc/services文件配置对“端口到服务”的管理。
红帽企业版Linux的xinetd是用libwrap.so编译的。当服务被请求时,用libwrap.so支持编译的服务将首先调用http_access(5)规则。如果允许访问,就会检查xinetd的内部访问控制策略。
二、全局配置文件
xinetd的全局配置文件是/etc/xinetd.conf,它设置所有被管理的服务所共享的全局配置选项,它也提供到服务特有配置的路径。
includedir /etc/xinetd.d
三、配置telnet服务的实例
step 1:安装telnet服务端程序
[root@patrick etc]yum install telnet*
...
[root@patrick etc] rpm -qa | grep telnet
telnet-0.17-39.el5
telnet-server-0.17-39.el5
step 2:在/etc/xinetd.d/ 下创建配置文件telnet。
[root@patrick xinetd.d]# cat telnet
# default: on
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
重启xinetd服务:service xinetd restart。
step 3: 配置防火墙信任端口23
[root@patrick xinetd.d] system-config-securitylevel
四、xinetd的访问控制
xinetd访问控制可用几个指令来实施,如only_from和no_access。对于某个服务,如果这两个指令都没有指定,说明所有主机都允许访问该服务。如果两者都被指定,将采用“更匹配”的远程主机地址指令。
[root@patrick xinetd.d]# cat telnet
# default: on
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
no_access = 192.168.54.0/24 # 只有192.168.54.0/24网段的机器能访问该服务
}