|
NAMErwip2cc - Maps IP addresses to country codesSYNOPSISrwip2cc { --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 DESCRIPTIONAs of SiLK 3.0, rwip2cc is deprecated, and it will be removed in the SiLK 4.0 release. Use rwpmaplookup(1) instead---the "EXAMPLES" section shows how to use rwpmaplookup to get output similar to that produced by rwip2cc.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. OPTIONSOption 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.
EXAMPLESThe following examples demonstrate the use of rwip2cc. In addition, each example shows how to get similar output using rwpmaplookup(1).In the following examples, the dollar sign ("$") represents the shell prompt. The text after the dollar sign represents the command line. Lines have been wrapped for improved readability, and the back slash ("\") is used to indicate a wrapped line. Single address specified on the command linePrint the country code for a single address using the default country code map. By default, only the value is printed when the address is specified on the command line.$ rwip2cc --address=10.0.0.0 -- Use the --print-ips switch to print the address and the country. $ rwip2cc --print-ip=1 --address=10.0.0.0 10.0.0.0|--| rwpmaplookup expects the input to come from a file, so use the --no-files switch to tell rwpmaplookup that the command line arguments are the addresses to print. By default, rwpmaplookup prints a title line, and each row contains the key and the value. $ rwpmaplookup --country-code --no-files 10.0.0.0 key|value| 10.0.0.0| --| Use rwpmaplookup's command line switches to exactly mimic the default output from rwip2cc: $ rwpmaplookup --country-code --fields=value --delimited --no-title \ --no-files 10.0.0.0 -- Single address using a different country code filePrint the country code for a single address specified on the command line using an older version of the country code mapping file.$ rwip2cc --map-file=old-addresses.pmap --address=128.2.0.0 us $ rwpmaplookup --country-code=old-address-map.pmap --no-files 128.2.0.0 key|value| 128.2.0.0| us| Addresses read from the standard inputUsing the default country code map, print the country code for multiple addresses read from the standard input. When the --input-file switch is given, the default output includes the address.$ echo '10.0.0.0/31' | rwip2cc --input-file=stdin 10.0.0.0|--| 10.0.0.1|--| You can use the --print-ips switch to suppress the IPs. $ echo '10.0.0.0/31' | rwip2cc --print-ips=0 --input-file=stdin -- -- Unlike rwip2cc, rwpmaplookup does not accept CIDR blocks as input. Use the IPset tools rwsetbuild(1) to parse the CIDR block list and rwsetcat(1) to print the list. $ echo '10.0.0.0/31' | rwsetbuild | rwsetcat --cidr=0 \ | rwpmaplookup --country-code key|value| 10.0.0.0| --| 10.0.0.1| --| Addresses read from a fileUsing an older version of the country code map, print the country code for multiple addresses read from a file.$ export SILK_COUNTRY_CODES=old-addresses.pmap $ cat file.txt 128.2.1.1 128.2.2.2 $ rwip2cc --input-file=file.txt 128.2.1.1|us| 128.2.2.2|us| $ rwpmaplookup --no-title --country-code file.txt 128.2.1.1| us| 128.2.2.2| us| ENVIRONMENT
FILESrwip2cc will look for the prefix map file that maps IPs to country codes in the following locations. ($SILK_COUNTRY_CODES is the value of the SILK_COUNTRY_CODES environment variable, if it is set. $SILK_PATH is value of the SILK_PATH environment variable, if it is set. The use of /usr/local/ assumes the application is installed in the /usr/local/bin/ directory.)$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 SEE ALSOrwpmaplookup(1), rwgeoip2ccmap(1), rwsetbuild(1), rwsetcat(1), silk(7)
Visit the GSP FreeBSD Man Page Interface. |