Search Posts

How to find Public IP Address on Linux?

There are many ways to find public IP address on Linux.Here Step by Step instruction to find public ip on linux.
What is IP Address?

An IP address is used to identify devices.Each device is connected through an IP address.

Dig command is a network administrator command line tool for determining public IP address and for network troubleshooting. To find a public IP address, open your terminal application on Linux and enter the following command

$ dig +short

The output will be like

Find IP address using Host Command:-

$ host

The output will be like as bellow

Using domain server:
Aliases: has address

Find IP address using Google Server:-

$ dig TXT +short | awk -F'"' '{ print $2}'

The output will be like as bellow

Store IP address in a shell variable:-
The bellow command is used to store the IP address in a shell variable

$ myip="$(dig +short"
$ echo "My WAN/Public IP address: ${myip}"

The output will be like as bellow

My WAN/Public IP address:

Leave a Reply

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

Social media & sharing icons powered by UltimatelySocial

Enjoy this blog? Please spread the word :)