PDA

View Full Version : Command to show/discover Linux server public IP address



Fli
11-11-2014, 03:52 PM
Hello,

how on any Linux distribution i can get an IP address of the server i am working on? Which command to use , how to discover server IP on Linux?

i mean by command and output is plain IP not anything else..

Update:

working for VPS & dedi:

hostname -i
curl -L http://myip.dnsomatic.com
curl -L http://cpanel.net/showip.shtml

this worked on dedi servers:

/sbin/ifconfig|grep inet|sed 's/\:/ /'|awk 'NR==1 {print $3}'

Works for VPS & dedi and is independent, default Linux based:

ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'|head -n 1

Hostfinch
07-20-2018, 11:11 AM
You can use this command:
dig +short myip.opendns.com @resolver1.opendns.com