Skip to content
  • Dan Williams's avatar
    policy: add public address mappings before localhost ones · 138876b4
    Dan Williams authored
    Otherwise glibc will count the localhost IPv6 (::1) mapping as
    resolving to the IPv4 localhost mapping as well, so this:
    
    127.0.0.1   localhost.localdomain localhost
    ::1         foobar localhost6.localdomain6 localhost6
    192.168.1.2 fooar
    
    causes a lookup of 'foobar' (or even just 'ping foobar') to resolve
    to 127.0.0.1, even though the hostname is *not* listed on the
    IPv4 localhost line.  Apparently glibc just looks for the hostname
    on any IPv4 or IPv6 localhost line.
    
    We need to ensure that even if you don't have a routable IP address
    for one of [IPv4, IPv6] that the hostname resolves to the localhost
    address for that IP version, otherwise lots of stuff starts
    breaking.  But for the IP versions that you do have a routable IP
    address, we want the hostname to map to that IP address too.
    138876b4