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