Home Linux Tips & Tricks Geo – A Simple BASH Utility To Get Network And Geolocation Details In Linux

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

By sk
Published: Last Updated on 1.4K views

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". Geo is used to display wan, lan, router, dns, mac address, and geolocation output, with clean stdout for piping.

Install Geo In Linux

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

$ yay -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 below.

Get Network and Geolocation Details using Geo

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.

Resource:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More