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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content