LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   what's difference between ifconfig and "hostname -i" (https://www.linuxquestions.org/questions/linux-software-2/whats-difference-between-ifconfig-and-hostname-i-205098/)

SeanatIL 07-14-2004 05:45 PM

what's difference between ifconfig and "hostname -i"
 
sorry to ask this stupid question, they gave me different info.

>ifconfig
eth0 Link encap:Ethernet HWaddr 00:D0:B7:A3:5C:FC
inet addr:10.1.144.48 Bcast:10.1.144.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:595502 errors:7 dropped:0 overruns:0 frame:7
TX packets:139996 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:103808093 (98.9 Mb) TX bytes:24454001 (23.3 Mb)
Interrupt:9 Base address:0xde80 Memory:fe9fe000-fe9fe038

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:694 errors:0 dropped:0 overruns:0 frame:0
TX packets:694 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:83497 (81.5 Kb) TX bytes:83497 (81.5 Kb)

>hostname -i
10.1.138.3

why they return different address? (10.1.144.48 and 10.1.138.3)

foo_bar_foo 07-14-2004 07:31 PM

*NOTE* i just give the config files i use yours might be different

ifconfig gives settings current for network interfaces (devices) including loopback
from /etc/sysconfig/network-devices
so if someone wants to talk to your NIC eth0 they will have to call 10.1.144.48

OK now each computer or "host" on your network can also be assigned one or more names instead of an IP address the name is linked to an IP address as defined in /etc/hosts

hostname on my system is set in /etc/sysconfig/network
the IP address shown by "hostname -i"
is set in /etc/hosts
where the name is to the right of the assigned IP
if you have multiple IP numbers assigned to "hostname" for some reason then "hostname -i" is just
spitting out the first one it comes to and that's not a problem.
mine says with "hostname -i" 127.0.0.1 and that works fine even though my network interface is something different.
but if you mean for your box to only be 127.0.0.1 and 10.1.144.48
i would change that stray number in /etc/hosts to 10.1.144.48
or if 10.1.144.48 is already defined in there just take the stray line out


All times are GMT -5. The time now is 02:28 PM.