linux,

Get public IP from the CLI on Linux

Oct 16, 2021 · 1 min read · Post a comment

Let’s speedrun the tutorial on how to get your public IP address from the command line interface for any whitelisting reason, on any Linux distro.

Prerequisites

  • Linux bash environment

Using curl command

curl ifconfig.me

Output:

66.249.70.54

Most popular alternatives to ifconfig.me:

  • ifconfig.co
  • ifconfig.io
  • checkip.amazonaws.com
  • whatismyip.akamai.com
  • ipinfo.io

…and dozens more.

Using dig command

dig +short myip.opendns.com @resolver1.opendns.com

Output:

66.249.70.54

Conclusion

Personally I always stick with curl and ifconfig.me. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.