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 Reset Password Root Alma Linux

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.

Centos Failed Update Kernel

Today I did a kernel update on my server with Centos 7 OS. At the end of the update process, I found a kernel...
habibzain
1 min read

Easy Fix Missing mirrorlist http://mirrorlist.centos.org on CentOS 7

When running yum update or command that utilize the yum system, errors similar to the following are produced: If you’re encountering issues with the...
habibzain
1 min read

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

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