Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Google   


Solaris Inetd Services

News

Lecture Notes  OSI Protocol Layers Recommended Books Recommended Links TCP Wrappers Xinetd Humor   Etc

Lecture Notes

The client-server model describes network services and the client programs of those services. One example of the client-server relationship is the name server and resolver model of the DNS. Another example of the client and server relationship is the NFS.

Starting and stopping services

To start services for server processes, you must know which files to use for automatic service configuration. You must also know how to manually start the services.

There are two ways of starting services: via inetd and via RC files

 Internet Service Daemon (inetd)

The inetd daemon is a special network process that runs on each system and starts server processes that do not automatically start at boot time. The inetd daemon is the server process for both the standard Internet services and Sun Remote Procedure Call (Sun RPC) services. The inetd daemon starts at boot time using the /etc/rc2.d/S72inetsvc script. A configuration file lists the services that the inetd daemon will listen for and start in response to network requests. If you do not specify a configuration file, the inetd daemon uses the default /etc/inet/inetd.conf file.

  1. To get the list of services that the inetd daemon listens for,  perform the command:

    # cat /etc/inet/inetd.conf
    .
    .(output truncated)
    .
    # TELNETD - telnet server daemon
    telnet stream tcp6 nowait root /usr/sbin/in.telnetd in.telnetd
    # smserverd to support removable media devices
    100155/1 tli rpc/ticotsord wait root
    /usr/lib/smedia/rpc.smserverd rpc.smserverd
    # REXD - rexd server provides only minimal authentication
    #rexd/1 tli rpc/tcp wait root /usr/sbin/rpc.rexd rpc.rexd
    # FTPD - FTP server daemon
    ftp stream tcp6 nowait root /usr/sbin/in.ftpd in.ftpd -a
    .
    .(output truncated)
    .

  2. When the inetd daemon receives a network request, it runs the associated command in the inetd.conf file.
     
  3. Structure of inetd.conf file Each entry is a single line in the following form:

    service-name endpoint-type protocol wait-status uid server-program \ server-arguments

Notes

The inetd daemon starts a server process when it receives an appropriate service request. The in.ftpd server process can be invoked by the inetd daemon each time a connection to the File Transfer Protocol (FTP) service is requested as shown in the following example:

# grep ftp /etc/inet/inetd.conf
ftp stream tcp6 nowait root /usr/sbin/in.ftpd in.ftpd -a

When changing the /etc/inet/inetd.conf file, send a hang-up (HUP) signal to the inetd process to force it to reread the configuration file:

# pkill -HUP inetd

Note – To turn off a service, add a # symbol to the beginning of the line corresponding to that service in the /etc/inetd.conf file, and send a HUP request.

Services Network Ports: Well known and Ephemeral Ports

Network ports help transport protocols distinguish between multiple service requests arriving at a given host computer. The TCP and UDP transport protocols identify ports using a positive integer between 1 and 65535, which is called a port number.

Network ports can be divided into two categories:

Port Numbers There are two fundamental approaches to port assignments:

Starting Services for Well-known Ports

Each network service uses a port that represents an address space reserved for that service. If a port number is not pre-assigned, the operating system allows an application to choose an unused port number. A client often communicates with a server through a well-known port.  The list of services that use a well-known port includes:

Starting Well-Known Port Services Startup Scripts

One of the well-known port services that starts at boot time is the sendmail process. The sendmail process uses well-known port 25 to perform network services for email using the Simple Mail Transport Protocol (SMTP). You can confirm that the name has been translated to the port number by searching for the mail entry in the /etc/inet/services file. To confirm the translation, perform the command: 

# grep mail /etc/inet/services
smtp 25/tcp mail

The sendmail process is initialized by the startup script /etc/rc2.d/S88sendmail when you boot the Solaris 9 OE. Because the sendmail process uses port 25, the sendmail process starts listening at  port 25 for incoming mail activity soon after start up. There is no need for the inetd daemon to listen at port 25 for incoming sendmail requests or to start sendmail, because the sendmail process is already running. 

Starting Well-Known Port Services on Demand using Inetd

The telnet service is a well-known port service that does not automatically start at boot time. For example the telnet service uses port 23. At the same time this services is used only episodically and it makes sense to run it only when there is a request to save memory. The inetd daemon can listen for telnet requests, so that the telnet service does not have to continually run on the system. When the inetd daemon  receives a network request at a port, it uses the information listed in the /etc/inet/service file to determine which service to start and if this is a telnet connection starts telnet daemon.

Here is a typical scenario that involves two system alisa and bill with alisa trying to connect to bill using telnet service:

  1. The initiating host alisa executes telnet bill command.
  2. The telnet service is a well-known service. The port for this service is port 23.
  3. The telnet packet requesting a connection goes to port 23 on the host bill.
  4. Initially, the inetd daemon listens at port 23 for the telnet service. The telnet bill command on alisa  generates a request to port 23 that inetd recognizes as a telnet request because of the configuration entry in the /etc/inet/services file (it associates ports and services for inetd).
  5. The telnet service does not continuously run on a system waiting for a connection. The inetd daemon must start the telnet service dynamically on demand.
  6. The inetd daemon consults the /etc/inetd.conf file to find a matching entry for the requested service. The inetd daemon  identifies the telnet service line.
  7. The inetd daemon executes the in.telnetd process from the /etc/inetd.conf file. The in.telnetd daemon takes control of the current telnet session’s communication.
  8. The in.telnetd daemon receives this session’s traffic and runs on port 23 until this telnet session ends.

Note – The inetd daemon continues to listen for new service requests.

Inetd Enhancements and Replacements

One typical enhancement of indet that provides better security is TCP Wrappers. the idea of TCP Warappers is realy simple: to screen the connection based on the rules contained in certain files (hosts.allow, host.deny) and based onthis screening to grant of deny request.  If the request is allowed, then the the corresponding server process (e.g ftp) can be started. This mechanism is also referred to as tcp_wrapper. Solaris 9 can be installed with TCP wrappers in the default installation. And TCP Wrappers are standard in Solaris 10.

There is also a  replacement for inetd, called xinetd that includes built-in TCP wrapper functionality. Like combination of  inetd+tcpd, it enables the configuration of the access rights for a given machine, but it can do more:

 It is often used in Linux distributions, but not in Solaris.

Recommended Links

inetd Daemon

inetd Daemon

Chapter 11: inetd: the Internet super server

Configuring the Internet Daemon, inetd

xinetd



Copyright © 1996-2007 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: February 28, 2008