[How To] Find internal/external/public IP address on Linux

Share with all..

While working from shell with no GUI, you may need to check server internal & external / public IP address.
This can be achieved using simple commands as below:

To check server internal IP address:

/sbin/ifconfig |grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }'

To check server external / public IP address:

Install Curl package on your server before executing below command.

curl ifconfig.me


curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/< .*$//'

That's All!

Share with all..

About Abhijit Sandhan

Loves Open Source, Blogging, Traveling, Hiking and sharing Knowledge!


  1. Type simply: curl icanhazip.com

    Best Regards

Leave a Reply

Your email address will not be published. Required fields are marked *