How To Find My Public IP Address From Linux CLI

Here are a few ways to find your public IP address from the Linux command line interface (CLI):

  1. Use curl:
    curl ifconfig.co
  2. Use dig:
    dig +short myip.opendns.com @resolver1.opendns.com
  3. Use wget:
    wget -qO- http://ipecho.net/plain
  4. Use ip command:
    ip addr show dev eth0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1

Note: Replace eth0 with your actual network interface name, if it’s different.

(beckerentandallergy.com)

Leave a Comment