How to query public IP Address on Linux
An Internet Protocol address (IP address) is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. An IP address serves two main functions: host or network interface identification and location addressing.
How to query public IP Address on Linux
- Using curl
+ Plain text formatted output
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
- Use wgetwget http://ipecho.net/plain -O – -q ; echo
wget http://observebox.com/ip -O – -q ; echo - Use host or dighost -t a dartsclink.com | sed ‘s/.*has address //’
dig +short myip.opendns.com @resolver1.opendns.com - Use bash#!/bin/bash PUBLIC_IP=`wget http://ipecho.net/plain -O – -q ; echo` echo $PUBLIC_IP
- Use netcatnetcat icanhazip.com 80 <<< $’GET / HTTP/1.1\nHost: icanhazip.com\n\n’ | tail -n1