inetd on Debian

9 02 2010

Unix or Linux contains 2 basic network services.

1. Network Services enabled by init
These network services always waits for network traffic and are started at boot time.
2. Network Services enabled by inetd or xinetd
Network services of this type are triggered when network traffic relating to one described in /etc/inetd.conf arrives.

inetd.conf format

To illustrate clear enough, consider this inetd.conf example file
discard     dgram   udp     wait    root    internal
daytime     stream  tcp     nowait  root    internal
#time       dgram   udp     wait    root    internal
#:STANDARD: These are standard services.
telnet      stream  tcp     nowait  root /usr/sbin/tcpd
ftp         stream  tcp     nowait  root /usr/sbin/tcpd

Service field must follow this pattern
service_name sock_type proto flags user server_path args

service name : mapping service name can be seen in /etc/services
socket type : stream and dgram are mostly used by TCP and UDP respectively
protocol : Yeah, we often deal with tcp or udp
flags : Wait status inform inetd process to fork the new process if nowait is configured. wait uses only a single process.
user : username of the network service
path : path to the network service program
arg : arguments
After configuring, restart inetd for all changes.
etc/init.d/openbsd-inetd restart
You can view the listening ports by
netstat -tl
netstat -ul

The difference of these 2 commands are for you to discover.