bash - `hostname -i` address differs from `ifconfig` address -


resolving local hostname (the 1 returned hostname) not yield right ip address. why , how fix it?

$ hostname -i 10.21.16.206  $ ping 10.21.16.206 ping 10.21.16.206 (10.21.16.206) 56(84) bytes of data. 10.21.16.159 icmp_seq=1 destination host unreachable  $ ifconfig (...) inet 10.21.16.159  netmask 255.255.252.0  broadcast 10.21.19.255 (...) 

10.21.16.206 != 10.21.16.159

$ host 10.21.16.159  host 159.16.21.10.in-addr.arpa. not found: 3(nxdomain)  $ host 10.21.16.206  206.16.21.10.in-addr.arpa domain name pointer lxka-czc1166cxw.united.domain.  $ resolveip 10.21.16.159 host name of 10.21.16.159 lxka-czc1166cxw  $ resolveip 10.21.16.206 host name of 10.21.16.206 lxka-czc1166cxw.united.domain 

help appreciated!

edit:

$ host $(hostname) lxka-czc1166cxw.united.domain has address 10.21.16.206 

hostname -i relies on dns resolution return ip address of given hostname. either /etc/hosts or dns resolver return hostname incorrect ip address.


Comments