48.5. TCP Wrappers and xinetd
Controlling access to network services is one of the most important security tasks facing a server administrator. Red Hat Enterprise Linux provides several tools for this purpose. For example, an
iptables-based firewall filters out unwelcome network packets within the kernel's network stack. For network services that utilize it, TCP Wrappers add an additional layer of protection by defining which hosts are or are not allowed to connect to "wrapped" network services. One such wrapped network service is the
xinetdsuper server. This service is called a super server because it controls connections to a subset of network services and further refines access control.
Figure 48.9, “Access Control to Network Services” is a basic illustration of how these tools work together to protect network services.
Figure 48.9. Access Control to Network Services
This chapter focuses on the role of TCP Wrappers and
xinetdin controlling access to network services and reviews how these tools can be used to enhance both logging and utilization management. Refer to Section 48.9, “IPTables” for information about using firewalls with
48.5.1. TCP Wrappers
The TCP Wrappers package (
tcp_wrappers) is installed by default and provides host-based access control to network services. The most important component within the package is the
/usr/lib/libwrap.alibrary. In general terms, a TCP-wrapped service is one that has been compiled against the
When a connection attempt is made to a TCP-wrapped service, the service first references the host's access files (
/etc/hosts.deny) to determine whether or not the client is allowed to connect. In most cases, it then uses the syslog daemon (
syslogd) to write the name of the requesting client and the requested service to
If a client is allowed to connect, TCP Wrappers release control of the connection to the requested service and take no further part in the communication between the client and the server.
In addition to access control and logging, TCP Wrappers can execute commands to interact with the client before denying or releasing control of the connection to the requested network service.
Because TCP Wrappers are a valuable addition to any server administrator's arsenal of security tools, most network services within Red Hat Enterprise Linux are linked to the
libwrap.alibrary. Some such applications include
To determine if a network service binary is linked to
libwrap.a, type the following command as the root user:
ldd <binary-name> | grep libwrap
Replace <binary-name> with the name of the network service binary.
If the command returns straight to the prompt with no output, then the network service is not linked to
The following example indicates that
/usr/sbin/sshdis linked to
ldd /usr/sbin/sshd | grep libwraplibwrap.so.0 => /usr/lib/libwrap.so.0 (0x00655000) ~]#
126.96.36.199. Advantages of TCP Wrappers
TCP Wrappers provide the following advantages over other network service control techniques:
- Transparency to both the client and the wrapped network service — Both the connecting client and the wrapped network service are unaware that TCP Wrappers are in use. Legitimate users are logged and connected to the requested service while connections from banned clients fail.
- Centralized management of multiple protocols — TCP Wrappers operate separately from the network services they protect, allowing many server applications to share a common set of access control configuration files, making for simpler management.