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?

  • 4
    tried /sbin/ifconfig ?
    – John Boker
    Commented Apr 23, 2010 at 3:05
  • Use an ioctl: mail.nl.linux.org/kernelnewbies/2003-05/msg00090.html
    – WhirlWind
    Commented Apr 23, 2010 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
    Commented Apr 23, 2010 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. Commented Apr 23, 2010 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. Commented Apr 23, 2010 at 6:54

7 Answers 7


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.

  • 1
    No, you don't have to be superuser to retrieve the information. Commented Apr 23, 2010 at 6:41
  • thanks, "hostname -i" is the one working also on a Kubernetes pod Commented Jul 26, 2021 at 22:39

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .