7.2 Forward Lookups
7.2.1 localhost in the shim #
- A name that, with trailing dots removed, is
localhostor ends in.localhost, compared case-insensitively, is answered inside the calling process without contacting resolvd — whether resolvd is running or not. - The answer is
127.0.0.1for IPv4,::1for IPv6, or both, IPv4 first, with canonical namelocalhostand TTL 0.
7.2.2 Other names #
- Any other name is sent as a
lookup(§4.9), with the family the entry point asks for. The addresses in the reply are filtered to that family, and an empty result isNOTFOUND(§7.1). - Addresses are returned in the order resolvd's reply lists them.
resolvd does not fix which family comes first (§4.9); glibc's own
sorting of getaddrinfo results is what callers normally see.
7.2.3 gethostbyname4_r #
The result is a linked list of gaih_addrtuple, and the pointer glibc
passes is overwritten with the head of the list:
7.2.3.1 The gethostbyname4_r TTL #
When ttlp is given it receives the least TTL among the addresses.
7.2.4 The forward hostent #
gethostbyname3_r, 2_r and _r return a hostent:
| Field | Content |
|---|---|
h_name | The reply's canonical name |
h_aliases | Empty |
h_addrtype | The af asked for |
h_length | 4 or 16 |
h_addr_list | Every address, in reply order |
7.2.5 The gethostbyname3_r TTL and canonical name #
When ttlp is given it receives the least TTL among the addresses, and
when canonp is given it is pointed at h_name.