Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hey guys, i'm trying to figure out how to find the host IP address using shell commands.
So far I have:
hostname -i
ip addr show
These both give me different IPs, which one is the correct host ip? and is it internal or external? from what I understand this is the internal IP of the system
Ifconfig shows the same information as ip addr show.
It show all addresses both the lo and your physical ethernet adapter
Hostname -i shows 127.0.0.1 since your hostname is not resolved because your not running an internal DNS server. See hostname man pages for more information.
127.0.0.1 is the local loop back adapter which is internal or virtual.
Ifconfig shows the same information as ip addr show.
It show all addresses both the lo and your physical ethernet adapter
Hostname -i shows 127.0.0.1 since your hostname is not resolved because your not running an internal DNS server. See hostname man pages for more information.
127.0.0.1 is the local loop back adapter which is internal or virtual.
hostname -i doesn't show me 127.0.0.1 it is showing me an address like:
192.168.x.x which i'm assuming is just a local ip?
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
ifconfig can be run by a non-root user by using the full path "/sbin/ifconfig" -- a non-root user won't be able to change anything but can list things all the same.
It really is worth reading up on how IP addresses work (no need to remember any calculations and the like though) as it can be helpful to know.
ifconfig can be run by a non-root user by using the full path "/sbin/ifconfig" -- a non-root user won't be able to change anything but can list things all the same.
It really is worth reading up on how IP addresses work (no need to remember any calculations and the like though) as it can be helpful to know.
ah, okay! "/sbin/ifconfig" worked for me, showing me the ethernet and loopback info. So looking at this, and based on what michael said it seems that this is showing the host IP which is a local/internal IP, correct?
Also it seems that it is showing the same address as
hostname -i
except it's cleaner since it shows nothing but the IP.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
Quote:
Originally Posted by goofygoober
ah, okay! "/sbin/ifconfig" worked for me, showing me the ethernet and loopback info. So looking at this, and based on what michael said it seems that this is showing the host IP which is a local/internal IP, correct?
Also it seems that it is showing the same address as
hostname -i
except it's cleaner since it shows nothing but the IP.
Yes, it shows the loopback IP address and any local addresses also. The 192.xxxxxx address is always going to be a LAN address which is routed to the internet mostly using NAT. Have a look using google about IP addresses and how things like rooting and subnetting work -- as mentioned above not to learn exactly how the numbers work but to give an idea of how things are connected.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.