Public addresses are assigned past times InterNIC together with consist of class-based network IDs or blocks of CIDR-based addresses (called CIDR blocks) that are guaranteed to live globally unique to the Internet. 
There’s 2 chief commands nosotros use, gyre together with wget. You tin purpose them interchangeably.
Curl output inwards evidently 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 output inwards JSON format:
curl ipinfo.io/json
curl ifconfig.me/all.json
curl www.trackip.net/ip?json (bit ugly)
curl output inwards XML format:
curl ifconfig.me/all.xml
curl all IP details – The motherload
curl ifconfig.me/all
Using DYNDNS (Useful when you’re using DYNDNS 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:].]\+"
Using wget instead of curl
wget http://ipecho.net/plain -O - -q ; echo
wget http://observebox.com/ip -O - -q ; echo
Using host together with dig ascendancy (cause nosotros can)
You tin also purpose host together with dig ascendancy assuming they are available or installed
host -t a dartsclink.com | sed 's/.*has address //'
dig +short myip.opendns.com @resolver1.opendns.com
Sample bash script:
#!/bin/bash
PUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`
echo $PUBLIC_IP
Quite a few to alternative from.
I was genuinely writing a modest script to rails all the IP changes of my router each solar daytime together with salve those into a file. I constitute these groovy commands together with sites to purpose land doing to a greater extent than or less online research. Hope they help somebody else someday too. Thanks for reading, delight Share together with RT.
