Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I find out my IP address on a unix box? I've tried

ifconfig

but it doesn't exist on the system.

share|improve this question
    
Did you try as root? Also what OS? –  Adam Jul 15 '09 at 16:41

3 Answers 3

up vote 12 down vote accepted

ifconfig is usually in /sbin. Depending on what system you're running this mightn't be on your path (in particular, RedHat systems don't include this on the default path)

Try:

$ /sbin/ifconfig

If it works then that's the issue, and you should change your path via your .bashrc (or whatever shell you're using).

export PATH=$PATH:/sbin:/usr/sbin
share|improve this answer
    
Thanks - it was indeed there –  jjujuma Jul 15 '09 at 16:43
1  
Some unix variants need the "-a" option passed to ifconfig to get informative output. –  freiheit Jul 15 '09 at 16:48

I would suggest looking at the host command. Of course, you will have to specify the name of the machine that you are on.

share|improve this answer
2  
This makes the assumption that the computer is on the internet, not behind NAT, has a working DNS server configured, and a hostname. If you're on a TCP/IP network that isn't connected to the internet, then this won't work. –  Ernie Jul 15 '09 at 17:43

If you are behind some sort of NAT device, that device probably has an http interface that provides this information. First, find out its IP address either from the documentation or from the output of the route command. There should be a line that looks like this:

default         192.168.2.1     0.0.0.0         UG    0      0        0 ath0

Then connect to that IP address with your browser and see what you can find out. The rest depends on what kind of NAT device you're using.

share|improve this answer

Your Answer

 
discard

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