wahern / dns

dns.c: Single file non-blocking DNS C library without callbacks or external dependencies.
http://25thandclement.com/~william/projects/dns.c.html
MIT License
256 stars 64 forks source link

localhost not preloaded #29

Open daurnimator opened 6 years ago

daurnimator commented 6 years ago

I was suprised to see dns.c reach out to my dns server to ask about 'localhost'.

rfc6761:

6.3. Domain Name Reservation Considerations for "localhost."

...

  1. Name resolution APIs and libraries SHOULD recognize localhost names as special and SHOULD always return the IP loopback address for address queries and negative responses for all other query types. Name resolution APIs SHOULD NOT send queries for localhost names to their configured caching DNS server(s).

I tracked this down to be due to /etc/hosts not containing a 'localhost' entry: dns.c needs to treat localhost specially.