Geo – A Simple BASH Utility To Get Network And Geolocation Details

Geo - A Simple BASH Utility To Get Network And Geolocation Details

A while ago, we wrote a blog post about “Bash-Snippets”, a set of BASH scripts for heavy command-line users. Those scripts consists of many useful utilities such as crypt, geo, cheat, weather, ytview and more. Using bash-Snippets, you can install all utilities or a particular one. In this brief guide, we are going to discuss about only one utility in the Bash-Snippets called “Geo”. It is used to display wan, lan, router, dns, mac address, and geolocation output, with clean stdout for piping.

Install Geo

On Arch Linux and its derivatives, geo is available in AUR. So, you can install it using any AUR helper programs such as Pacaur, Yaourt, Packer etc.

pacaur -S geo-bash

Or,

yaourt -S geo-bash

Or,

packer -S geo-bash

In the other distributions, you can install Geo either using “Bash-Snippets” as described in the installation section. Or, directly download it from here and manually compile and install it. Please note that the Geo utility we are talking about here is same as in the Bash-Snippets. If you have already installed it from bash-Snippets, just skip the installation part and go to the Geo Usage section.

Geo Usage

Let us now see the usage of Geo utility.

To display your local IP address, run:

$ geo -l
192.168.43.192

To view the wan IP, use -w flag.

$ geo -w
43.210.233.112

To check the DNS:

$ geo -d
192.168.43.1

Check Mac address of your network interface card:

$ geo -m enp5s0
28:c6:gd:57:6b:32

Here, enp5s0 is my Ethernet card.

Also, you can combine all flags in one command like below. The following command will display your LAN, WAN ip, DNS, and Mac id.

$ geo -lwdm enp5s0
43.210.233.112
192.168.43.192
192.168.43.1
28:c6:gd:57:6b:32

To display the gelocation, run:

$ geo -g
India
TN
Chennai

Vodafone India
43.210.233.112

To view the help section, just type “geo”:

$ geo
Geo
Description: Provides quick access for wan, lan, router, dns, mac, and ip geolocation data
Usage: geo [flag]
 -w Returns WAN IP
 -l Returns LAN IP(s)
 -r Returns Router IP
 -d Returns DNS Nameserver
 -m Returns MAC address for interface. Ex. eth0
 -g Returns Current IP Geodata
Examples:
 geo -g
 geo -wlrdgm eth0
Custom Geo Output =>
[all] [query] [city] [region] [country] [zip] [isp]
Example: geo -a 8.8.8.8 -o city,zip,isp
 -o [options] Returns Specific Geodata
 -a [address] For specific ip in -s
 -v Returns Version
 -h Returns Help Screen
 -u Updates Bash-Snippets

Hope this helps. More good stuffs to come. Stay tuned!

Cheers!

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You may also like...