Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

I'm curious and I want to know all different methods for getting the IP address from a Linux box, I know ifconfig works well, but wondering if there are any other methods to use to obtain the ip address?

share|improve this question

marked as duplicate by HopelessN00b Feb 9 at 14:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

ifconfig is actually deprecated, and is replaced with the "ip" command. However many people (myself included) haven't quite got to grips with "ip" yet! –  Coops Sep 30 '09 at 12:49

6 Answers 6

up vote 8 down vote accepted

One way would be:

ip address list
share|improve this answer
or just 'ip addr' –  l0c0b0x Sep 30 '09 at 21:08

To find the external IP of a box (behind a NAT firewall for instance) try this one-liner:


So useful and so quick!

share|improve this answer
good to know, thanks! –  l0c0b0x Sep 30 '09 at 21:08

The ip tool is quite handy and can give you a bunch of methods for IP address determination and much more.

Quick exmaples:

ip addr show dev wlan0
ip route list | grep -w src | awk '{print "device:",$3, "address:",$9}'
share|improve this answer

I've used

hostname -i

But honestly I shouldn't because this relies on the /etc/hosts file of the machine and not the actual IP address.

share|improve this answer

You can use ping if you know the network interface. (eth0, eth1, wlan0, etc.)

ping -I eth0
ping [-I interface]


alt text

share|improve this answer

The following command will list all IP addresses

ip addr show

The output from ifconfig does not always show secondary addresses on interfaces which do not have a named alias, such as those added by "ip addr add"

share|improve this answer

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