Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

ShowIP

Portable IPv4 detection tool for Unix-like systems

License POSIX Shell Platform


Overview

ShowIP is a lightweight, portable, and POSIX-compliant shell tool that detects your public and local IPv4 addresses.

It is designed to work across multiple Unix-like systems including Linux, BSD, and macOS, while keeping dependencies minimal.

The script automatically detects available networking utilities (curl, wget, or fetch) and uses multiple IP services as failover providers to ensure reliable results.

ShowIP is particularly useful for:

  • shell scripts
  • automation workflows
  • system diagnostics
  • DevOps tooling
  • CI/CD environments

Features

  • Detect Public IPv4
  • Detect Local IPv4
  • Automatic failover between multiple IP providers
  • POSIX compliant shell script
  • Extremely lightweight
  • Zero external dependencies required
  • Works on Linux, BSD, and macOS
  • Optional JSON output for scripting
  • VM / container safe local IP detection

Table of Contents


Installation

Clone the repository

git clone https://github.com/korayustundag/showip.git
cd showip
chmod +x showip

Install globally (recommended)

sudo install -m 755 showip /usr/local/bin/showip

Now you can run it anywhere:

showip

Download manually

curl -O https://raw.githubusercontent.com/korayustundag/showip/main/showip
chmod +x showip

Usage

showip [options]

Options

Option Description
-l Show only local IP
-p Show only public IP
-j JSON output
-h Display help

Examples

Show both public and local IP

showip

Example output:

Public IPv4 : 13.107.213.60
Local  IPv4 : 192.168.1.24

Show only public IP

showip -p

Example:

Public IPv4 : 13.107.213.60

Show only local IP

showip -l

Example:

Local  IPv4 : 192.168.1.24

JSON output

showip -j

Example:

{
  "public_ipv4": "13.107.213.60",
  "local_ipv4": "192.168.1.24"
}

This is useful for:

  • shell scripting
  • monitoring tools
  • automation pipelines

Output Formats

Human readable

Public IPv4 : 13.107.213.60
Local  IPv4 : 192.168.1.24

JSON

{
  "public_ipv4": "13.107.213.60",
  "local_ipv4": "192.168.1.24"
}

How It Works

Public IP Detection

ShowIP queries several IP detection services sequentially:

If one service fails or times out, the script automatically falls back to the next provider.


Local IP Detection

Instead of parsing raw ifconfig output (which is unreliable across platforms), ShowIP determines the active interface using routing information.

Linux

Uses:

ip route get <target>

BSD / macOS

Uses:

route -n get <target>
ifconfig

This routing-based detection is more reliable and works properly inside:

  • Virtual Machines
  • Containers
  • NAT environments

Portability

ShowIP is designed to be fully portable across Unix-like systems.

Supported platforms:

  • Linux
  • FreeBSD
  • OpenBSD
  • NetBSD
  • macOS

The script is written using POSIX shell, avoiding Bash-specific features.


Dependencies

ShowIP automatically detects one of the following tools:

Tool Purpose
curl HTTP requests
wget HTTP requests
fetch HTTP requests (BSD systems)

Only one of these tools is required.


Security Considerations

  • Only trusted public IP detection services are used.
  • HTTP requests are performed with timeouts to avoid hanging processes.
  • Output is validated to ensure valid IPv4 addresses.
  • No sensitive information is stored or transmitted.

Contributing

Contributions are welcome.

You can contribute by:

  • reporting bugs
  • suggesting improvements
  • submitting pull requests
  • improving documentation

Please open an Issue before submitting major changes.


License

This project is licensed under the BSD 2-Clause License.

See the LICENSE file for details.


Author

Koray Üstündağ


Support

If you find this project useful, consider:

⭐ Starring the repository

🐛 Reporting issues

🔧 Contributing improvements

About

Portable POSIX shell tool to detect public and local IPv4 addresses on Linux, BSD and macOS with automatic failover and JSON support.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages