Check the external / public IP of the server

To view the external / public IP of the server, you may use the following command.

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

You may put the following in your own shell script in order to make use of value of the external / public IP.

#!/usr/bin/env bash
myip="$(dig +short myip.opendns.com @resolver1.opendns.com)"
echo "My External/Public IP address: ${myip}"

Tags: No tags

Add a Comment

You must be logged in to post a comment