How to know my public IP in terminal

Hi everybody, today i share a simple list for get your public IP in linux command line.

First command, check your IP using dyndns service is very long command.

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

This is short command and very easy to remember.


Ipify is the same than ifconfig but response is in JSON format, prefer for webservices or other apps.

curl ''

Mi favorite is this command, is very elegant only send a request to obtain IP using DNS server.

dig +short

Other command is the same that others.


For to use this commands you need to install curl and dig packages.

For use curl install sudo aptitude install curl

For use dig install sudo aptitude install dnsutils