get ip ubuntu code example
Example 1: ubuntu check public ip command line
dig +short myip.opendns.com @resolver1.opendns.com
host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'
wget -qO- http://ipecho.net/plain | xargs echo
wget -qO - icanhazip.com
curl ifconfig.co
curl ifconfig.me
curl icanhazip.com
Example 2: check ip json
$ curl 'https://api.ipify.org?format=json'
{"ip":"51.159.59.56"}
Example 3: ip address ubuntu
ip address show
Example 4: how to get ip address in ubuntu
Open your command prompt and type following command shown below and press enter
ifconfig -a