What is inetd?
Following is a very simple diagram to illustrate inetd(8):
pop3 ------ |
|
ftpd ------- | INETD | ---- Internet / DMZ / Switch / Whatever . . .
|
cvsupserver - |
In the above diagram you can see the general idea. The inetd process receives a request and then starts the appropriate server process. What inetd is doing is software multiplexing. An important note here, regarding security: On many other UNIX-like systems, a package called tcpwrappers is used as a security enhancement for inetd.|
ftpd ------- | INETD | ---- Internet / DMZ / Switch / Whatever . . .
|
cvsupserver - |
Configuring inetd - /etc/inetd.conf
/etc/inetd.conf
, see inetd.conf(5). The inetd.conf
file basically provides enabling and mapping of services the systems administrator would like to have multiplexed through inetd(8), indicating which program should be started for incoming requests on which port.inetd.conf(5) is an ascii file containing one service per line, and several fields per line.
The basic field layout is:
service-name socket-type protocol wait/nowait user:group server-program arguments
Services - /etc/services
/etc/services
. This file basically contains information mapping a service name to a port number.The format of the
/etc/services
file is:service-name port-number/protocol-name [aliases]"service-name" is the name of the service, "port-number" is the port number assigned to the service, "protocol-name" is either "tcp" or "udp", and if alias names for a port are needed, they can be added as "aliases", separated by white spaces.
Let's take a look at the "ssh" entries as an example:
ssh 22/tcp # Secure Shell ssh 22/udpAs we can see, from the left, the service name is "ssh", the port number is "22", the protocols are both "tcp" and "udp". Notice that there is a separate entry for every protocol a service can use (even on the same port).
Protocols - /etc/protocols
/etc/protocols
. This file has the information pertaining to DARPA Internet protocols. The format of the protocols name data base is:protocol-name number [aliases]
where "protocol-name" describes the payload of an IP packet, e.g. "tcp" or "udp". "number" is the official protocol number assigned by IANA, and optional alias names can be added after that. Let's look at the seventh entry in the
/etc/protocols
db as an example:tcp 6 TCP # transmission control protocol
Remote Procedure Calls (RPC) - /etc/rpc
/etc/rpc
and contains name mappings to rpc program numbers.The format of the file is:
server-name program-number aliasesFor example, here is the nfs entry:
nfs 100003 nfsprog
Allowing and denying hosts - /etc/hosts.{allow,deny}
/etc/hosts.allow
and /etc/hosts.deny
Securing the configuration files -
1. Change the permissions on this file to 600
root shell > chmod 600 /etc/inetd.conf
2. Ensure that the owner is root.
root shell > stat /etc/inetd.conf
3. Edit the inetd.conf file vi /etc/inetd.conf and disable services like: ftp, telnet, shell, login, exec, talk, ntalk, imap, pop-2, pop-3, finger, auth, etc. unless you plan to use it. If it's turned off, it's much less of a risk
root shell > killall -HUP inetd
4. One more security measure you can take to secure the inetd.conf file is to set it immutable, using the chattr command. To set the file immutable simply, execute the following command:root shell > chattr +i /etc/inetd.conf
This will prevent any changes accidental or otherwise to the inetd.conf file. A file with the immutable attribute set i cannot be modified, deleted or renamed, no link can be created to this file and no data can be written to it. The only person that can set or clear this attribute is the super-user root. If you wish later to modify the inetd.conf file you will need to unset the immutable flag: To unset the immutable flag, simply execute the following command:
root shell > chattr -i /etc/inetd.conf
References:
http://www.netbsd.org/docs/guide/en/chap-inetd.html
http://www.faqs.org/docs/securing/chap5sec36.html
No comments:
Post a Comment