IP address

Hi All,

I logged into to a unix machine, from $ prompt what should I type to get IP address of that machine?

Thanks inadvance,

Krishna

netstat is a good start. I don't know much about what it will tell you or the options running it. Try it and see. Hopefully someone else will have more information for you.

Try typing ifconfig, then enter.
If it doesn't find that command, you'll have to specify the whole path. For example, you might have to enter "/sbin/ifconfig".
You should get something similar to the following:

You'll notice that there are two entries - one for each interface. The first one is eth0, my primary (and only) ethernet interface. In that block, a field named "inet addr" shows the ip address, in my case, 10.2.9.122.
The second block is lo, the loopback interface. It doesn't physically exist, but nearly every system should have one. It's address will always be 127.0.0.1.
Note that there may be more than one "real" interface. A single machine can technically have 255 (i think) IP addresses assigned to it.

By the way, your interface names may vary. This one is from a Linux box connected via ethernet.

The easiest thing is:
uname -a and you will see the name of your machine
then ping namemachine
or grep namemachine /etc/hosts
That's it!

You could also do it in 2 steps :wink:

#1 Type hostname
#2 nslookup (hit enter, then type the hostname or fully qualified hostname from #1)

Sometimes an `ifconfig` with no switches is not enough.

On my OpenBSD2.9 machine I have to either specify the individual nic or the "-a" switch to display all adapters. Oddly enough, the lone `ifconfig` is sufficient under FreeBSD4.5 to display all adapters and settings.

Yup thats right
SOlaris takes a option -a to ifconfig
but IRIX needs to be passed its network interface as the argument , no -a works with it

nslookup is a good option too

But i would rather prefer vi /etc/hosts

the ifconfig and netstat commands are restricted to common users.
try $ cat /etc/hosts

chau

U can use userconf to get the ip address

Woe Woe Woe...

You guys got me confused /!\

"ifconfig -a" is fine...

If no IP - "dhcpcd eth0" to get one from your ISP.

Or make up your own "ifconfig eth0 192.168.1.1 up".

Hi,

You can try this...

ifconfig -a | tail -1 | awk '{print $2}'

Nicolas.
France