Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells, Featured

IP Geolocation from Shell

Submitted by on August 25, 2021 – 11:23 am

A handy utility by Rafael Rinaldi called whereami allows you to geolocate an IP address directly from the command line. Here are some quick notes on installing and using this tool.

I am using Ubuntu 18.04.5 LTS running under WSL2 so there were some pre-requisites I had to install: nvm, node.js, and npm. Here’s how to do this on Ubuntu:

get_latest_release() {
  curl --silent "https://api.github.com/repos/$1/releases/latest" | 
    grep '"tag_name":' |                                            
    sed -E 's/.*"([^"]+)".*//'                                    
}
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$(get_latest_release nvm-sh/nvm)/install.sh | sudo -E bash -
source ~/.bashrc
nvm ls
nvm install node --lts
node --verion
npm --version

Installing the whereami utility is easy:

npm install -g @rafaelrinaldi/whereami
command -v whereami

And here’s an example of how to use it with dig:

whereami $(dig +short kremlin.ru | head -1) -f human
#  Moscow, Moscow, Russia
whereami $(dig +short whitehouse.gov | head -1) -f human
#  United States

 

Print Friendly, PDF & Email

Leave a Reply