xinetd Configuration Files
The configuration files for xinetd
are as follows:
/etc/xinetd.conf
- The globalxinetd
configuration file.
/etc/xinetd.d/
- The directory containing all service-specific files.
The /etc/xinetd.conf File
The /etc/xinetd.conf
file contains general configuration settings which affect every service under xinetd
's control. It is read when the xinetd
service is first started, so for configuration changes to take effect, you need to restart the xinetd
service. The following is a sample /etc/xinetd.conf
file:
defaults { instances = 60 log_type = SYSLOG authpriv log_on_success = HOST PID log_on_failure = HOST cps = 25 30 } includedir /etc/xinetd.d
These lines control the following aspects of xinetd
:
instances
- Specifies the maximum number of simultaneous requests thatxinetd
can process.
log_type
- Configuresxinetd
to use theauthpriv
log facility, which writes log entries to the/var/log/secure
file. Adding a directive such asFILE /var/log/xinetdlog
would create a custom log file calledxinetdlog
in the/var/log/
directory.log_on_success
- Configuresxinetd
to log successful connection attempts. By default, the remote host's IP address and the process ID of the server processing the request are recorded.log_on_failure
- Configuresxinetd
to log failed connection attempts or if the connection was denied.cps
- Configuresxinetd
to allow no more than 25 connections per second to any given service. If this limit is exceeded, the service is retired for 30 seconds.includedir
/etc/xinetd.d/
- Includes options declared in the service-specific configuration files located in the/etc/xinetd.d/
directory. Refer to "The /etc/xinetd.d/ Directory" for more information.
Often, both the log_on_success
and log_on_failure
settings in /etc/xinetd.conf
are further modified in the service-specific configuration files. More information may therefore appear in a given service's log file than the /etc/xinetd.conf
file may indicate. Refer to "Logging Options" for further information.
The /etc/xinetd.d/ Directory
The /etc/xinetd.d/
directory contains the configuration files for each service managed by xinetd
and the names of the files correlate to the service. As with xinetd.conf
, this directory is read only when the xinetd
service is started. For any changes to take effect, the administrator must restart the xinetd
service.
The format of files in the /etc/xinetd.d/
directory use the same conventions as /etc/xinetd.conf
. The primary reason the configuration for each service is stored in a separate file is to make customization easier and less likely to affect other services.
To gain an understanding of how these files are structured, consider the /etc/xinetd.d/krb5-telnet
file:
service telnet { flags = REUSE socket_type = stream wait = no user = root server = /usr/kerberos/sbin/telnetd log_on_failure += USERID disable = yes }
These lines control various aspects of the telnet
service:
service
- Specifies the service name, usually one of those listed in the/etc/services
file.
flags
- Sets any of a number of attributes for the connection.REUSE
instructsxinetd
to reuse the socket for a Telnet connection.The
REUSE
flag is deprecated. All services now implicitly use theREUSE
flag.socket_type
- Sets the network socket type tostream
.wait
- Specifies whether the service is single-threaded (yes
) or multi-threaded (no
).user
- Specifies which user ID the process runs under.server
- Specifies which binary executable to launch.log_on_failure
- Specifies logging parameters forlog_on_failure
in addition to those already defined inxinetd.conf
.disable
- Specifies whether the service is disabled (yes
) or enabled (no
).
Refer to the xinetd.conf
man page for more information about these options and their usage.
Altering xinetd Configuration Files
A range of directives is available for services protected by xinetd
. This section highlights some of the more commonly used options.
Logging Options
The following logging options are available for both /etc/xinetd.conf
and the service-specific configuration files within the /etc/xinetd.d/
directory.
The following is a list of some of the more commonly used logging options:
ATTEMPT
- Logs the fact that a failed attempt was made (log_on_failure
).
DURATION
- Logs the length of time the service is used by a remote system (log_on_success
).EXIT
- Logs the exit status or termination signal of the service (log_on_success
).HOST
- Logs the remote host's IP address (log_on_failure
andlog_on_success
).PID
- Logs the process ID of the server receiving the request (log_on_success
).USERID
- Logs the remote user using the method defined in RFC 1413 for all multi-threaded stream services (log_on_failure
andlog_on_success
).
For a complete list of logging options, refer to the xinetd.conf
man page.
Access Control Options
Users of xinetd
services can choose to use the TCP Wrappers hosts access rules, provide access control via the xinetd
configuration files, or a mixture of both. Refer to "TCP Wrappers Configuration Files" for more information about TCP Wrappers hosts access control files.
This section discusses using xinetd
to control access to services.
Unlike TCP Wrappers, changes to access control only take effect if the xinetd
administrator restarts the xinetd
service.
Also, unlike TCP Wrappers, access control through xinetd
only affects services controlled by xinetd
.
The xinetd
hosts access control differs from the method used by TCP Wrappers. While TCP Wrappers places all of the access configuration within two files, /etc/hosts.allow
and /etc/hosts.deny
, xinetd
's access control is found in each service's configuration file in the /etc/xinetd.d/
directory.
The following hosts access options are supported by xinetd
:
only_from
- Allows only the specified hosts to use the service.
no_access
- Blocks listed hosts from using the service.access_times
- Specifies the time range when a particular service may be used. The time range must be stated in 24-hour format notation, HH:MM-HH:MM.
The only_from
and no_access
options can use a list of IP addresses or host names, or can specify an entire network. Like TCP Wrappers, combining xinetd
access control with the enhanced logging configuration can increase security by blocking requests from banned hosts while verbosely recording each connection attempt.
For example, the following /etc/xinetd.d/telnet
file can be used to block Telnet access from a particular network group and restrict the overall time range that even allowed users can log in:
service telnet { disable = no flags = REUSE socket_type = stream wait = no user = root server = /usr/kerberos/sbin/telnetd log_on_failure += USERID no_access = 172.16.45.0/24 log_on_success += PID HOST EXIT access_times = 09:45-16:15 }
In this example, when a client system from the 10.0.1.0/24
network, such as 10.0.1.2
, tries to access the Telnet service, it receives the following message:
Connection closed by foreign host.
In addition, their login attempts are logged in /var/log/messages
as follows:
Sep 7 14:58:33 localhost xinetd[5285]: FAIL: telnet address from=172.16.45.107 Sep 7 14:58:33 localhost xinetd[5283]: START: telnet pid=5285 from=172.16.45.107 Sep 7 14:58:33 localhost xinetd[5283]: EXIT: telnet status=0 pid=5285 duration=0(sec)
When using TCP Wrappers in conjunction with xinetd
access controls, it is important to understand the relationship between the two access control mechanisms.
The following is the sequence of events followed by xinetd
when a client requests a connection:
- The
xinetd
daemon accesses the TCP Wrappers hosts access rules using alibwrap.a
library call. If a deny rule matches the client, the connection is dropped. If an allow rule matches the client, the connection is passed toxinetd
.
- The
xinetd
daemon checks its own access control rules both for thexinetd
service and the requested service. If a deny rule matches the client, the connection is dropped. Otherwise,xinetd
starts an instance of the requested service and passes control of the connection to that service.Care should be taken when using TCP Wrappers access controls in conjunction with
xinetd
access controls. Misconfiguration can cause undesirable effects.
Binding and Redirection Options
The service configuration files for xinetd
support binding the service to an IP address and redirecting incoming requests for that service to another IP address, hostname, or port.
Binding is controlled with the bind
option in the service-specific configuration files and links the service to one IP address on the system. When this is configured, the bind
option only allows requests to the correct IP address to access the service. You can use this method to bind different services to different network interfaces based on requirements.
This is particularly useful for systems with multiple network adapters or with multiple IP addresses. On such a system, insecure services (for example, Telnet), can be configured to listen only on the interface connected to a private network and not to the interface connected to the Internet.
The redirect
option accepts an IP address or hostname followed by a port number. It configures the service to redirect any requests for this service to the specified host and port number. This feature can be used to point to another port number on the same system, redirect the request to a different IP address on the same machine, shift the request to a totally different system and port number, or any combination of these options. A user connecting to a certain service on a system may therefore be rerouted to another system without disruption.
The xinetd
daemon is able to accomplish this redirection by spawning a process that stays alive for the duration of the connection between the requesting client machine and the host actually providing the service, transferring data between the two systems.
The advantages of the bind
and redirect
options are most clearly evident when they are used together. By binding a service to a particular IP address on a system and then redirecting requests for this service to a second machine that only the first machine can see, an internal system can be used to provide services for a totally different network. Alternatively, these options can be used to limit the exposure of a particular service on a multi-homed machine to a known IP address, as well as redirect any requests for that service to another machine especially configured for that purpose.
For example, consider a system that is used as a firewall with this setting for its Telnet service:
service telnet { socket_type = stream wait = no server = /usr/kerberos/sbin/telnetd log_on_success += DURATION USERID log_on_failure += USERID bind = 123.123.123.123 redirect = 10.0.1.13 23 }
The bind
and redirect
options in this file ensure that the Telnet service on the machine is bound to the external IP address (123.123.123.123
), the one facing the Internet. In addition, any requests for Telnet service sent to 123.123.123.123
are redirected via a second network adapter to an internal IP address (10.0.1.13
) that only the firewall and internal systems can access. The firewall then sends the communication between the two systems, and the connecting system thinks it is connected to 123.123.123.123
when it is actually connected to a different machine.
This feature is particularly useful for users with broadband connections and only one fixed IP address. When using Network Address Translation (NAT), the systems behind the gateway machine, which are using internal-only IP addresses, are not available from outside the gateway system. However, when certain services controlled by xinetd
are configured with the bind
and redirect
options, the gateway machine can act as a proxy between outside systems and a particular internal machine configured to provide the service. In addition, the various xinetd
access control and logging options are also available for additional protection.
Resource Management Options
The xinetd
daemon can add a basic level of protection from Denial of Service (DoS) attacks. The following is a list of directives which can aid in limiting the effectiveness of such attacks:
per_source
- Defines the maximum number of instances for a service per source IP address. It accepts only integers as an argument and can be used in bothxinetd.conf
and in the service-specific configuration files in thexinetd.d/
directory.
cps
- Defines the maximum number of connections per second. This directive takes two integer arguments separated by white space. The first argument is the maximum number of connections allowed to the service per second. The second argument is the number of seconds thatxinetd
must wait before re-enabling the service. It accepts only integers as arguments and can be used in either thexinetd.conf
file or the service-specific configuration files in thexinetd.d/
directory.max_load
- Defines the CPU usage or load average threshold for a service. It accepts a floating point number argument.The load average is a rough measure of how many processes are active at a given time. See the
uptime
,who
, andprocinfo
commands for more information about load average.
There are more resource management options available for xinetd
. Refer to the xinetd.conf
man page for more information.