If you don’t have curl installed, just enter following command:
For Ubuntu, Linux Mint or other Debian based systems:
sudo apt-get install curl
For Fedora, CentOS or other RHEL based systems:
sudo yum install curl
Once this is done, you can use any of the following commands listed below to get your public IP address. You can run them in terminal or you can also use them in bash scripts. Here is the list:
curl ident.me
curl ifconfig.me
curl tnx.nl/ip
curl icanhazip.com
curl ipecho.net/plain
curl ip.appspot.com
curl whatsmyip.akamai.com
First posted on http://www.yourownlinux.com/
Alternative DIG
As alternative you could use dig
with OpenDNS as resolver:
dig +short myip.opendns.com @resolver1.opendns.com
Perhaps alias it in your bashrc
so it’s easy to remember
alias wanip='dig +short myip.opendns.com @resolver1.opendns.com'
Responds with a plain ip address:
$ wanip
80.100.192.168
Article sponsored by Lowhosting.com
Leave a Reply