Here are some ways to get your external IP using command-line.

  • IP returned as text:
curl -sS http://icanhazip.com/
curl -sS http://checkip.amazonaws.com/
curl -sS http://whatismyip.akamai.com/
curl -sS -k https://diagnostic.opendns.com/myip
curl -sS http://ifconfig.me/ip
curl -sS http://ident.me/
curl -sS http://myip.dnsomatic.com/
curl -sS http://ip4.me/api/ | cut -d, -f2
  • IP buried in webpage:
lynx -dump http://ip4.me/ | sed -ne '/You are connecting with an IPv4 Address of/ {n;p}'
lynx -dump http://checkip.dyndns.org/ | awk '/Current IP Address:/ {print $NF}'
lynx -dump http://ipchicken.com/ | awk '/Name Address:/ {print $NF}'
lynx -dump http://monip.org/ | awk '/IP :/ {print $NF}'
lynx -dump http://www.myipaddress.com/ | sed -ne "/Your computer's IP address is:/ {n;n;p}"
  • Special DNS query:
dig @resolver1.opendns.com myip.opendns.com +short
  • user/william/getting_external_ip.txt
  • Last modified: 23 months ago
  • by 198.52.186.162