CentOSDebianFedoraHow ToLinuxOperating SystemsRedHatUbuntu

[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!

Related Articles

4 Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button