|
NAMEwhoseip - return information about IP addressSYNOPSISwhoiseip [-dhN] [-F FILE] [-D FILE] [-i FILE] [--cache-file=FILE] [--debug] [--define-format=NAME=TEXT] [--dump=FILE] [--export] [--fastcgi=[SUFFIX...]] [--format=TEXT] [--format-file=[NAME=]FILE] [--formfile=FILE] [--help] [--import] [--ip-list=FILE] [--no-cache] [--single-query] [--usage] [IPADDR...]DESCRIPTIONFor each IP address, whoseip returns the country it is located in (a ISO 3166-1 code), the network it belongs to and the number of addresses in the network.The program can operate in several modes: as a standalone command line tool, or as a CGI or Fast CGI process. If the program name ends in .fcgi the Fast CGI mode is enabled. This mode is also enabled if the command line option --fastcgi is given without arguments, or if the program name ends in one of the suffixes supplied in the argument to this option (a whitespace-separated list). In this mode, the IP address to look for is taken from the URI parameter ip. Additional parameter fmt can be used to supply the name of the desired output format. Its value must be either a name of one of the built-in formats, or must be defined using the --define-format option (see below). As a shortcut, the invocation command line containing an IP alone is also recognized. Otherwise, when one or more IP addresses are given in the command line, whoseip prints the data for each of them on the standard output. This is command line mode. If called without arguments, the program checks if the environment variable GATEWAY_INTERFACE is defined and contains CGI/V (where V is the version number). If so, it assumes CGI mode. In this mode the command line is parsed the same way as in Fast CGI mode. If GATEWAY_INTERFACE is not set, the program reads IP addresses from input (one per line) and prints replies for each of them. This is inetd mode. To summarize:
Output formats are configurable and depend on the mode whoseip runs in. In command line and inetd modes, the default output format is: OK COUNTRY CIDR RANGE
COUNT
where COUNTRY is country code, CIDR is network block in CIDR notation, RANGE is network block as a range of IP addresses, and COUNT is number of IP address in the network block. If the specified IP address is not found, the reply is NO TEXT
where TEXT is a human-readable explanatory message. If the input is invalid, the reply is: BAD TEXT
In CGI and FastCGI modes, the output is represented as XML, as shown in the example below: <?xml version="1.0" encoding="US-ASCII"?> <whoseip xmlns:whoseip="http://man.gnu.org.ua/8/whoseip"> <whoseip:status>OK</whoseip:status> <whoseip:country>US</whoseip:country> <whoseip:cidr>192.0.2.0/24</whoseip:cidr> <whoseip:range>192.0.2.0-192.0.2.255</whoseip:range> <whoseip:count>255</whoseip:count> <whoseip:term>192.0.2.10</whoseip:term> </whoseip> The following example illustrates the reply if the IP is not found: <?xml version="1.0" encoding="US-ASCII"?> <whoseip xmlns:whoseip="http://man.gnu.org.ua/8/whoseip"> <whoseip:status>NO</whoseip:status> <whoseip:diag>IP unknown</whoseip:diag> <whoseip:term>43.0.0.1</whoseip:term> </whoseip> See the section FORMAT below for a discussion on how to customize output formats. CachingTo minimize number of queries to external whois servers, it is recommended to use a cache database. It is enabled by using the --cache-file=FILENAME option (or cache-file configuration file statement). A time to live for the cached records can be set using the --cache-ttl option.OPTIONS
The following options cause the program to display informative text and exit:
CONFIGURATION FILEIf the file /etc/whoseip.conf exists, it is read before processing command line options. If the environment variable WHOSEIP_CONF is set, its value is used as the file name, instead of /etc/whoseip.conf.The file is read line by line. Long lines can be split over several physical lines by inserting a backslash followed by a newline. Empty lines are ignored. Comments are introduced with the # character. Anything following it up to the logical line is ignored. Each non-empty line must contain a single long command line option, without the leading --. Arguments must be separated from options with an equals sign, optionally surrounded with whitespace. For example: # Assume FastCGI if the program name ends in one of these # suffixes fastcgi = .fcgi .pl # Define output format for CGI and FastCGI modes define-format = cgi=Content-Type: application/json\n\ \n\ { "status": "${status}", \ $?{diag}{"diag": "${diag}"}{\ "country": "${country}",\ "cidr": "${cidr}",\ "range": "${range}",\ "count": "${count}"}\ $?{term}{, "term": "${term}" } }\n FORMATOutput formats can be redefined using --define-format, --format, and --format-file command line options, or corresponding configuration file keywords.The format string supplied with this options (or in the input file, in case of the --format-file option) can contain the following macro references, which are replaced with the corresponding piece of information on output:
If a macro is not defined, the corresponding reference expands to empty string. Conditional expressions evaluate depending on whether a macro is defined. The syntax of a conditional expression is: $?{NAME}{TEXT-IF-TRUE}{TEXT-IF-FALSE}
Its effect is as follows: if the macro NAME is defined, the TEXT-IF-TRUE is substituted, otherwise the TEXT-IF-FALSE is substituted. Conditional expressions can be nested. The escape sequences \a, \b, \e, \f, \n, \r, \t, and \v are replaced according to their traditional meaning. EXIT CODES
BUGSOnly IPv4 is supported.AUTHORSergey Poznyakoff <gray@gnu.org>POD ERRORSHey! The above document had some coding errors, which are explained below:
Visit the GSP FreeBSD Man Page Interface. |