What is the difference between the ip address of hostname -i, and the output of ip addr??, and what ip address of hostname -i is used for?


As per man hostname

-i, --ip-address
          Display the network address(es) of the host name. Note that this
          works only if the host name can be resolved.  Avoid  using  this
          option; use hostname --all-ip-addresses instead.

This takes the hostname, performs a DNS lookup of that hostname, and displays the corresponding address.

ip addr will give you a full list of all interface, all IPs, aliases (if any), along with mac, state and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.