Saturday, 19 July 2014
Check your Public IP address Geo Location using the command line on Linux
$ geoiplookup 220.127.116.11
Displays the country that 18.104.22.168 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