How to Get Public IP from Terminal on Linux Ubuntu



How to Get Public IP from Terminal on Linux Ubuntu

How to Get Public IP from Terminal on Linux Ubuntu

In this video we’re going to learn how to retrieve the public IP address of your Linux Ubuntu 22.04 machine right from the terminal. Knowing your public IP can be useful for various networking tasks, such as setting up a server, accessing remote services, or troubleshooting connectivity issues.

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