Curl plain text output:
curl icanhazip.com 69.162.69.148
curl ifconfig.me 153.121.72.211
curl curlmyip.com
curl ip.appspot.com
curl ipinfo.io/ip
curl ipecho.net/plain
curl www.trackip.net/i
curl JSON format output:
curl ipinfo.io/jsoncurl ifconfig.me/all.jsoncurl www.trackip.net/ip?json (有点丑陋)
curl XML format output:
curl ifconfig.me/all.xml
curl to get all IP details (digger)
curl ifconfig.me/all
Use DYDNS (useful when you use DYDNS service)
curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
curl -s http://checkip.dyndns.org/ | grep -o "[[:digit:].]\+"
Use Wget instead of Curl
wget http://ipecho.net/plain -O - -q ; echo
wget http://observebox.com/ip -O - -q ; echo
Using the host and dig commands
You can also use the host and dig commands directly, if available.
host -t a dartsclink.com | sed 's/.*has address //'
dig +short myip.opendns.com @resolver1.opendns.com
Example bash script:
#!/bin/bash
PUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`
echo $PUBLIC_IP