• IP addresses are unique identifiers used to determine who is who on the Internet.
  • IP addresses can be formatted differently depending on whether they use IPv4 or IPv6 protocol.

Using curl

curl ifconfig.co
echo $(curl -s api.ipify.org)
echo $(curl -s ipaddress.sh)
echo $(curl -s ipinfo.io/ip)

Using dig

dig +short myip.opendns.com @resolver1.opendns.com
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}'

References