How To Find My Public IP Address From Command Line On a Linux


Originally published at:

How do I find out my public IP address on the Linux and OS X Unix command line to use with my own bash shell script without using third party web site? Is there command-line option which will show my dynamic IP address on a Ubuntu or Fedora Linux?


I use this command:

wget -qO -

Example output:

[root@BERTHA ~]# wget -qO -


For that : open the terminal and type “curl

  1. dig +short
    Does anyone care to elaborate on whats exactly happening in this? I guessing myip is being passed as a host name? to opendns and its resolver?

appreciate the lesson.


yes, always returns your IP address when request sent to opendns resolver will always have 0 ttl, that way it can not cached by any dns client and provides visitors true IP address using nothing but standard dns command line.