Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I think there used to be a command to do that but I forget.

Something like ipconfig in windows.

My server has 10 available IPs and I want to know them all.

share|improve this question
1  
ifconfig or ip a s –  Ulrich Dangel Mar 18 '13 at 5:03
    
@UlrichDangel The Q&A is simple, but that is still the answer. –  jordanm Mar 18 '13 at 5:10
    
ip r l .......... :) –  Rahul Patil Mar 18 '13 at 8:02
    
@jordanm i couldn't really believe it and didn't feel like writing a lot of text around it. –  Ulrich Dangel Mar 18 '13 at 11:16
    
@UlrichDangel I would have just pasted some example output to "pad" the answer. –  jordanm Mar 18 '13 at 15:06
add comment

4 Answers

up vote 3 down vote accepted

if you are only interested in the IP addresses but not the other gory details about the network interfaces, /sbin/ifconfig -a | grep "inet addr:" |awk '{print $2}'|cut -d: -f2 gives you all the ip addresses configured on all network interface cards and nothing else.

share|improve this answer
    
This works perfectly. –  Jim Thio Mar 18 '13 at 11:54
    
grep | awk | cut is pretty bad. awk can do the job of all 3 of those tools. –  jordanm Mar 18 '13 at 15:06
add comment

Below are some command to extract only IP addresses :

ifconfig | awk -F':' 'NR==2{split($2,a," "); print a[1]}'

ip -f inet addr show dev eth0 | sed -n 's/^ *inet *\([.0-9]*\).*/\1/p'

ifconfig eth0 | sed -n 's/^ *inet addr:*\([.0-9]*\).*/\1/p'

To check Public IP

curl ifconfig.me
share|improve this answer
    
This is actually the most complete solution. However, I've tried and tested Mel's solution. –  Jim Thio Mar 18 '13 at 8:11
add comment

/sbin/ifconfig -a 'll show you your network interface(s) with details including the IP address.

share|improve this answer
add comment
ifconfig

if you have a problem, try

man ifconfig
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.