Create Your Own IP Geolocation Tool in Termux

IP geolocation tools are used to find basic information about an IP address like country, region, city, ISP, and more. In this post, you will create your own simple IP geolocation tool in Termux using the Go programming language. It runs on any Linux terminal and displays IP information in a clean format with a hacker-style banner.

Hereโ€™s what you can do with this tool:

  • Get IP address details
  • Find country and city information
  • Identify ISP details
  • Learn basic Go programming
  • Build your own CLI tool in Termux
  • Understand API-based data fetching

Create Your Own IP Geolocation Tool

Below are the simple commands to create the IP geolocation tool in Termux. Copy and run each command step by step.

Update Termux packages.

pkg update && pkg upgrade -y

Install Go language.

pkg install golang -y

Create project directory.

mkdir ipgeo && cd ipgeo

Initialize Go module.

go mod init ipgeo

Create the main file.

nano main.go

Paste the full code below into the file.

package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

type GeoData struct {
	Query      string `json:"query"`
	Country    string `json:"country"`
	RegionName string `json:"regionName"`
	City       string `json:"city"`
	ISP        string `json:"isp"`
}

func banner() {
	green := "\033[32m"
	cyan := "\033[36m"
	yellow := "\033[33m"
	reset := "\033[0m"

	fmt.Println(green + "โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— " + reset)
	fmt.Println(green + "โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ• โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—" + reset)
	fmt.Println(green + "โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘" + reset)
	fmt.Println(green + "โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ• โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘" + reset)
	fmt.Println(green + "โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘     โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•" + reset)
	fmt.Println(green + "โ•šโ•โ•โ•šโ•โ•      โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• " + reset)

	fmt.Println(cyan + "========================================" + reset)
	fmt.Println(yellow + "      IP GEOLOCATION TOOL v1.0" + reset)
	fmt.Println(cyan + "========================================" + reset)
	fmt.Println()
}

func main() {
	banner()

	if len(os.Args) < 2 {
		fmt.Println("Usage: ipgeo <ip-address>")
		return
	}

	ip := os.Args[1]
	url := "http://ip-api.com/json/" + ip

	resp, err := http.Get(url)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	var data GeoData
	json.NewDecoder(resp.Body).Decode(&data)

	fmt.Println("RESULTS")
	fmt.Println("========================================")
	fmt.Println("IP      :", data.Query)
	fmt.Println("Country :", data.Country)
	fmt.Println("Region  :", data.RegionName)
	fmt.Println("City    :", data.City)
	fmt.Println("ISP     :", data.ISP)
	fmt.Println("========================================")
}

Save and exit nano.

To save the file:

  • Press CTRL + X
  • Press Y
  • Press Enter

Build the tool.

go build -o ipgeo

Usage Commands

You have successfully created your own IP Geolocation Tool in Termux, and now itโ€™s time to run and test it. Below are the commands you can use to execute the tool and get IP information from your terminal.

Run the tool with an IP address.

./ipgeo 8.8.8.8

Run another example.

./ipgeo 1.1.1.1

If no IP is provided, it will show help message.

./ipgeo

Example output:

โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ• โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—
โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ• โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘     โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•
โ•šโ•โ•โ•šโ•โ•      โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•
      IP GEOLOCATION TOOL v1.0

========================================
IP      : 8.8.8.8
Country : United States
Region  : California
City    : Mountain View
ISP     : Google LLC
========================================

Edit and Customize the Tool

You can modify or improve this IP geolocation tool anytime by editing the source file. You can add new features like more IP details, better UI design, or even different APIs.

Open the file again using nano:

nano main.go

Inside nano, you can edit the code as needed.

To save changes:

  • Press CTRL + X
  • Press Y
  • Press Enter

After saving, rebuild the tool:

go build -o ipgeo

This makes your updated version ready to run again.

End Note

This is a simple IP geolocation tool made in Termux. It helps you learn how APIs and Go programming work together. You can also improve it later by adding more features or changing the design.

SHARE THIS POST: