Saturday 19 July 2014

Check your Public IP address Geo Location using the command line on Linux




If you are using VPN connections it can be important and useful to be able to check your current public IP. For me going to one of the many web sites that offer such a service is slow. As always on Linux the command line is the fastest way. Searching around I found geoiplookup which did exactly what I wanted. It uses the GeoIP library and database to find the Country that an IP address or hostname originates from.

Example

$ geoiplookup 80.60.233.195


Displays the country that 80.60.233.195 originates from e.g.

NL, Netherlands


You can have a simple bash script like :

#!/bin/bash
clear
echo "Current Public IP is :"
curl -s checkip.dyndns.org | sed 's/.*IP Address: \([0-9\.]*\).*/\1/g'
sleep 1
PUBLICIP=$(curl -s checkip.dyndns.org | sed 's/.*IP Address: \([0-9\.]*\).*/\1/g')
geoiplookup $PUBLICIP


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

1 comment:

  1. Caesars Rewards Casino App for US Players in 2021 - MJH Hub
    Download Caesars Rewards Casino App 세종특별자치 출장안마 on your iOS or Android device. The app 청주 출장마사지 is the only app currently available in 천안 출장샵 the Casino 제천 출장마사지 Rewards program. The app  Rating: 4.8 · ‎10 reviews · 이천 출장샵 ‎Free · ‎iOS · ‎Entertainment

    ReplyDelete