Get Public IP Address in Linux

When troubleshooting network connectivity issues, may be helpful to know public IP address of the machine. A public IP address is an IP address that is used for communication between hosts over the Internet. A public address is assigned to the home's network by the ISP. This tutorial shows how to get public IP address in Linux.

One of the fastest and recommended way to get public IP address of Linux system, get it directly from a DNS server. Use dig command with an OpenDNS resolver to get public IP address:

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

Leave a Comment

Your email address will not be published.