linux,

Get Public IP from CLI on Linux

Oct 16, 2021 · 1 min read · Post a comment
Get Public IP from CLI on Linux

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

  • Access to Linux bash environment

Using curl command

$ curl ifconfig.me

Example output:

66.249.70.54

Most popular alternatives to ifconfig.me:

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

…and a dozen others.

Using dig command

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

Example 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.