Several ways to query the IP of the extranet under Linux. Curl Plain Text Format output:
curl icanhazip.comcurl ifconfig.mecurl curlmyip.comcurl ip.appspot.comcurl ipinfo.io/ipcurl ipecho.net/plaincurl 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 gets all IP details (excavator)
curl ifconfig.me/all
Use Dydns (useful when you use the 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 ; echowget http://observebox.com/ip -O - -q ; echo
Using the host and Dig commands
If so, you can also use the host and dig commands directly.
host -t a dartsclink.com | sed ‘s/.*has address //‘dig +short myip.opendns.com @resolver1.opendns.com
Bash Script Example:
#!/bin/bashPUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`echo $PUBLIC_IP
Several ways to query the IP of the extranet under Linux.