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'
Another way
curl ipinfo.io