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

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

or

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

That's All!

Share on Facebook3Share on Google+0Tweet about this on TwitterShare on StumbleUpon1Share on LinkedIn0Share on Tumblr0Pin on Pinterest0Email this to someonePrint this page

About Abhijit Sandhan

Abhijit Sandhan
Loves Linux, Blogging, Traveling, Hiking and sharing Knowledge!

4 comments

  1. Type simply: curl icanhazip.com

    Best Regards

Leave a Reply

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