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!
Type simply: curl icanhazip.com
Best Regards
Hi,
Thanks for the comment.
Curl will fetch the complete page instead of just providing the website IP address.
Please try it. icanhazipDOTcom shows only your IP and nothing else.
Best Regards
Giuseppe
yes, curl works for icanhazipDOTcom domain.
Thanks for your inputs and feedback.