Use one of the following commands to check your public IP address from the Linux command line.
Get the Public IP address from the Linux Command Line
0. Easy to Remember Services
Get your external IP address using the curl
command:
$ curl ifconfig.me $ curl ip.appspot.com $ curl icanhazip.com
Get your external IP address using the wget
command:
$ wget -q -O - ifconfig.me $ wget -q -O - ip.appspot.com $ wget -q -O - icanhazip.com
Get the External IP address using DynDNS.org
1. Using the wget command:
$ wget -q -O - checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
2. Using the curl command:
$ curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
3. Using the lynx command:
$ lynx -dump checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' | sed '/^$/d'
curl ipinfo.io
ip.appspot.com was in google cloud, and went away.
Here are 11 confirming sites I’ve found:
# ~/bin/.bash/.ifaces https://pastebin.com/DiPUdqPJ
myip() {
( for site in ipaddr.pub/cli ipecho.net/plain icanhazip.com ifconfig.me \
ipconfig.in/ip ident.me bot.whatismyipaddress.com diagnostic.opendns.com/myip \
checkip.amazonaws.com whatismyip.akamai.com
do echo “$site ”
wget -qO- $site
echo
done
wget -qO- checkip.dyndns.org |\
sed -n -E ‘/IP Address/s/^.*:[\t ]+([^<]+).*$/checkip.dyndns.org \n\1/p' ) |\
sed -n -E '/^$/d;H;${g;s/^[\n]+//;s/( )\n/ /g;p;}'
wget -qO- ipinfo.io | sed '1s/.*/ipinfo.io:/;$d;'
}