On Tue, Jul 25, 2017 at 11:20:57PM +0200, u-hd-p...@aetey.se wrote: > > > As you can see, getaddrinfo(3) will only use DNS to chase the CNAME > > defined in DNS and does not consult /etc/hosts in the middle of a > > You refer to a certain implementation which is not a specification > by itself. What do the applicable standards say?
Since we are discussing our processing of SRVs rather than CNAMEs, I'll limit my conversation to the relevant stanards for SRVs. >From RFC2782 page 4, the target of a SRV RR: Target The domain name of the target host. There MUST be one or more address records for this name, the name MUST NOT be an alias (in the sense of RFC 1034 or RFC 2181). Implementors are urged, but not required, to return the address record(s) in the Additional Data section. Unless and until permitted by future standards action, name compression is not to be used for this field. A Target of "." means that the service is decidedly not available at this domain. Note that it states "the domain name of the target host". /etc/hosts doesn't contain domain names but rather host names. It also urges implementors to return the address records in the Additional Data section. This implies, I think, the addresses are to be obtained by the implementor probably on the domain name server. Later in RFC2782, on page 6 (according to the below URL), there is a section entitled "Usage rules" which again clearly states that a SRV-cognisant client SHOULD use a procedure which includes querying DNS for the results of the SRV RR targets: For each element in the new list query the DNS for address records for the Target or use any such records found in the Additional Data section of the earlier SRV response. Later in the "Notes:" section, the RFC states: - If the Additional Data section doesn't contain address records for all the SRV RR's and the client may want to connect to the target host(s) involved, the client MUST look up the address record(s). (This happens quite often when the address record has shorter TTL than the SRV or NS RR's.) An "address record" in the context of an RFC about DNS is clearly a DNS A or AAAA RR and not an entry in /etc/hosts.  https://tools.ietf.org/html/rfc2782 -- Roland C. Dowdeswell