1. defaults配置
【范例1】/etc/xinetd.conf
# Simple configuration file for xinetd
# Some defaults, and include /etc/xinetd.d/
defaults
{
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}
includedir /etc/xinetd.d
解读:RedHat 7.x建议的配置方法不是将所有服务项都写在一个文件里面,/etc/xinetd.conf是作为默认配置文件用的,/etc/xinetd.d目录下面的每个文件对应一个服务。前面说过,默认项的设置是作用于所有服务的,由此可以看出上面的对所有服务都是设置了60个实例、设置的日志方式为SYSLOG authpriv,登陆成功时记录HOST和PID,失败时仅记录HOST,
每秒最多处理25个连接,如果超过这个数目的连接则等待30秒后继续处理。Includedir指令指定了配置文件的目录是/etc/xinetd.d
【范例1】/etc/xinetd.d/telnet
# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
instances = 10
server = /usr/sbin/in.telnetd
log_on_failure += USERID
rlimit_as = 8M
rlimit_cpu=20
}
解读:
1、 instances的设置覆盖了defaults项的设置;
2、 log_on_failure属性在defaults项的基础上加上了USERID。
3、 对TELNET服务设置了资源限制,最多可用内存为8M,CPU每秒处理20个进程。
【范例3.1】/etc/xinetd.d/echo
# default: off
# description: An echo server. This is the tcp \
# version.
service echo
{
disable = yes
type = INTERNAL
id = echo-stream
socket_type = stream
protocol = tcp
user = root
wait = no
}
【范例3.2】/etc/xinetd.d/echo-udp
# default: off
# description: An echo server. This is the udp \
# version.
service echo
{
disable = yes
type = INTERNAL UNLISTED
id = echo-dgram
socket_type = dgram
protocol = udp
user = root
wait = yes
port = 7
}
解读:由于它们的服务名相同,只是socket类型不同,所以,使用id属性来区分。
【范例4】/etc/xinetd.d/rstatd
service rstatd
{
type = RPC
socket_type = dgram
protocol = udp
server = /usr/etc/rpc.rstatd
wait = yes
user = root
rpc_version = 2-4
env =LD_LIBRARY_PATH=/etc/securelib
}