Getting your Public IP from the Terminal

Public IPv4 addresses are assigned by NIC and belong to CIDR blocks that are unique to the entire internet.

In this little post, I show many ways to find your public IP address form the Linux terminal.

Using Curl

You can curl it from IP websites:

$ curl

You might want to get more details (such as remote_host) with:

$ curl

Other destination that also works: Curling is also great to get information about the Geographical Location of a provided IP address.

Using wget

Similarly to curl:

$ wget -O - -q ; echo

Using dig and host

Another nice way to find the IP:

$ host -t a | sed 's/.*has address //'
dig +short

If you use DynDNS

Finally, if you have a DynDNS configuration:

$ curl -s | grep -o "[[:digit:].]\+"