Saturday, 19 July 2014
Check your Public IP address Geo Location using the command line on Linux
$ geoiplookup 22.214.171.124
Displays the country that 126.96.36.199 originates from e.g.
You can have a simple bash script like :
echo "Current Public IP is :"
curl -s checkip.dyndns.org | sed 's/.*IP Address: \([0-9\.]*\).*/\1/g'
PUBLICIP=$(curl -s checkip.dyndns.org | sed 's/.*IP Address: \([0-9\.]*\).*/\1/g')
To install on Arch :
$ sudo pacman -S geoip
To install on Ubuntu, Linux Mint or Debian
$ sudo apt-get install geoip-bin
By default the IP to country database is located at /usr/share/GeoIP/GeoIP.dat