This should be simple, but the machines we ssh into don't seem to have the regular commands.

Are there any other simple ways I can use to get my IP?

migrated from stackoverflow.com Apr 23 '10 at 3:45

This question came from our site for professional and enthusiast programmers.

  • 4
    tried /sbin/ifconfig ? – John Boker Apr 23 '10 at 3:05
  • Use an ioctl: mail.nl.linux.org/kernelnewbies/2003-05/msg00090.html – WhirlWind Apr 23 '10 at 3:07
  • I presume you need to get this programmatically, right, and you're not just trying to find out what the IP is? There are any number of ways to do either. – Devin Ceartas Apr 23 '10 at 3:14
  • I like how so many answers and comments offer ifconfig when the title says it's not working. However, instead of saying "not working" it would be helpful if you posted error messages or other information that shows how the result differs from the expectation. – Dennis Williamson Apr 23 '10 at 6:44
  • +1 for /sbin/ifconfig. It is most probably that ifconfig is not in your PATH, so try using it with full path to command. – Ivan Petrushev Apr 23 '10 at 6:54

try /sbin/ifconfig. you can also try searching in /proc/net


try with

ip address

Just to know, post a uname -a :)


ifconfig will work. but you need to be a super user.

try this command hostname -i

even netstat -rn also will work. but it will display the routing table also along with IP.

  • No, you don't have to be superuser to retrieve the information. – Dennis Williamson Apr 23 '10 at 6:41

Have you tried:

$ ifconfig eth0

(or replace eth0 with the device you're using) Look for: inet addr: xxx.xxx.xxx.xxx That's your IP addy.


Well, do you mean the IP in LAN?

If you can ssh in the box [by typing "ssh address_of_the_box"], you can just ping the address_of_the_box in another box, then you can get it...


If you are using ssh to access the machine, you must have the hostname. So you should be able to look up the ip address on some other machine using, for example dig hostname.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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