Detailed explanation of several Linux query exportation IP command method
- 2020-05-27 07:57:01
- OfStack
Curl output in plain text format:
curl icanhazip.com
curl ifconfig.me
curl curlmyip.com
curl ip.appspot.com
curl ipinfo.io/ip
curl ipecho.net/plain
curl www.trackip.net/i
curl JSON output:
curl ipinfo.io/jsoncurl ifconfig.me/all.jsoncurl www.trackip.net/ip?json
Output in curl XML format:
curl ifconfig.me/all.xml
curl gets all IP details (excavator)
curl ifconfig.me/all
Use DYDNS (useful when you use DYDNS services)
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
Use 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
Example bash script:
#!/bin/bash
PUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`
echo $PUBLIC_IP