getaddrinfo() returning a different name to what is specified in /etc/hosts

Solution Verified - Updated -

Issue

  • getaddrinfo() behaviour for AF_INET and AF_INET6 addresses changed as of Red Hat Enterprise Linux 6.5
  • Different hostname is returned by the getaddrinfo() function when using an updated glibc.
  • Name resolution for addresses in hosts file behaves differently in glibc-2.12-1.131 or later.
  • A host entry in /etc/hosts does not return the hostname I expect it to.
  • A hostname in /etc/hosts returns the FQDN instead of the shortname.

Environment

  • Red Hat Enterprise Linux 6 (all architectures)
  • The glibc package prior to glibc-2.12-1.131.el6 installed
  • This glibc package updated in Red Hat Enterprise Linux 6.5
  • Hostnames defined in /etc/hosts
  • Application which does lookups using getaddrinfo() type AF_INET or AF_INET6 lookups of those hostnames.

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.