Several ways to query public IP Address on Linux
- Using curl
+ Plain text formatted output
+ JSON formatted output
+ XML formatted output
+ Get all the IP details
- Use wget
- Use host or dig
- Use bash
- Use netcat
by do son ·
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
+ JSON formatted output
curl ipinfo.io/json
curl ifconfig.me/all.json
curl www.trackip.net/ip?json
+ XML formatted output
curl ifconfig.me/all.xml
+ Get all the IP details
curl ifconfig.me/all
wget http://ipecho.net/plain -O - -q ; echo
wget http://observebox.com/ip -O - -q ; echo
host -t a dartsclink.com | sed 's/.*has address //'
dig +short myip.opendns.com @resolver1.opendns.com
#!/bin/bash
PUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`
echo $PUBLIC_IP
netcat icanhazip.com 80 <<< $'GET / HTTP/1.1\nHost: icanhazip.com\n\n' | tail -n1
Tags: ip address