 |
 |
 |
 |
 |
 |
Introduction
very internet protocol address belongs to an organization (e.g. an internet service
provider). Which IP belongs to which organization is stored in a huge database. This
database also holds many other interesting information about a specific IP address.
There are four authoritative whois servers:
- whois.arin.net ("North America and Sub-Sahara Africa")
- whois.ripe.net ("Europe, the Middle East, Central Asia, and African countries located
north of the equator")
- whois.lacnic.net ("Latin America and some Caribbean Islands")
- whois.apnic.net ("Asia/Pacific Region")
ll these server have the same query format but may differ in their ouput format. To
query information about a specific IP open a TCP connection on port 43 to the whois
server and send the IP address in text format ("aaa.bbb.ccc.ddd") followed by a DOS line
break. Then read the server's reply.
f the server cannot resolve the query it may return an error document or a default
database entry. ARIN knows all IP addresses but will return a reference to one of the
other whois servers if the IP address does not belong to its region.
|
 |
Whois query
ince most operation systems ship with their own whois tool this program is just an
example how to query a whois server. But when rewriting it for automatic usage it can be
very useful for server applications that have to resolve IP addresses, e.g. to map an IP
to a country or organization.
'Author : Daniel, Master Sourcerer at Kitana's Cas...
'Last change: March 11, 2004
'Email : sourcerer@kitana.org
#DIM ALL
$whoishost = "whois.arin.net"
%whoisport = 43
$outputfile = "whois.txt"
'Reads a document from an open connection
FUNCTION READTCP$(H&)
LOCAL BUFFER$,DOC$
DOC$=""
DO
TCP RECV H&,1024,BUFFER$
DOC$=DOC$+BUFFER$
LOOP UNTIL BUFFER$=""
READTCP$=DOC$
END FUNCTION
'Main program
FUNCTION PBMAIN&
LOCAL HTCP&,Q$,R$
LOCAL P&,I&,NR&
|
 |
 |