RWIP2CC(1)

NAME
rwip2cc - Maps IP addresses to country codes

SYNOPSIS
  rwip2cc { --address=IP_ADDRESS | --input-file=FILE }
        [--map-file=PMAP_FILE] [--print-ips={0,1}]
        [{--integer-ips | --zero-pad-ips}] [--no-columns]
        [--column-separator=CHAR] [--no-final-delimiter]
        [{--delimited | --delimited=CHAR}]
        [--output-path=PATH] [--pager=PAGER_PROG]

  rwip2cc --help

  rwip2cc --version

DESCRIPTION
rwip2cc maps from (textual) IP address to two letter country code. Either the --address or --input-file switch is required.

The --address switch looks up the country code of a single IP address and prints the country code to the standard output.

The --input-file switch reads data from the specified file (use "stdin" or "-" to read from the standard input) and prints, to the standard output, the country code for each IP it sees. Blank lines in the input are ignored; comments, which begin at the "#" character and extend to the end of line, are also ignored. Each line that is not a blank or a comment should contain an IP address or a CIDR block; rwip2cc will complain if the line cannot be parsed. Note that for CIDR blocks, the CIDR block is exploded into its constituent IP addresses and the country code for each IP address is printed.

The --print-ips switch controls whether the IP is printed with its country code. When --print-ips=1 is specified, the output contains two columns: the IP and the country-code. When --print-ips=0 is specified, only the country code is given. The default behavior is to print the IP whenever the --input-file switch is provided, and not print the IP when --address is given.

You can tell rwip2cc to use a specific country code prefix map file by giving the location of that file to the --map-file switch. The country code prefix map file is created with the rwgeoip2ccmap(1) command. When --map-file is not specified, rwip2cc attempts to use the default country code mapping file, as specified in the "FILES" section below.

OPTIONS
Option names may be abbreviated if the abbreviation is unique or is an exact match for an option. A parameter to an option may be specified as --arg=param or --arg param, though the first form is required for options that take optional parameters.

--address=IP_ADDRESS
    Print to the standard output the country code for the single IP_ADDRESS.

--input-file=FILE
    Print the IP and country code for each IP address in FILE; use "stdin" to read from the standard input.

--map-file=PMAP_FILE
    Use the designated country code prefix mapping file instead of the default.

--print-ips={0|1}
    Controls whether the IP is printed. When the value is 1, the output contains two columns: the IP and the country-code. When the value is 0, only the country code is given. When this switch is not specified, the default behavior is to print the IPs only when input comes from a file (i.e., when --input-file is specified).

--integer-ips
    Enable printing of IPs and print the IPs as integers. By default, IP addresses are printed in their canonical form.

--zero-pad-ips
    Enable printing of IPs and print the IP addresses in their canonical form, but add zeros to the IP address so it fully fills the width of column. For IPv4, use three digits per octet, e.g, 127.000.000.001.

--no-columns
    Disable fixed-width columnar output.

--column-separator=C
    Use specified character between columns and after the final column. When this switch is not specified, the default of '|' is used.

--no-final-delimiter
    Do not print the column separator after the final column. Normally a delimiter is printed.

--delimited
--delimited=C
    Run as if --no-columns --no-final-delimiter --column-sep=C had been specified. That is, disable fixed-width columnar output; if character C is provided, it is used as the delimiter between columns instead of the default '|'.

--output-path=PATH
    Determines where the output of rwuniq (ASCII text) is written. If this option is not given, output is written to the standard output.

--pager=PAGER_PROG
    When the --input-file switch is specified and output is to a terminal, invoke the program PAGER_PROG to view the output one screen full at a time. This switch overrides the SILK_PAGER environment variable, which in turn overrides the PAGER variable. If the value of the pager is determined to be the empty string, no paging will be performed and all output will be printed to the terminal.

--help
    Print the available options and exit.

--version
    Print the version number and information about how SiLK was configured, then exit the application.

EXAMPLES
A single address using the default country code prefix map:

  $ rwip2cc --address=10.0.0.0
  --

A single address using an older version of country code prefix map:

  $ rwip2cc --map-file=old-addresses.pmap --address=128.2.0.0
  us

Multiple addresses:

  $ echo '10.0.0.0/31' | rwip2cc --input=stdin
  --
  --

ENVIRONMENT

SILK_COUNTRY_CODES
    This environment variable allows the user to specify the country code mapping file that rwip2cc will use. The value may be a complete path or a file relative to SILK_PATH. If the variable is not specified, the code looks for a file named country_codes.pmap as specified in the "FILES" section below.

SILK_PATH
    This environment variable gives the root of the install tree. As part of its search for the Country Code mapping file, rwip2cc checks the directories $SILK_PATH/share/silk and $SILK_PATH/share for a file named country_codes.pmap.

SILK_PAGER
    When set to a non-empty string, rwip2cc automatically invokes this program to display its output a screen at a time. If set to an empty string, rwip2cc does not automatically page its output.

PAGER
    When set and SILK_PAGER is not set, rwip2cc automatically invokes this program to display its output a screen at a time.

FILES
rwip2cc will look for the prefix map file that maps IPs to country codes in the following locations:

  $SILK_COUNTRY_CODES
  $SILK_PATH/share/silk/country_codes.pmap
  $SILK_PATH/share/country_codes.pmap
  /usr/local/share/silk/country_codes.pmap
  /usr/local/share/country_codes.pmap

The use of /usr/local/ in this list assumes rwip2cc is installed in the /usr/local/bin/ directory.

SEE ALSO
rwgeoip2ccmap(1)

BUGS
Neither rwip2cc nor prefix map files support IPv6 addresses.