6.3. The WHOIS Directory ServiceWHOIS is another useful read-only directory service. WHOIS provides a telephone directory-like service for machines, networks, and the people who run them. Some larger organizations like IBM, UC Berkeley, and MIT provide WHOIS service, but the most important WHOIS servers by far are those run by the InterNIC and other Internet registries like RIPE (European IP address allocations) and APNIC (Asia/Pacific address allocations). If you have to contact a system administrator at another site to report suspicious network activity, you would use WHOIS to get the contact info. There are GUI and command-line based tools for making WHOIS queries available for most operating systems. Under Unix, a typical query looks like this:
If you needed to track down the owner of a particular IP address range, WHOIS is also the right tool:
The previous sessions used a Unix command-line WHOIS client. Windows NT and MacOS do not ship with clients like this, but that shouldn't stop users of those systems from accessing this information. There are many fine shareware clients available, but it is easy enough to construct a very simple client in Perl using Net::Whois, originally by Chip Salzenberg and now maintained by Dana Hudes. The following example is only slightly modified from one provided in the documentation that comes with the module:
Querying the InterNIC/Network Solutions WHOIS server is a simple process. We use Net::Whois::Domain to return a result object. Data is then accessed by calling the methods of that object named after the fields returned by the WHOIS query. WHOIS will play a significant role in Chapter 8, "Electronic Mail", but for now let's move on to more complex directory services. We've already begun that transition simply by moving from Finger to WHOIS. There's an important distinction between the Finger and WHOIS examples that you've seen so far: structure. The output of Finger varies from one server implementation to another. Although some output conventions exist, it is freeform in nature. The InterNIC/Network Solutions WHOIS server returns data with a more consistent structure and organization. We can expect each entry to have at least Name, Address, and Domain fields. The Net::Whois module relies on this structure and parses the response into fields for us. There is another module by Vipul Ved Prakash called Net::XWhois which takes this a step further, providing a framework for parsing information formatted in different ways by different WHOIS servers. Even though the WHOIS protocol itself does not have a notion of fields, the modules we are calling are starting to rely on the structure of the information. The directory services we are about to look at take this structuring more seriously. ![]() Copyright © 2001 O'Reilly & Associates. All rights reserved. |
|