MacOS Resolution of localhost Does anyone know the exact mechanism by which localhost is resolved to 127.0.0.1 on MacOS without an entry in /etc/hosts? Is it logic encoded in mDNSResponder itself or something similar, or more high level in a config file somewhere?
Further, how could I determine this myself?  For example, via system call tracing or similar?
It seem like this is, in fact, hardcoded in mDNSResponder.
╰─ grep -A5 -B5 &quot;Register localhost&quot; ./mDNSResponder-1096.40.7/mDNSMacOSX/mDNSMacOSX.c
        const domainname *const localHostName     = (const domainname *) &quot;\x9&quot; &quot;localhost&quot;;
        const domainname *const broadcastHostName = (const domainname *) &quot;\xd&quot; &quot;broadcasthost&quot;;
        const mDNSv4Addr        localHostV4       = { { 127, 0, 0, 1 } };
        mDNSv6Addr              localHostV6;
        // Register localhost 127.0.0.1 A record.
        RegisterLocalOnlyARecord(localHostName, &amp;localHostV4);
        // Register broadcasthost 255.255.255.255 A record.
--
--
        // Register broadcasthost 255.255.255.255 A record.
        RegisterLocalOnlyARecord(broadcastHostName, &amp;onesIPv4Addr);
        // Register localhost ::1 AAAA record.
        mDNSPlatformMemZero(&amp;localHostV6, sizeof(localHostV6));
        localHostV6.b[15] = 1;
        RegisterLocalOnlyAAAARecord(localHostName, &amp;localHostV6);
    }