Here are a few ways to find your public IP address from the Linux command line interface (CLI):
- Use curl:
curl ifconfig.co
- Use dig:
dig +short myip.opendns.com .opendns.com
- Use wget:
wget -qO- http://ipecho.net/plain
- 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.