geoiplookup command is to get the Country that an IP address or Hostname use the GeoIP library and database. These online services and its freely available GeoIP databases such as those from MaxMind. 

Ubuntu/Debian :

#  apt-get install geoip-bin geoip-database


Fedora/CentOS/RHEL:
 
# yum install GeoIP GeoIP-data

If you have missed .dat file package download GeoIP Database from Maxmind and extract to that default location,
 
# cd /usr/local/share/GeoIP

# wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

# wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

# wget -N http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz

# gunzip GeoIP.dat.gz

# gunzip GeoIPASNum.dat.gz

To ensure your .dat file available on specific location,
 
# gunzip GeoLiteCity.dat.gz

-rwxr-r-- 1 root root  3905950 Jan  5 18:26 GeoIPASNum.dat
-rwxr-r-- 1 root root  1183408 Jan  4 20:34 GeoIP.dat
-rwxr-r- 1 root root 27428736 Dec 11  2012 GeoLiteCity.dat


Once you have installed GeoIP default .dat file location is /usr/local/share GeoIP/

The following command show information of IP address is physically located on earth, Country, ISP provider, IP location and etc.
 
# geoiplookup -f /usr/local/share/GeoIP/GeoIP.dat 4.2.2.2
GeoIP Country Edition: US, United States


-f     Specify a custom path to a single GeoIP datafile.
 
# geoiplookup -f /usr/local/geoip/share/GeoIP/GeoIP.dat 8.8.8.8
GeoIP Country Edition: IN, India

 
# geoiplookup 4.2.2.2
GeoIP Country Edition: US, United States

 
# geoiplookup /usr/local/geoip/share/GeoIP/GeoLiteCity.dat  4.2.2.2
GeoIP Country Edition: US, United States
GeoIP ASNum Edition: AS3356 Level 3 Communications, Inc.