xinetd 服务简单的说就是用来管理其它远程服务的一个程序,它所管理控制的一系列远程访问服务包括 Telnet,
rsync 和 TFTP 等等。在这些服务安装完后,会在 /etc/xinetd.d 目录下生成配置文件,如:
xinetd 守护进程包含了两个级别的配置文件,第一个是设置基本参数的 /etc/xinetd.conf ,它默认指向 /etc/xinet.d 中的配置文件,除非 /etc/xinet.d 目录下的配置文件有特别指定,否则就用 /etc/xinetd.conf 中的参数设置。
xinetd.conf 文件在 CentOS 6.2 中的默认配置为:
下面解释以上一些参数的含义:
Instances :激活的 xinetd 服务器的最大数量。
log_type :指定日志参数。上面的 SYSLOG daemon info 中的 info 是 syslog 的记录等级,这类日志信息一般记录在 /var/log/messages 中。
log_on_success :指定服务启动,停止时的记录信息。上面指定了 4 个项:PID HOST DURATION EXIT 。PID 表示记录服务进程ID,如果该由 xinetd 所执行的服务并没有 fork 出新进程,那么被记录的 PID 为 0 。HOST 表示记录远程主机地址。DURATION 表示记录服务会话时期。EXIT 表示记录退出状态。
log_on_failure :指定用户请求的服务不能启动时的记录信息。
cps :调节进入连接的速率。上面后接的两个参数 50 10 分别表示,如果每秒超过 50 个连接,那么 xinetd 将被禁用 10 秒,这能缓解破解 xinetd 服务的企图。
includedir :指定目录中的每个文件作为一个 xinetd 配置文件。
only_from :指名允许服务的 IP 地址。
no_access :包含这些 IP 地址的计算机不允许访问。
access_times :指定允许访问服务的时间。比如 access_time = 09:30-23:00 表示在早上九点半到晚上11点这段时间内允许访问。
上面的参数都可以在 /etc/xinetd.d 目录中的其它配置文件中配置。
注意:/etc/xinetd.conf 文件并不会默认安装,甚至在 /etc/xinetd.d 目录下的文件也不是默认安装,需要安装 xinetd 软件包。
激活 xinetd 服务
激活 xinetd 服务有两种方法:直接编辑相应的配置文件,或用 chkconfig 命令激活。比如要激活 Kerberos 版的 Telnet 服务,那么编辑 /etc/xinetd.d 目录下的 krb5-telnet 配置文件,将参数 disable = yes 改为 disable = no 。也就是说,服务默认是禁用的。
使用 chkconfig 命令方法激活和停用服务命令分别如下:
如果是按照修改配置文件参数的方法,希望修改后生效,你可能会重新启动 Linux 以重新启动 xinetd 服务,使之重新读取 /etc/xinetd.d 下的配置文件,但重启系统是 Windows 喜欢做的事情,Linux 则不会,只要运行下面的命令即可:
上面的命令和
是等效的。
更多关于 xinetd 服务的配置参数参考 man 手册:
# ls /etc/xinetd.d/
eklogin ekrb5-telnet gssftp klogin krb5-telnet kshell rsync
xinetd 守护进程包含了两个级别的配置文件,第一个是设置基本参数的 /etc/xinetd.conf ,它默认指向 /etc/xinet.d 中的配置文件,除非 /etc/xinet.d 目录下的配置文件有特别指定,否则就用 /etc/xinetd.conf 中的参数设置。
xinetd.conf 文件在 CentOS 6.2 中的默认配置为:
#
# This is the master xinetd configuration file. Settings in the
# default section will be inherited by all service configurations
# unless explicitly overridden in the service configuration. See
# xinetd.conf in the man pages for a more detailed explanation of
# these attributes.
defaults
{
# The next two items are intended to be a quick access place to
# temporarily enable or disable services.
#
# enabled =
# disabled =
# Define general logging characteristics.
log_type = SYSLOG daemon info
log_on_failure = HOST
log_on_success = PID HOST DURATION EXIT
# Define access restriction defaults
#
# no_access =
# only_from =
# max_load = 0
cps = 50 10
instances = 50
per_source = 10
# Address and networking defaults
#
# bind =
# mdns = yes
v6only = no
# setup environmental attributes
#
# passenv =
groups = yes
umask = 002
# Generally, banners are not used. This sets up their global defaults
#
# banner =
# banner_fail =
# banner_success =
}
includedir /etc/xinetd.d
下面解释以上一些参数的含义:
Instances :激活的 xinetd 服务器的最大数量。
log_type :指定日志参数。上面的 SYSLOG daemon info 中的 info 是 syslog 的记录等级,这类日志信息一般记录在 /var/log/messages 中。
log_on_success :指定服务启动,停止时的记录信息。上面指定了 4 个项:PID HOST DURATION EXIT 。PID 表示记录服务进程ID,如果该由 xinetd 所执行的服务并没有 fork 出新进程,那么被记录的 PID 为 0 。HOST 表示记录远程主机地址。DURATION 表示记录服务会话时期。EXIT 表示记录退出状态。
log_on_failure :指定用户请求的服务不能启动时的记录信息。
cps :调节进入连接的速率。上面后接的两个参数 50 10 分别表示,如果每秒超过 50 个连接,那么 xinetd 将被禁用 10 秒,这能缓解破解 xinetd 服务的企图。
includedir :指定目录中的每个文件作为一个 xinetd 配置文件。
only_from :指名允许服务的 IP 地址。
no_access :包含这些 IP 地址的计算机不允许访问。
access_times :指定允许访问服务的时间。比如 access_time = 09:30-23:00 表示在早上九点半到晚上11点这段时间内允许访问。
上面的参数都可以在 /etc/xinetd.d 目录中的其它配置文件中配置。
注意:/etc/xinetd.conf 文件并不会默认安装,甚至在 /etc/xinetd.d 目录下的文件也不是默认安装,需要安装 xinetd 软件包。
激活 xinetd 服务
激活 xinetd 服务有两种方法:直接编辑相应的配置文件,或用 chkconfig 命令激活。比如要激活 Kerberos 版的 Telnet 服务,那么编辑 /etc/xinetd.d 目录下的 krb5-telnet 配置文件,将参数 disable = yes 改为 disable = no 。也就是说,服务默认是禁用的。
使用 chkconfig 命令方法激活和停用服务命令分别如下:
# chkconfig service_name on #激活
# chkconfig service_name off #停用
如果是按照修改配置文件参数的方法,希望修改后生效,你可能会重新启动 Linux 以重新启动 xinetd 服务,使之重新读取 /etc/xinetd.d 下的配置文件,但重启系统是 Windows 喜欢做的事情,Linux 则不会,只要运行下面的命令即可:
# service xinetd reload
上面的命令和
# /etc/init.d/xinetd reload
是等效的。
更多关于 xinetd 服务的配置参数参考 man 手册:
$ man xinetd.conf