Banners.Makefile06-Nov-20122.2 KiB

BLURB06-Nov-20121.7 KiB

CHANGES06-Nov-201218.7 KiB

clean_exit.c01-Nov-20131.1 KiB

diag.c23-Aug-20181.4 KiB

DISCLAIMER06-Nov-20121.2 KiB

environ.c06-Nov-20124.8 KiB

eval.c06-Nov-20123.6 KiB


fix_options.c06-Nov-20123.7 KiB

fromhost.c06-Nov-20121.4 KiB

hosts_access.306-Nov-20123.5 KiB

hosts_access.506-Nov-201216 KiB

hosts_access.c07-Aug-201914.1 KiB

hosts_ctl.c06-Nov-20121.1 KiB

hosts_options.506-Nov-20126.5 KiB

inetcf.c07-Aug-20198 KiB


Makefile16-Dec-201232.7 KiB

misc.c06-Nov-20121.9 KiB

miscd.c06-Nov-20123.1 KiB



ncr.c06-Nov-20122.5 KiB

options.c07-Aug-201913.8 KiB



percent_x.c01-Nov-20132.4 KiB


ptx.c06-Nov-20122.6 KiB

README06-Nov-201247.1 KiB

README.IRIX06-Nov-20122.6 KiB

README.NIS06-Nov-20126.5 KiB


rfc931.c07-Aug-20195.9 KiB

safe_finger.c06-Nov-20125 KiB

scaffold.c07-Aug-20196.4 KiB



shell_cmd.c07-Aug-20192.1 KiB

socket.c07-Aug-201912.1 KiB

strcasecmp.c06-Nov-20123.8 KiB

tcpd.806-Nov-20126.9 KiB

tcpd.c07-Aug-20193.5 KiB

tcpd.h06-Jan-20178.2 KiB

tcpdchk.806-Nov-20122.5 KiB

tcpdchk.c07-Aug-201912.8 KiB

tcpdmatch.806-Nov-20123.2 KiB

tcpdmatch.c07-Aug-201910.7 KiB

tli-sequent.c06-Nov-20124.9 KiB


tli.c06-Nov-201210.3 KiB

try-from.c06-Nov-20122 KiB

update.c01-Nov-20133 KiB

vfprintf.c06-Nov-20123.1 KiB

workarounds.c06-Nov-20127.6 KiB


1@(#) README 1.30 97/03/21 19:27:21
3This is the 7.6 version of the TCP/IP daemon wrapper package.
5Thank you for using this program. If you like it, send me a postcard.
6My postal address is at the bottom of this file.
8Read the BLURB file for a brief summary of what is new. The CHANGES
9file gives a complete account of differences with respect to previous
12Announcements of new releases of this software are posted to Usenet
13(, comp.unix.admin), to the cert-tools mailing list,
14and to a dedicated mailing list.  You can subscribe to the dedicated
15mailing list by sending an email message to
16with in the body (not subject):  subscribe tcp-wrappers-announce.
18Table of contents
21    1 - Introduction
22    2 - Disclaimer
23    3 - Tutorials
24                3.1 - How it works
25                3.2 - Where the logging information goes
26    4 - Features
27                4.1 - Access control
28                4.2 - Host name spoofing
29                4.3 - Host address spoofing
30                4.4 - Client username lookups
31                4.5 - Language extensions
32		4.6 - Multiple ftp/gopher/www archives on one host
33		4.7 - Banner messages
34		4.8 - Sequence number guessing
35    5 - Other works
36                5.1 - Related documents
37                5.2 - Related software
38    6 - Limitations
39                6.1 - Known wrapper limitations
40                6.2 - Known system software bugs
41    7 - Configuration and installation
42                7.1 - Easy configuration and installation
43                7.2 - Advanced configuration and installation
44                7.3 - Daemons with arbitrary path names
45                7.4 - Building and testing the access control rules
46                7.5 - Other applications
47    8 - Acknowledgements
491 - Introduction
52With this package you can monitor and filter incoming requests for the
54network services.
56It supports both 4.3BSD-style sockets and System V.4-style TLI. Praise
57yourself lucky if you don't know what that means.
59The package provides tiny daemon wrapper programs that can be installed
60without any changes to existing software or to existing configuration
61files.  The wrappers report the name of the client host and of the
62requested service; the wrappers do not exchange information with the
63client or server applications, and impose no overhead on the actual
64conversation between the client and server applications.
66Optional features are: access control to restrict what systems can
67connect to what network daemons; client user name lookups with the RFC
68931 etc. protocol; additional protection against hosts that pretend to
69have someone elses host name; additional protection against hosts that
70pretend to have someone elses host address.
72The programs are very portable. Build procedures are provided for many
73common (and not so common) environments, and guidelines are provided in
74case your environment is not among them.
76Requirements are that network daemons are spawned by a super server
77such as the inetd; a 4.3BSD-style socket programming interface and/or
78System V.4-style TLI programming interface; and the availability of a
79syslog(3) library and of a syslogd(8) daemon.  The wrappers should run
80without modification on any system that satisfies these requirements.
81Workarounds have been implemented for several common bugs in systems
84What to do if this is your first encounter with the wrapper programs:
851) read the tutorial sections for an introduction to the relevant
86concepts and terminology; 2) glance over the security feature sections
87in this document; 3) follow the installation instructions (easy or
88advanced). I recommend that you first use the default security feature
89settings.  Run the wrappers for a few days to become familiar with
90their logs, before doing anything drastic such as cutting off access or
91installing booby traps.
932 - Disclaimer
96The wrapper programs rely on source address information obtained from
97network packets. This information is provided by the client host. It is
98not 100 percent reliable, although the wrappers do their best to expose
101In the absence of cryptographic protection of message contents, and of
102cryptographic authentication of message originators, all data from the
103network should be treated with sound scepticism.
1073 - Tutorials
110The tutorial sections give a gentle introduction to the operation of
111the wrapper programs, and introduce some of the terminology that is
112used in the remainder of the document: client, server, the inetd and
113syslogd daemons, and their configuration files.
1153.1 - How it works
118Almost every application of the TCP/IP protocols is based on a client-
119server model. For example, when a user invokes the telnet command to
120connect to one of your systems, a telnet server process is executed on
121the target host. The telnet server process connects the user to a login
122process. A few examples of client and server programs are shown in the
123table below:
125              client   server    application
126              --------------------------------
127              telnet   telnetd   remote login
128              ftp      ftpd      file transfer
129              finger   fingerd   show users
131The usual approach is to run one single daemon process that waits for
132all kinds of incoming network connections. Whenever a connection is
133established, this daemon (usually called inetd) runs the appropriate
134server program and goes back to sleep, waiting for other connections.
136The wrapper programs rely on a simple, but powerful mechanism.  Instead
137of directly running the desired server program, the inetd is tricked
138into running a small wrapper program. The wrapper logs the client host
139name or address and performs some additional checks.  When all is well,
140the wrapper executes the desired server program and goes away.
142The wrapper programs have no interaction with the client user (or with
143the client process).  Nor do the wrappers interact with the server
144application. This has two major advantages: 1) the wrappers are
145application-independent, so that the same program can protect many
146kinds of network services; 2) no interaction also means that the
147wrappers are invisible from outside (at least for authorized users).
149Another important property is that the wrapper programs are active only
150when the initial contact between client and server is established. Once
151a wrapper has done its work there is no overhead on the client-server
154The simple mechanism has one major drawback: the wrappers go away after
155the initial contact between client and server processes, so the
156wrappers are of little use with network daemons that service more than
157one client.  The wrappers would only see the first client attempt to
158contact such a server. The NFS mount daemon is a typical example of a
159daemon that services requests from multiple clients. See the section on
160related software for ways to deal with such server programs.
162There are two ways to use the wrapper programs:
1641) The easy way: move network daemons to some other directory and fill
165   the resulting holes with copies of the wrapper programs.  This
166   approach involves no changes to system configuration files, so there
167   is very little risk of breaking things.
1692) The advanced way: leave the network daemons alone and modify the
170   inetd configuration file.  For example, an entry such as:
172     tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
174   When a tftp request arrives, inetd will run the wrapper program
175   (tcpd) with a process name `in.tftpd'.  This is the name that the
176   wrapper will use when logging the request and when scanning the
177   optional access control tables.  `in.tftpd' is also the name of the
178   server program that the wrapper will attempt to run when all is
179   well.  Any arguments (`-s /tftpboot' in this particular example) are
180   transparently passed on to the server program.
182For an account of the history of the wrapper programs, with real-life
183examples, see the section below on related documents.
1853.2 - Where the logging information goes
188The wrapper programs send their logging information to the syslog
189daemon (syslogd). The disposition of the wrapper logs is determined by
190the syslog configuration file (usually /etc/syslog.conf). Messages are
191written to files, to the console, or are forwarded to a @loghost. Some
192syslogd versions can even forward messages down a |pipeline.
194Older syslog implementations (still found on Ultrix systems) only
195support priority levels ranging from 9 (debug-level messages) to 0
196(alerts). All logging information of the specified priority level or
197more urgent is written to the same destination.  In the syslog.conf
198file, priority levels are specified in numerical form.  For example,
200    8/usr/spool/mqueue/syslog
202causes all messages with priority 8 (informational messages), and
203anything that is more urgent, to be appended to the file
206Newer syslog implementations support message classes in addition to
207priority levels.  Examples of message classes are: mail, daemon, auth
208and news. In the syslog.conf file, priority levels are specified with
209symbolic names: debug, info, notice, ..., emerg. For example,
211    mail.debug                  /var/log/syslog
213causes all messages of class mail with priority debug (or more urgent)
214to be appended to the /var/log/syslog file.
216By default, the wrapper logs go to the same place as the transaction
217logs of the sendmail daemon. The disposition can be changed by editing
218the Makefile and/or the syslog.conf file. Send a `kill -HUP' to the
219syslogd after changing its configuration file. Remember that syslogd,
220just like sendmail, insists on one or more TABs between the left-hand
221side and the right-hand side expressions in its configuration file.
223Solaris 2.x note: the syslog daemon depends on the m4 macro processor.
224The m4 program is installed as part of the software developer packages.
226Trouble shooting note: when the syslogging does not work as expected,
227run the program by hand (`syslogd -d') and see what really happens.
2294 - Features
2324.1 - Access control
235When compiled with -DHOSTS_ACCESS, the wrapper programs support a
236simple form of access control.  Access can be controlled per host, per
237service, or combinations thereof. The software provides hooks for the
238execution of shell commands when an access control rule fires; this
239feature may be used to install "booby traps".  For details, see the
240hosts_access.5 manual page, which is in `nroff -man' format. A later
241section describes how you can test your access control rules.
243Access control can also be used to connect clients to the "right"
244service. What is right may depend on the requested service, the origin
245of the request, and what host address the client connects to. Examples:
247(1) A gopher or www database speaks native language when contacted from
248    within the country, otherwise it speaks English.
250(2) A service provider offers different ftp, gopher or www services
251    with different internet hostnames from one host (section 4.6).
253Access control is enabled by default. It can be turned off by editing
254the Makefile, or by providing no access control tables. The install
255instructions below describe the Makefile editing process.
257The hosts_options.5 manual page (`nroff -man' format) documents an
258extended version of the access control language. The extensions are
259disabled by default. See the section below on language extensions.
261Later System V implementations provide the Transport Level Interface
262(TLI), a network programming interface that performs functions similar
263to the Berkeley socket programming interface.  Like Berkeley sockets,
264TLI was designed to cover multiple protocols, not just Internet.
266When the wrapper discovers that the TLI interface sits on top of a
267TCP/IP or UDP/IP conversation it uses this knowledge to provide the
268same functions as with traditional socket-based applications.  When
269some other protocol is used underneath TLI, the host address will be
270some universal magic cookie that may not even be usable for access
271control purposes.
2734.2 - Host name spoofing
276With some network applications, such as RSH or RLOGIN, the client host
277name plays an important role in the authentication process. Host name
278information can be reliable when lookups are done from a _local_ hosts
279table, provided that the client IP address can be trusted.
281With _distributed_ name services, authentication schemes that rely on
282host names become more problematic. The security of your system now may
283depend on some far-away DNS (domain name server) outside your own
286The wrapper programs verify the client host name that is returned by
287the address->name DNS server, by asking for a second opinion.  To this
288end, the programs look at the name and addresses that are returned by
289the name->address DNS server, which may be an entirely different host. 
291If any name or address discrepancies are found, or if the second DNS
292opinion is not available, the wrappers assume that one of the two name
293servers is lying, and assume that the client host pretends to have
294someone elses host name.
296When compiled with -DPARANOID, the wrappers will always attempt to look
297up and double check the client host name, and will always refuse
298service in case of a host name/address discrepancy.  This is a
299reasonable policy for most systems.
301When compiled without -DPARANOID, the wrappers by default still perform
302hostname lookup. You can match hosts with a name/address discrepancy
303with the PARANOID wildcard and decide whether or not to grant service.
305Automatic hostname verification is enabled by default. Automatic
306hostname lookups and verification can be turned off by editing the
307Makefile. The configuration and installation section below describes
308the Makefile editing process.
3104.3 - Host address spoofing
313While host name spoofing can be found out by asking a second opinion,
314it is much harder to find out that a host claims to have someone elses
315network address. And since host names are deduced from network
316addresses, address spoofing is at least as effective as name spoofing.
318The wrapper programs can give additional protection against hosts that
319claim to have an address that lies outside their own network.  For
320example, some far-away host that claims to be a trusted host within
321your own network. Such things are possible even while the impersonated
322system is up and running.
324This additional protection is not an invention of my own; it has been
325present for at least five years in the BSD rsh and rlogin daemons.
326Unfortunately, that feature was added *after* 4.3 BSD came out, so that
327very few, if any, UNIX vendors have adopted it.  Our site, and many
328other ones, has been running these enhanced daemons for several years,
329and without any ill effects.
331When the wrapper programs are compiled with -DKILL_IP_OPTIONS, the
332programs refuse to service TCP connections with IP source routing
333options. -DKILL_IP_OPTIONS is not needed on modern UNIX systems
334that can stop source-routed traffic in the kernel. Examples are
3354.4BSD derivatives, Solaris 2.x, and Linux. See your system manuals
336for details.
338If you are going to use this feature on SunOS 4.1.x you should apply
339patch 100804-03+ or 101790-something depending on your SunOS version.
340Otherwise you may experience "BAD TRAP" and "Data fault" panics when
341the getsockopt() system call is executed after a TCP RESET has been
342received. This is a kernel bug, it is not the fault of the wrappers.
344The feature is disabled by default. It can be turned on by editing the
345Makefile.  The configuration and installation section below describes
346the Makefile editing process.
348UDP services do not benefit from this additional protection. With UDP,
349all you can be certain of is the network packet's destination address.
3514.4 - Client username lookups
354The protocol proposed in RFC 931 provides a means to obtain the client
355user name from the client host.  The requirement is that the client
356host runs an RFC 931-compliant daemon. The information provided by such
357a daemon is not intended to be used for authentication purposes, but it
358can provide additional information about the owner of a TCP connection.
360The RFC 931 protocol has diverged into different directions (IDENT,
361TAP, RFC 1413). To add to the confusion, they all use the same network
362port.  The daemon wrappers implement a common subset of the protocols.
364There are some limitations: the number of hosts that run an RFC 931 (or
365compatible) daemon is limited (but growing); client user name lookups
366do not work for datagram (UDP) services. More seriously, client user
367name lookups can cause noticeable delays with connections from non-UNIX
368PCs. Recent PC software seem to have fixed this (for example NCSA
369telnet). The wrappers use a 10-second timeout for RFC931 lookups, to
370accommodate slow networks and slow hosts.
372By default, the wrappers will do username lookup only when the access
373control rules require them to do so (via user@host client patterns, see
374the hosts_access.5 manual page) or when the username is needed for
375%<letter> expansions.
377You can configure the wrappers to always perform client username
378lookups, by editing the Makefile.  The client username lookup timeout
379period (10 seconds default) can be changed by editing the Makefile. The
380installation sections below describe the Makefile editing process.
382On System V with TLI-based network services, client username lookups
383will be possible only when the underlying network protocol is TCP/IP.
3854.5 - Language extensions
388The wrappers sport only a limited number of features. This is for a
389good reason: programs that run at high privilege levels must be easy to
390verify. And the smaller a program, the easier to verify. There is,
391however, a provision to add features.
393The options.c module provides a framework for language extensions.
394Quite a few extensions have already been implemented; they are
395documented in the hosts_options.5 document, which is in `nroff -man'
396format. Examples: changing the severity level at which a request for
397service is logged; "allow" and "deny" keywords; running a customized
398server instead of the standard one; many others.
400The language extensions are not enabled by default because they
401introduce an incompatible change to the access control language
402syntax.  Instructions to enable the extensions are given in the
4054.6 - Multiple ftp/gopher/www archives on one host
408Imagine one host with multiple internet addresses. These addresses do
409not need to have the same internet hostname. Thus, it is possible to
410offer services with different internet hostnames from just one host.
412Service providers can use this to offer organizations a presence on the
413"net" with their own internet hostname, even when those organizations
414aren't connected to the Internet at all.  To the end user it makes no
415difference, because applications use internet hostnames.
417There are several ways to assign multiple addresses to one machine.
418The nice way is to take an existing network interface and to assign
419additional internet addresses with the `ifconfig' command. Examples:
421    Solaris 2:	ifconfig le0:1 <address> netmask <mask> up
422    4.4 BSD:	ifconfig en0 alias <address> netmask <mask>
424On other systems one has to increase the number of network interfaces:
425either with hardware interfaces, or with pseudo interfaces like SLIP or
426PPP.  The interfaces do not need to be attached to anything. They just
427need to be up and to be assigned a suitable internet address and mask.
429With the wrapper software, `daemon@host' access control patterns can be
430used to distinguish requests by the network address that they are aimed
431at.  Judicious use of the `twist' option (see the hosts_options.5 file,
432`nroff -man' format) can guide the requests to the right server.  These
433can be servers that live in separate chroot areas, or servers modified
434to take additional context from the command line, or a combination.
436Another way is to modify gopher or www listeners so that they bind to
437only one specific network address. Multiple gopher or www servers can
438then be run side by side, each taking requests sent to its respective
439network address.
4414.7 - Banner messages
444Some sites are required to present an informational message to users
445before they attempt to login.  Banner messages can also be useful when
446denying service:  instead of simply dropping the connection a polite
447explanation is given first. Finally, banners can be used to give your
448system a more personal touch.
450The wrapper software provides easy-to-use tools to generate pre-login
451banners for ftp, telnet, rlogin etc. from a single prototype banner
452textfile.  Details on banners and on-the-fly %<letter> expansions are
453given in the hosts_options.5 manual page (`nroff -man' format). An
454example is given in the file Banners.Makefile.
456In order to support banner messages the wrappers have to be built with
457language extensions enabled. See the section on language extensions.
4594.8 - Sequence number guessing
462Recently, systems came under attack from intruders that exploited a
463well-known weakness in TCP/IP sequence number generators.  This
464weakness allows intruders to impersonate trusted hosts. Break-ins have
465been reported via the rsh service. In fact, any network service can be
466exploited that trusts the client host name or address.
468A long-term solution is to stop using network services that trust the
469client host name or address, and to use data encryption instead.
471A short-term solution, as outlined in in CERT advisory CA-95:01, is to
472configure network routers so that they discard datagrams from "outside"
473with an "inside" source address. This approach is most fruitful when
474you do not trust any hosts outside your local network.
476The IDENT (RFC931 etc.) client username lookup protocol can help to
477detect host impersonation attacks.  Before accepting a client request,
478the wrappers can query the client's IDENT server and find out that the
479client never sent that request.
481When the client host provides IDENT service, a negative IDENT lookup
482result (the client matches `UNKNOWN@host') is strong evidence of a host
483impersonation attack.
485A positive IDENT lookup result (the client matches `KNOWN@host') is
486less trustworthy.  It is possible for an attacker to spoof both the
487client request and the IDENT lookup connection, although doing so
488should be much harder than spoofing just a client request. Another
489possibility is that the client's IDENT server is lying.
491Client username lookups are described in more detail in a previous
492section. Pointers to IDENT daemon software are described in the section
493on related software.
4955 - Other works
4985.1 - Related documents
501The war story behind the tcp wrapper tools is described in:
503    W.Z. Venema, "TCP WRAPPER, network monitoring, access control and
504    booby traps", UNIX Security Symposium III Proceedings (Baltimore),
505    September 1992. 
507 (postscript)
508 (flat text)
510The same cracker is also described in:
512    W.R. Cheswick, "An Evening with Berferd, In Which a Cracker is
513    Lured, Endured, and Studied", Proceedings of the Winter USENIX
514    Conference (San Francisco), January 1992.
518An updated version of the latter paper appeared in:
520    W.R. Cheswick, S.M. Bellovin, "Firewalls and Internet Security",
521    Addison-Wesley, 1994.
523Discussions on internet firewalls are archived on
524Subscribe to the mailing list by sending a message to 
528With in the body (not subject): subscribe firewalls.
5305.2 - Related software
533Network daemons etc. with enhanced logging capabilities can generate
534massive amounts of information: our 150+ workstations generate several
535hundred kbytes each day. egrep-based filters can help to suppress some
536of the noise.  A more powerful tool is the Swatch monitoring system by
537Stephen E. Hansen and E. Todd Atkins. Swatch can process log files in
538real time and can associate arbitrary actions with patterns; its
539applications are by no means restricted to security.  Swatch is
540available, directory /general/security-tools/swatch.
542Socks, described in the UNIX Security III proceedings, can be used to
543control network traffic from hosts on an internal network, through a
544firewall host, to the outer world. Socks consists of a daemon that is
545run on the firewall host, and of a library with routines that redirect
546application socket calls through the firewall daemon.  Socks is
547available from in /pub/firewalls/socks.tar.Z.
549For a modified Socks version by Ying-Da Lee ( try, directory /pub/security/socks.cstc.
552Tcpr is a set of perl scripts by Paul Ziemba that enable you to run ftp
553and telnet commands across a firewall. Unlike socks it can be used with
554unmodified client software. Available from, /pub/tcpr.
556The TIS firewall toolkit provides a multitude of tools to build your
557own internet firewall system., directory /pub/firewalls.
559Versions of rshd and rlogind, modified to report the client user name
560in addition to the client host name, are available for anonymous ftp
561(  These programs are
562drop-in replacements for SunOS 4.x, Ultrix 4.x, SunOS 5.x and HP-UX
5639.x. This archive also contains ftpd/rexecd/login versions that support
564S/Key or SecureNet one-time passwords in addition to traditional UNIX
565reusable passwords.
567The securelib shared library by William LeFebvre can be used to control
568access to network daemons that are not run under control of the inetd
569or that serve more than one client, such as the NFS mount daemon that
570runs until the machine goes down.  Available from, file
573xinetd (posted to comp.sources.unix) is an inetd replacement that
574provides, among others, logging, username lookup and access control.
575However, it does not support the System V TLI services, and involves
576much more source code than the daemon wrapper programs. Available
577from, directory /usenet/comp.sources.unix.
579netlog from Texas A&M relies on the SunOS 4.x /dev/nit interface to
580passively watch all TCP and UDP network traffic on a network.  The
581current version is on in /pub/security/TAMU.
583Where shared libraries or router-based packet filtering are not an
584option, an alternative portmap daemon can help to prevent hackers
585from mounting your NFS file systems using the proxy RPC facility. was tested with SunOS
5874.1.X Ultrix 3.0 and Ultrix 4.x, HP-UX 8.x and some version of AIX. The
588protection is less effective than that of the securelib library because
589portmap is mostly a dictionary service.
591An rpcbind replacement (the Solaris 2.x moral equivalent of portmap)
592can be found on in /pub/security. It prevents hackers
593from mounting your NFS file systems by using the proxy RPC facility.
595Source for a portable RFC 931 (TAP, IDENT, RFC 1413) daemon by Peter
596Eriksson is available from
598Some TCP/IP implementations come without syslog library. Some come with
599the library but have no syslog daemon. A replacement can be found in  The fakesyslog
601library that comes with the nntp sources reportedly works well, too.
6036 - Limitations
6066.1 - Known wrapper limitations
609Many UDP (and rpc/udp) daemons linger around for a while after they
610have serviced a request, just in case another request comes in.  In the
611inetd configuration file these daemons are registered with the `wait'
612option. Only the request that started such a daemon will be seen by the
613wrappers.  Such daemons are better protected with the securelib shared
614library (see: Related software).
616The wrappers do not work with RPC services over TCP. These services are
617registered as rpc/tcp in the inetd configuration file. The only non-
618trivial service that is affected by this limitation is rexd, which is
619used by the on(1) command. This is no great loss.  On most systems,
620rexd is less secure than a wildcard in /etc/hosts.equiv.
622Some RPC requests (for example: rwall, rup, rusers) appear to come from
623the server host. What happens is that the client broadcasts its request
624to all portmap daemons on its network; each portmap daemon forwards the
625request to a daemon on its own system. As far as the rwall etc.  daemons
626know, the request comes from the local host.
628Portmap and RPC (e.g. NIS and NFS) (in)security is a topic in itself.
629See the section in this document on related software.
6316.2 - Known system software bugs
634Workarounds have been implemented for several bugs in system software.
635They are described in the Makefile. Unfortunately, some system software
636bugs cannot be worked around. The result is loss of functionality.
638IRIX has so many bugs that it has its own README.IRIX file.
640Older ConvexOS versions come with a broken recvfrom(2) implementation.
641This makes it impossible for the daemon wrappers to look up the
642client host address (and hence, the name) in case of UDP requests.
643A patch is available for ConvexOS 10.1; later releases should be OK.
645With early Solaris (SunOS 5) versions, the syslog daemon will leave
646behind zombie processes when writing to logged-in users.  Workaround:
647increase the syslogd threshold for logging to users, or reduce the
648wrapper's logging severity.
650On some systems, the optional RFC 931 etc. client username lookups may
651trigger a kernel bug.  When a client host connects to your system, and
652the RFC 931 connection from your system to that client is rejected by a
653router, your kernel may drop all connections with that client.  This is
654not a bug in the wrapper programs: complain to your vendor, and don't
655enable client user name lookups until the bug has been fixed.
657Reportedly, SunOS 4.1.1, Next 2.0a, ISC 3.0 with TCP 1.3, and AIX 3.2.2
658and later are OK.
660Sony News/OS 4.51, HP-UX 8-something and Ultrix 4.3 still have the bug.
661Reportedly, a fix for Ultrix is available (CXO-8919).
663The following procedure can be used (from outside the domain) to
664find out if your kernel has the bug. From the system under test, do:
666        % ftp
668This command attempts to make an ftp connection to our anonymous ftp
669server (  When the connection has been established, run
670the following command from the same system under test, while keeping
671the ftp connection open:
673        % telnet 111
675Do not forget the `111' at the end of the command. This telnet command
676attempts to connect to our portmap process.  The telnet command should
677fail with:  "host not reachable", or with a timeout error. If your ftp
678connection gets messed up, you have the bug. If the telnet command does
679not fail, please let me know a.s.a.p.!
681For those who care, the bug is that the BSD kernel code was not careful
682enough with incoming ICMP UNREACHABLE control messages (it ignored the
683local and remote port numbers, and therefore zapped *all* connections
684with the remote system). The bug is still present in the BSD NET/1
685source release (1989) but apparently has been fixed in BSD NET/2 (1991). 
6877 - Configuration and installation
6907.1 - Easy configuration and installation
693The "easy" recipe requires no changes to existing software or
694configuration files.  Basically, you move the daemons that you want to
695protect to a different directory and plug the resulting holes with
696copies of the wrapper programs.
698If you don't run Ultrix, you won't need the miscd wrapper program.  The
699miscd daemon implements among others the SYSTAT service, which produces
700the same output as the WHO command.
702Type `make' and follow the instructions.  The Makefile comes with
703ready-to-use templates for many common UNIX implementations (sun,
704ultrix, hp-ux, aix, irix,...). 
706IRIX has so many bugs that it has its own README.IRIX file.
708When the `make' succeeds the result is five executables (six in case of
711You can use the `tcpdchk' program to identify the most common problems
712in your wrapper and inetd configuration files.  
714With the `tcpdmatch' program you can examine how the wrapper would
715react to specific requests for service.  
717The `safe_finger' command should be used when you implement booby
718traps:  it gives better protection against nasty stuff that remote
719hosts may do in response to your finger probes.
721The `try-from' program tests the host and username lookup code.  Run it
722from a remote shell command (`rsh host /some/where/try-from') and it
723should be able to figure out from what system it is being called.
725The tcpd program can be used to monitor the telnet, finger, ftp, exec,
726rsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
727a one-to-one mapping onto executable files.
729The tcpd program can also be used for services that are marked as
730rpc/udp in the inetd configuration file, but not for rpc/tcp services
731such as rexd.  You probably do not want to run rexd anyway. On most
732systems it is even less secure than a wildcard in /etc/hosts.equiv.
734With System V.4-style systems, the tcpd program can also handle TLI
735services. When TCP/IP or UDP/IP is used underneath TLI, tcpd provides
736the same functions as with socket-based applications. When some other
737protocol is used underneath TLI, functionality will be limited (no
738client username lookups, weird network address formats).
740Decide which services you want to monitor. Move the corresponding
741vendor-provided daemon programs to the location specified by the
742REAL_DAEMON_DIR constant in the Makefile, and fill the holes with
743copies of the tcpd program. That is, one copy of (or link to) the tcpd
744program for each service that you want to monitor. For example, to
745monitor the use of your finger service:
747    # mkdir REAL_DAEMON_DIR
748    # mv /usr/etc/in.fingerd REAL_DAEMON_DIR
749    # cp tcpd /usr/etc/in.fingerd
751The example applies to SunOS 4. With other UNIX implementations the
752network daemons live in /usr/libexec, /usr/sbin or in /etc, or have no
753"in." prefix to their names, but you get the idea.
755File protections: the wrapper, all files used by the wrapper, and all
756directories in the path leading to those files, should be accessible
757but not writable for unprivileged users (mode 755 or mode 555). Do not
758install the wrapper set-uid.
760Ultrix only:  If you want to monitor the SYSTAT service, move the
761vendor-provided miscd daemon to the location specified by the
762REAL_DAEMON_DIR macro in the Makefile, and install the miscd wrapper
763at the original miscd location.
765In the absence of any access-control tables, the daemon wrappers
766will just maintain a record of network connections made to your system.
7687.2 - Advanced configuration and installation
771The advanced recipe leaves your daemon executables alone, but involves
772simple modifications to the inetd configuration file.
774Type `make' and follow the instructions.  The Makefile comes with
775ready-to-use templates for many common UNIX implementations (sun,
776ultrix, hp-ux, aix, irix, ...). 
778IRIX users should read the warnings in the README.IRIX file first.
780When the `make' succeeds the result is five executables (six in case of
783You can use the `tcpdchk' program to identify the most common problems
784in your wrapper and inetd configuration files.  
786With the `tcpdmatch' program you can examine how the wrapper would
787react to specific requests for service.  
789The `try-from' program tests the host and username lookup code.  Run it
790from a remote shell command (`rsh host /some/where/try-from') and it
791should be able to figure out from what system it is being called.
793The `safe_finger' command should be used when you implement a booby
794trap:  it gives better protection against nasty stuff that remote hosts
795may do in response to your finger probes.
797The tcpd program can be used to monitor the telnet, finger, ftp, exec,
798rsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
799a one-to-one mapping onto executable files.
801With System V.4-style systems, the tcpd program can also handle TLI
802services. When TCP/IP or UDP/IP is used underneath TLI, tcpd provides
803the same functions as with socket-based applications. When some other
804protocol is used underneath TLI, functionality will be limited (no
805client username lookups, weird network address formats).
807The tcpd program can also be used for services that are marked as
808rpc/udp in the inetd configuration file, but not for rpc/tcp services
809such as rexd.  You probably do not want to run rexd anyway. On most
810systems it is even less secure than a wildcard in /etc/hosts.equiv.
812Install the tcpd command in a suitable place. Apollo UNIX users will
813want to install it under a different name because the name "tcpd" is
814already taken; a suitable name would be "frontd".  
816File protections: the wrapper, all files used by the wrapper, and all
817directories in the path leading to those files, should be accessible
818but not writable for unprivileged users (mode 755 or mode 555). Do not
819install the wrapper set-uid.
821Then perform the following edits on the inetd configuration file
822(usually /etc/inetd.conf or /etc/inet/inetd.conf):
824    finger  stream  tcp     nowait  nobody  /usr/etc/in.fingerd     in.fingerd
825                                            ^^^^^^^^^^^^^^^^^^^
828    finger  stream  tcp     nowait  nobody  /usr/etc/tcpd           in.fingerd
829                                            ^^^^^^^^^^^^^
830Send a `kill -HUP' to the inetd process to make the change effective.
831Some IRIX inetd implementations require that you first disable the
832finger service (comment out the finger service and `kill -HUP' the
833inetd) before you can turn on the modified version. Sending a HUP
834twice seems to work just as well for IRIX 5.3, 6.0, 6.0.1 and 6.1.
836AIX note: you may have to execute the `inetimp' command after changing
837the inetd configuration file.
839The example applies to SunOS 4. With other UNIX implementations the
840network daemons live in /usr/libexec, /usr/sbin, or /etc, the network
841daemons have no "in." prefix to their names, or the username field in
842the inetd configuration file may be missing.
844When the finger service works as expected you can perform similar
845changes for other network services. Do not forget the `kill -HUP'.
847The miscd daemon that comes with Ultrix implements several network
848services. It decides what to do by looking at its process name. One of
849the services is systat, which is a kind of limited finger service.  If
850you want to monitor the systat service, install the miscd wrapper in a
851suitable place and update the inetd configuration file:
853    systat  stream  tcp     nowait  /suitable/place/miscd      systatd
855Ultrix 4.3 allows you to specify a user id under which the daemon will
856be executed. This feature is not documented in the manual pages.  Thus,
857the example would become:
859    systat  stream  tcp     nowait  nobody /suitable/place/miscd    systatd
861Older Ultrix systems still run all their network daemons as root.
863In the absence of any access-control tables, the daemon wrappers
864will just maintain a record of network connections made to your system.
8667.3 - Daemons with arbitrary path names
869The above tcpd examples work fine with network daemons that live in a
870common directory, but sometimes that is not practical. Having soft
871links all over your file system is not a clean solution, either.
873Instead you can specify, in the inetd configuration file, an absolute
874path name for the daemon process name.  For example,
876    ntalk   dgram   udp     wait    root    /usr/etc/tcpd /usr/local/lib/ntalkd
878When the daemon process name is an absolute path name, tcpd ignores the
879value of the REAL_DAEMON_DIR constant, and uses the last path component
880of the daemon process name for logging and for access control.
8827.4 - Building and testing the access control rules
885In order to support access control the wrappers must be compiled with
886the -DHOSTS_ACCESS option. The access control policy is given in the
887form of two tables (default: /etc/hosts.allow and /etc/hosts.deny).
888Access control is disabled when there are no access control tables, or
889when the tables are empty.
891If you haven't used the wrappers before I recommend that you first run
892them a couple of days without any access control restrictions. The
893logfile records should give you an idea of the process names and of the
894host names that you will have to build into your access control rules.
896The syntax of the access control rules is documented in the file
897hosts_access.5, which is in `nroff -man' format. This is a lengthy
898document, and no-one expects you to read it right away from beginning
899to end.  Instead, after reading the introductory section, skip to the
900examples at the end so that you get a general idea of the language.
901Then you can appreciate the detailed reference sections near the
902beginning of the document.
904The examples in the hosts_access.5 document (`nroff -man' format) show
905two specific types of access control policy:  1) mostly closed (only
906permitting access from a limited number of systems) and 2) mostly open
907(permitting access from everyone except a limited number of trouble
908makers). You will have to choose what model suits your situation best.
909Implementing a mixed policy should not be overly difficult either.
911Optional extensions to the access control language are described in the
912hosts_options.5 document (`nroff -man' format).
914The `tcpdchk' program examines all rules in your access control files
915and reports any problems it can find. `tcpdchk -v' writes to standard
916output a pretty-printed list of all rules. `tcpdchk -d' examines the
917hosts.access and hosts.allow files in the current directory. This
918program is described in the tcpdchk.8 document (`nroff -man' format).
920The `tcpdmatch' command can be used to try out your local access
921control files.  The command syntax is:
923    tcpdmatch process_name hostname (e.g.: tcpdmatch in.tftpd localhost)
925    tcpdmatch process_name address  (e.g.: tcpdmatch in.tftpd
927This way you can simulate what decisions will be made, and what actions
928will be taken, when hosts connect to your own system. The program is
929described in the tcpdmatch.8 document (`nroff -man' format).
931Note 1: `tcpdmatch -d' will look for hosts.{allow,deny} tables in the
932current working directory. This is useful for testing new rules without
933bothering your users.
935Note 2: you cannot use the `tcpdmatch' command to simulate what happens
936when the local system connects to other hosts.
938In order to find out what process name to use, just use the service and
939watch the process name that shows up in the logfile.  Alternatively,
940you can look up the name from the inetd configuration file. Coming back
941to the tftp example in the tutorial section above:
943    tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
945This entry causes the inetd to run the wrapper program (tcpd) with a
946process name `in.tftpd'.  This is the name that the wrapper will use
947when scanning the access control tables. Therefore, `in.tftpd' is the
948process name that should be given to the `tcpdmatch' command. On your
949system the actual inetd.conf entry may differ (tftpd instead of
950in.tftpd, and no `root' field), but you get the idea.
952When you specify a host name, the `tcpdmatch' program will use both the
953host name and address. This way you can simulate the most common case
954where the wrappers know both the host address and the host name.  The
955`tcpdmatch' program will iterate over all addresses that it can find
956for the given host name.
958When you specify a host address instead of a host name, the `tcpdmatch'
959program will pretend that the host name is unknown, so that you can
960simulate what happens when the wrapper is unable to look up the client
961host name.
9637.5 - Other applications
966The access control routines can easily be integrated with other
967programs.  The hosts_access.3 manual page (`nroff -man' format)
968describes the external interface of the libwrap.a library.
970The tcpd program can even be used to control access to the mail
971service.  This can be useful when you suspect that someone is trying
972out some obscure sendmail bug, or when a remote site is misconfigured
973and keeps hammering your mail daemon.
975In that case, sendmail should not be run as a stand-alone network
976listener, but it should be registered in the inetd configuration file.
977For example:
979    smtp    stream  tcp     nowait  root    /usr/etc/tcpd /usr/lib/sendmail -bs
981You will still need to run one sendmail background process to handle
982queued-up outgoing mail. A command like:
984    /usr/lib/sendmail -q15m
986(no `-bd' flag) should take care of that. You cannot really prevent
987people from posting forged mail this way, because there are many
988unprotected smtp daemons on the network.
9908 - Acknowledgements
993Many people contributed to the evolution of the programs, by asking
994inspiring questions, by suggesting features or bugfixes, or by
995submitting source code.  Nevertheless, all mistakes and bugs in the
996wrappers are my own.
998Thanks to Brendan Kehoe (, Heimir Sverrisson (
999and Dan Bernstein ( for feedback on an early
1000release of this product.  The host name/address check was suggested by
1001John Kimball (  Apollo's UNIX environment has some
1002peculiar quirks: Willem-Jan Withagen (, Pieter
1003Schoenmakers ( and Charles S. Fuller (
1004provided assistance.  Hal R.  Brand ( told me how to
1005get the client IP address in case of datagram-oriented services, and
1006suggested the optional shell command feature.  Shabbir Safdar
1007( provided a first version of a much-needed manual
1008page.  Granville Boman Goza, IV ( suggested to use the
1009client IP address even when the host name is available.  Casper H.S.
1010Dik ( provided additional insight into DNS spoofing
1011techniques.  The bogus daemon feature was inspired by code from Andrew
1012Macpherson (BNR Europe Ltd).  Steve Bellovin (
1013confirmed some of my suspicions about the darker sides of TCP/IP
1014insecurity. Risks of automated fingers were pointed out by Borja Marcos
1015( Brad Plecs ( was kind enough to try
1016my early TLI code and to work out how DG/UX differs from Solaris.
1018John P.  Rouillard ( deserves special mention for his
1019persistent, but constructive, nagging about wrong or missing things,
1020and for trying out and discussing embryonic code or ideas.
1022Last but not least, Howard Chu (, Darren Reed
1023(, Icarus Sparry (, Scott Schwartz
1024(, John A. Kunze (, Daniel Len Schales
1025(, Chris Turbeville (, Paul Kranenburg
1026(, Marc Boucher (, Dave Mitchell
1027(, Andrew Maffei, Adrian van Bloois, Rop Gonggrijp, John
1028C. Wingenbach, Everett F. Batey  and many, many others provided fixes,
1029code fragments, or ideas for improvements.
1031        Wietse Venema (
1032        Department of Mathematics and Computing Science
1033        Eindhoven University of Technology
1034        P.O. Box 513
1035        5600 MB Eindhoven
1036        The Netherlands
1038	Currently visiting IBM T.J. Watson Research, Hawthorne NY, USA.


1@(#) README.IRIX 1.2 94/12/28 18:45:58
3In the past few months I received several messages with questions from
4people that tried to use my tcp wrapper on IRIX 5.x. Some mysteries
5could be solved via email, and then some remained.
7Today I finally had a chance to do some tests on someones IRIX 5.2
8system.  Here is my first-hand experience with wrapper release 6.3.
10(1) Inetd is broken. Normally one edits inetd.conf, sends a HUP signal
11    to inetd and that's it. With IRIX evil things happen:  inetd is too
12    stupid to remember that it is already listening on a port.
14    In order to modify an entry in inetd.conf, first comment it out
15    with a # at the beginning of the line, kill -HUP the inetd, then
16    uncomment the inetd.conf entry and kill -HUP again.
18    Even with this amount of care I have seen inetd messing up, like
19    calling rusersd when I make a talk connection.  Even killing and
20    restarting inetd does not solve all problems.
22    I find it hard to believe, it but the best thing to do with IRIX is
23    to reboot after changing inetd.conf.
25(2) When tcpd is built according to the irix4 Makefile rules, it
26    appears to work as expected with TCP-based services such as
27    fingerd, and with UDP-based services such as ntalk and tftp.
29(3) It does NOT work with RPC over UDP services such as rusersd and
30    rstatd:  the wrapper hangs in the recvfrom() system call, and I
31    have spent several hours looking for ways to work around it. No
32    way.  After finding that none of the applicable socket primitives
33    can be made to work (recvfrom recvmsg) I give up. So, the IRIX RPC
34    services cannot be wrapped until SGI fixes their system so that it
35    works like everyone elses code (HP Sun Dec AIX and so on).
37(4) I didn't even bother to try the RPC over TCP services.
39(5) When an IRIX 5.2 system is a NIS client, it can have problems with
40    hosts that have more than one address: the wrapper will see only
41    one address, and may complain when PARANOID mode is on. The fix is
42    to change the name service lookup order in /etc/resolv.conf so that
43    your system tries DNS before NIS (hostresorder bind nis local).
45(6) IRIX 5.2 is not System V.4, and it shows. Do not link with the
46    -lsocket and -lnsl libraries. They are completely broken, and the
47    wrapper will be unable to figure out the client internet address.
48    So, TLI services cannot be wrapped until SGI fixes their system so
49    that it works the way it is supposed to.
51I am not impressed by the quality of the IRIX system software.  There
52are many things that work on almost every other system except with IRIX.
54	Wietse


1@(#) README.NIS 1.2 96/02/11 17:24:52
3> Problem: I have several [machines] with multiple IP addresses, and
4> when they try to connect to a daemon with tcp wrapper, they are often
5> rejected.  I assume this is due to the -DPARANOID option, and depends
6> on which IP address is returned first from the nameserver for a given
7> name.   This behavior seems to be random, may depend on ordering in
8> the YP host map?
10[Note: the situation described below no longer exists. Presently, my
11internet gateway uses the same IP address on all interfaces.  To avoid
12confusion I have removed the old name from the DNS. I
13have kept the discussion below for educational reasons].
15NIS was not designed to handle multi-homed hosts.  With NIS, each
16address should have its own hostname. For example, wzv-gw is my
17gateway. It has two interfaces: one connected to the local ethernet,
18the other to a serial link. In the NIS it is registered as:
20  wzv-gw-ether
21   wzv-gw-slip
23In principle, wzv-gw could be the official name of one of these
24interfaces, or it could be an alias for both.
26The DNS was designed to handle multi-homed hosts. In the DNS my gateway
27is registered in zone, with one name that has two A records:
29        wzv-gw  IN      A
30                IN      A
32And of course there are PTR records in zones
33and that point to
35This setup does not cause any problems. You can test your name service
36with the two programs below. This is what they say on a local NIS client
37(both client and server running SunOS 4.1.3_U1):
39        % gethostbyname wzv-gw
40        Hostname:
41        Aliases:        
42        Addresses: 
44        % gethostbyaddr
45        Hostname:       wzv-gw-ether
46        Aliases:        
47        Addresses: 
49        % gethostbyaddr
50        Hostname:       wzv-gw-slip
51        Aliases:        
52        Addresses: 
54Things seem less confusing when seen by a NIS client in a different
55domain (both client and server running SunOS 4.1.3_U1):
57        % gethostbyname
58        Hostname:
59        Aliases:        
60        Addresses: 
62        % gethostbyaddr
63        Hostname:
64        Aliases:        
65        Addresses:
67        % gethostbyaddr
68        Hostname:
69        Aliases:        
70        Addresses:
72Alas, Solaris 2.4 still has problems. This is what I get on a Solaris
732.4 NIS client, with a SunOS 4.1.3_U1 NIS server:
75	% gethostbyname
76	Hostname:
77	Aliases: 
78	Addresses: 
80The tcpd source comes with a workaround for this problem. The
81workaround is ugly and is not part of the programs attached below.
84#! /bin/sh
85# This is a shell archive.  Remove anything before this line, then unpack
86# it by saving it into a file and typing "sh file".  To overwrite existing
87# files, type "sh file -c".  You can also feed this as standard input via
88# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
89# will see the following message at the end:
90#		"End of shell archive."
91# Contents:  gethostbyaddr.c gethostbyname.c
92# Wrapped by wietse@wzv on Sun Jan  8 17:08:48 1995
93PATH=/bin:/usr/bin:/usr/ucb ; export PATH
94if test -f gethostbyaddr.c -a "${1}" != "-c" ; then 
95  echo shar: Will not over-write existing file \"gethostbyaddr.c\"
97echo shar: Extracting \"gethostbyaddr.c\" \(1073 characters\)
98sed "s/^X//" >gethostbyaddr.c <<'END_OF_gethostbyaddr.c'
99X /*
100X  * gethostbyaddr tester. compile with:
101X  * 
102X  * cc -o gethostbyaddr gethostbyaddr.c (SunOS 4.x)
103X  * 
104X  * cc -o gethostbyaddr gethostbyaddr.c -lnsl (SunOS 5.x)
105X  * 
106X  * run as: gethostbyaddr address
107X  * 
108X  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
109X  */
111X#include <sys/types.h>
112X#include <sys/socket.h>
113X#include <netinet/in.h>
114X#include <arpa/inet.h>
115X#include <netdb.h>
116X#include <stdio.h>
118Xmain(argc, argv)
119Xint     argc;
120Xchar  **argv;
122X    struct hostent *hp;
123X    long    addr;
125X    if (argc != 2) {
126X	fprintf(stderr, "usage: %s i.p.addres\n", argv[0]);
127X	exit(1);
128X    }
129X    addr = inet_addr(argv[1]);
130X    if (hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)) {
131X	printf("Hostname:\t%s\n", hp->h_name);
132X	printf("Aliases:\t");
133X	while (hp->h_aliases[0])
134X	    printf("%s ", *hp->h_aliases++);
135X	printf("\n");
136X	printf("Addresses:\t");
137X	while (hp->h_addr_list[0])
138X	    printf("%s ", inet_ntoa(*(struct in_addr *) * hp->h_addr_list++));
139X	printf("\n");
140X	exit(0);
141X    }
142X    fprintf(stderr, "host %s not found\n", argv[1]);
143X    exit(1);
146if test 1073 -ne `wc -c <gethostbyaddr.c`; then
147    echo shar: \"gethostbyaddr.c\" unpacked with wrong size!
149# end of overwriting check
151if test -f gethostbyname.c -a "${1}" != "-c" ; then 
152  echo shar: Will not over-write existing file \"gethostbyname.c\"
154echo shar: Extracting \"gethostbyname.c\" \(999 characters\)
155sed "s/^X//" >gethostbyname.c <<'END_OF_gethostbyname.c'
156X /*
157X  * gethostbyname tester. compile with:
158X  * 
159X  * cc -o gethostbyname gethostbyname.c (SunOS 4.x)
160X  * 
161X  * cc -o gethostbyname gethostbyname.c -lnsl (SunOS 5.x)
162X  * 
163X  * run as: gethostbyname hostname
164X  * 
165X  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
166X  */
167X#include <sys/types.h>
168X#include <sys/socket.h>
169X#include <netinet/in.h>
170X#include <arpa/inet.h>
171X#include <netdb.h>
172X#include <stdio.h>
174Xmain(argc, argv)
175Xint     argc;
176Xchar  **argv;
178X    struct hostent *hp;
180X    if (argc != 2) {
181X	fprintf(stderr, "usage: %s hostname\n", argv[0]);
182X	exit(1);
183X    }
184X    if (hp = gethostbyname(argv[1])) {
185X	printf("Hostname:\t%s\n", hp->h_name);
186X	printf("Aliases:\t");
187X	while (hp->h_aliases[0])
188X	    printf("%s ", *hp->h_aliases++);
189X	printf("\n");
190X	printf("Addresses:\t");
191X	while (hp->h_addr_list[0])
192X	    printf("%s ", inet_ntoa(*(struct in_addr *) * hp->h_addr_list++));
193X	printf("\n");
194X	exit(0);
195X    } else {
196X	fprintf(stderr, "host %s not found\n", argv[1]);
197X	exit(1);
198X    }
201if test 999 -ne `wc -c <gethostbyname.c`; then
202    echo shar: \"gethostbyname.c\" unpacked with wrong size!
204# end of overwriting check
206echo shar: End of shell archive.
207exit 0