Quick Tip: Get or Find your Public IP Address using curl

Some sample websites that you can use with curl to display your external public IP. As you know, especially if you are connected to a router, it will provide you private IP via the DHCP and it is NAT’ed. So using ‘ifconfig’, ‘ip addr show’, ‘hostname -I’ or via the GUI won’t show the public IP.

curl icanhazip.com
curl ifconfig.me
curl ipecho.net/plain ; echo
curl ident.me ; echo
curl checkip.amazonaws.com
curl bot.whatismyipaddress.com ;echo
curl myexternalip.com/raw
curl whatismyip.akamai.com ; echo
curl myip.dnsomatic.com;echo
curl -s ipinfo.io | jq .ip #need to install jq

Or you want to challenge yourself, you can combine it with sed to do some filtering:

curl -s checkip.dyndns.org | sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’

About the author

Free Linux

View all posts

1 Comment

Leave a Reply