------------------------------------------------------------------------------- Inetd Server Programs The purpose of the inetd is to provide a simple way of generating servers. The inetd program listens on all the ports specified by the /etc/inetd.conf file (ports are usually named, which is mapped in /etc/services), then calls the listed program when a connection is made. What makes it extremely useful however is that STDIN and STDOUT of the called program is connected to the accepted network connection. This means inetd server programs does NOT having to do any special C library calls, just read from standard input and write to standard output, something the simplest of shell scripts can do! WARNING: These days system filewalls and network routers tend to close of all unneeded incoming access. This make creating new servers much more involved. Also servers that are expected to handle heavy loads, may be better designed to do the networking themselves. Essentially, this technique while still in use (as xinetd), is not very popular apart from low overhead, occasional use services, like. ------------------------------------------------------------------------------- Finger Denied Server For example you can disable the finger daemon by replacing the appropriate line in /etc/inetd.conf with... finger stream tcp nowait nobody /usr/etc/nofinger nofinger then reinitialize inetd with a HUP signal. You can then create a simple "nofinger" script to do the job... =======8<-------- #!/bin/sh read cmd # Finger spits across something followed by echo "Finger is disabled for reason blah. Please send mail to^M" echo "postmaster@mysite.de if you want information about local users^M" =======8<-------- That should do the trick. Note that the ^M in the above should be replaced with a real carriage return (C-Q C-M in emacs). They are needed to correctly terminate the line for strict RFC compliance (which, last time I checked, stated that you must end lines with a pair). --- Warner Losh Note: this can also be used to log finger requests so that you can find out who is doing lots of finger requests to you (run-away finger loop for watching login and logouts. Caution, do NOT do a reverse finger lookup on a finger request! ------------------------------------------------------------------------------- Httpd Server Moved The following is a simple inetd server which creates a fake web server. This can expanded to auto-redirect a old web server to the new location. setup using... in /etc/services http 80/tcp httpd # WorldWideWeb server in /etc/inetd.conf http stream tcp nowait nobody /opt/etc/httpd_moved script httpd_moved =======8<-------- #!/usr/ucb/tail +4 # # Fake inetd http script which just reports that the server has moved! # HTTP/1.1 200 OK Server: Fake_Tail_Server/1.0 (Unix) Last-Modified: Mon, 6 Jul 1998 02:36:39 GMT Connection: close Content-Type: text/html ....whatever message is required.... =======8<-------- ------------------------------------------------------------------------------- Getting client details. Perl... $othersock = getpeername(STDIN); ($family, $port, $clientaddr) = unpack('Sna4', $othersock); $clientIP = join('.', unpack("C4", $clientaddr)); Shell... # NOTE: the following find ALL client connects at time of call netstat -n | grep "{My_IP_Address}:{My_Port}" | awk '{print $5}' |\ awk -F. '{print "@" $1 "." $2 "." $3 "." $4 }' | sort -u >> ~/client.log Also you could, if that server allows, do a identd request of some sort. However you can NOT trust the output of identd or finger unless you have control of that server. That last is also useful for a "who fingered me" program which uses a ".plan" named pipe, and a background daemon. -------------------------------------------------------------------------------