In linux, how can I get my IP address - ifconfig and ip addr show are not working
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
Related videos on Youtube
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, 2022Comments
-
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 about 14 yearstried /sbin/ifconfig ?
-
Admin about 14 yearsUse an ioctl: mail.nl.linux.org/kernelnewbies/2003-05/msg00090.html
-
Admin about 14 yearsI 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 about 14 yearsI 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 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 about 14 years/sbin/ifconfig ... damn solaris!
-
pavon almost 8 yearsNote 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 about 14 yearsNo, you don't have to be superuser to retrieve the information.
-
Mirko Conti almost 3 yearsthanks, "hostname -i" is the one working also on a Kubernetes pod