Uncategories

Finding external IP using external services

curl icanhazip.com

or

curl ipecho.net

or

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

How do I store my IP address in a shell variable?

The syntax is:

myip=”$(dig +short myip.opendns.com @resolver1.opendns.com)”
echo “My WAN/Public IP address: ${myip}”

Sample outputs:

My WAN/Public IP address: 74.86.144.194

Refer: https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s