---
name: "geoip"
section: "3"
platform: "linux"
package: "tclgeoip"
version: "0.2-1.1+b1"
release: "Debian 11 (Bullseye)"
platforms: ["linux"]
url: "https://new.carta.tech/geoip"
---

# geoip(3)

A Tcl extension for geographic or organisational lookup of IP addresses and hostnames.

## NAME

geoip - A Tcl extension for geographic or organisational lookup of IP addresses  and hostnames.

## SYNOPSIS

**geoip open \[-type**  *TYPE* \] \[-flags  *FLAG* \] **geoip open \[-file**  *PATH* \] \[-flags  *FLAG* \] **geoip \[COMMAND\]** **geoip \[QUERY\]** *arg1*

## DESCRIPTION

This Tcl extension encapsulates most of GeoIP C API functions into tcl commands.

## OPEN OPTIONS

open takes either a file path and a set of flags, or a type and a set of flags. Supported types and flags are described below.

- TYPE

  Looks under the standard installation share directory, eg /usr/local/share/GeoIP/ for a GeoIP
   database according to type.

- PATH

  Absolute/relative path to GeoIP database.

- FLAG

  Flags seperated by ':', eg memory\_cache:memory\_check

## COMMAND

Individual singular commands can be one of:

- close

  Close the currently open database.

- db\_info

  Get information about the current database.

- db\_edition

  Returns edition of opened database.

- db\_avail

  Test the availability of databases in your system in known locations. e.g db\_avail country\_edition

## QUERY

Commands that query the database. All commands return N/A if a result  cannot be found. If none already open, a command will attempt to open a suitable database. country commands will open a country\_edition database. region commands will open a region\_edition\_rev1 one. name commands  will open an org\_edition one, and the record\_edition will open a  city\_edition\_rev1 database. The commands are:

- country\_code\_by\_addr

  Takes an IP address and returns the ISO-3166-1 Alpha-2 code of
   the country.

- country\_code3\_by\_addr

  Takes an IP address and returns the ISO-3166-1 Alpha-3 code the country.

- country\_code\_by\_name

  Takes a hostname and returns the ISO-3166-1 Alpha-2 code the country.

- country\_code3\_by\_name

  Takes a hostname and returns the ISO-3166-1 Alpha-3 code the country.

- country\_name\_by\_addr

  Takes an IP address and returns the country name.

- country\_name\_by\_name

  Takes a hostname and returns the country name.

- name\_by\_addr

  Takes an IP address and returns the organisation name (or ISP/ASnum according
   to the opened database)

- name\_by\_name

  Takes a hostname and returns the organisation name.

- region\_by\_addr

  Takes an IP address and returns these region attributes as in an associative
   array: country, region

- region\_by\_name

  Takes a hostname and returns the region attributes.

- record\_by\_addr

  Takes an IP address and returns these record attributes as in an associative array:
   code, code3, region, country, city, postcode, latitude, longitude, dma(dma code),
   and area (area code)

- record\_by\_name

  Takes a hostname and returns the record attributes.

## TYPES

Relevant types of databases are: country\_edition, org\_edition, isp\_edition, city\_edition\_rev1, region\_edition\_rev1, geoip\_asnum\_edition. "open -type" will accept their unambiguous abbreviations.

## FLAGS

Valid flags are: standard, memory\_cache, check\_cache, index\_cache.

## FILES

- ./share/GeoIP.dat

  GeoIP country\_edition database.

- ./share/GeoIPOrg.dat

  GeoIP org\_edition database.

- ./share/GeoIPCity.dat

  GeoIP region\_city\_rev1 database.

- ./share/GeoIPRegion.dat

  GeoIP region\_edition\_rev1 database.

- ./share/GeoIPASNum.dat

  GeoIP asnum\_edition database.

## BUGS

Please report to author.

## AUTHOR

Djihed Afifi \<djihed@gmail.com\>.

## SEE ALSO

GeoIP C API documentation \<www.maxmind.com\>
