habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Linux Show Public IP from Terminal

1 min read

IP address is unique protocol, that define address host or server. In this post is how to find out your own public IP address using command line options on an Ubuntu, Debian, CentOS Linux, macOS/OS X and Unix bash shell. A computer or server can be connected to other servers around the world because there is a public IP address and they are interconnected. This post explain about show public IP from terminal linux.

Why Need Know Public IP

Main reason why we need to know the public ip of our server is:

Troubleshooting.

Big reason is for troubleshooting. For example in cases like this.

There is a server using local ip address, under the NAT network. The server cannot access the API on the opposing server. Even though the original public server IP has been allowed or whitelisted.

This is important to know the public IP. Whether the public ip that is allowed for API access is correct or not. Perhaps we gave wrong information public IP to the API developer.

How to Know Public IP

Use Browser to Show Public IP

If our server supports the GNOME desktop and there is a browser, use a browser. Search google and Open url ip public check. Example https://whatismyipaddress.com

Use Terminal to Show Public IP

This is an option if we only have a terminal console available. Use several powerfull command in this sub section.

See also  Easy Uninstall amavisd-new On Ubuntu

1. Use Dig Command

Open the Terminal application. Type the following dig (domain information groper) command

dig +short myip.opendns.com @resolver1.opendns.com

or

dig TXT +short o-o.myaddr.l.google.com @ns1.google.com

Result output is :

Show Public IP Address from Terminal Linux

2. Use host command

host myip.opendns.com resolver1.opendns.com

3. Use the Google Server using dig

dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}'

That is simply method linux show public IP. Hope it’s helpful, please feel free to leave a comment if you have any questions and I’ll appreciate it. Or if there is another method to be able to show linux public ip, you can also add it in the comments, I will mention you and add a backlink to your website.

See you in the next article. Big thanks and bye.

habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox