In linux, how can I get my IP address - ifconfig and ip addr show are not working

26,499

Solution 1

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

Solution 2

try with

ip address

Just to know, post a uname -a :)

Solution 3

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.

Solution 4

$ ifconfig eth0

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

Solution 5

Have you tried:

/sbin/ifconfig
Share:
26,499

Related videos on Youtube

Pushpender
Author by

Pushpender

I like to code and lift weights... I am a full-time Software Engineer for the movie business as well as a freelance coder, and part-time landlord. Received my BS in Computer Science, MBA, MS in Computer Science, and MS in Software Engineering. I spent a few years in the military then working as a contractor overseas which eventually brought me back to the states.

Updated on September 17, 2022

Comments

  • Pushpender
    Pushpender almost 2 years

    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?

    • John Boker
      John Boker about 14 years
      tried /sbin/ifconfig ?
    • Admin
      Admin about 14 years
    • Admin
      Admin about 14 years
      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.
    • Dennis Williamson
      Dennis Williamson about 14 years
      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.
    • Ivan Petrushev
      Ivan Petrushev about 14 years
      +1 for /sbin/ifconfig. It is most probably that ifconfig is not in your PATH, so try using it with full path to command.
    • Pushpender
      Pushpender about 14 years
      /sbin/ifconfig ... damn solaris!
    • pavon
      pavon almost 8 years
      Note that while /sbin/ifconfig is the most frequetly solution to this problem, there are cases where ifconfig is genuinely not installed, like minimalist docker images or embedded systems.
  • Dennis Williamson
    Dennis Williamson about 14 years
    No, you don't have to be superuser to retrieve the information.
  • Mirko Conti
    Mirko Conti almost 3 years
    thanks, "hostname -i" is the one working also on a Kubernetes pod