res_getservers does not set sin6_scope_id in case for DNS server with IPV6 address with scope local

Hi,


In case of pure IPV6 network, many routers provide a DNS IPV6 address from a local link (I.E fe80::/64)

To be able to route this address kind of address, it's mandatory to know its scope (I.E %en0 for the first network interface).


In case of DNS server addresses, this value should be available from sin6_scope_id of the struct sockaddr_in6 returned by res_getservers.

In my case (macosx 10.12.6/Xcode 8.3.3), this value is always 0. It seems to be the same on IOS 10.


The consequence is that IPV6 DNS address from local link returned by res_getservers are unsuable.


Any clue on this ?


Best regards

Replies

The first question I always ask in situations like this is, why are you doing your own DNS resolution? You’re always going to run into problems with that because the legacy BIND APIs simply don’t provide enough info for you to successfully emulate what the system resolver is doing. And if you call the system resolver then it really doesn’t matter what

res_getservers
returns.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi Quinn,


Thanks for your answer,


Well, our software is a SIP (RFC 3261) stack running on many operating system. We have very strong asynchronous requirements specially because we are performaing many DNS request including SRV.

So for both portability an asynchrous behavior, we choosed to maintain a full DNS stack. By the way, I agree it's a lot of work ;-)


This being said thanks to res_getservers this is something we managed to acheive on macosx/ios because we only need a way to get routable DNS server IP addresses, including scope id ;-) .

So it would be very apriciated if this field was set :-) Or maybe any alternate API to get such address ?


Best regards

Jehan

I’m going to address your main point up front, just so we’re not distracted by my “don’t do your own DNS resolution” rant (-: You wrote:

So it would be very apriciated if this field was set :-)

If you want to request a change to the OS behaviour, you should file a bug report along those lines. Please post your bug number, just for the record.

And now back to the rant (-:

So for both portability an asynchrous behavior, we choosed to maintain a full DNS stack.

On the async front, the system resolver on Apple platforms fully supports async execution of arbitrary DNS queries via

DNSServiceQueryRecord
(in
<dns_sd.h>
).

On the portability front, this sounds like a classic trade off between developer and customer convenience. I understand the desire to use the same code on all platforms but…

By the way, I agree it's a lot of work ;-)

I think you missed my point there. It’s not “a lot of work” (well, it is a lot of work, but not just a lot of work), it’s actually impossible. The legacy BIND APIs don’t expose enough info for you to implement a resolver that handles all the situations that the system resolver handles. In various corner cases — and the one I’m most familiar with is VPN — your resolver will give different results from the system resolver.

This can result in very confusing behaviour. For example, imagine that the SIP server also runs a web server for management. The user connects to the web server via Safari and everything works fine. They then use your app to connect over SIP and they get ‘host not found’ errors.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks,


I submitted a bug repport (https://bugreport.apple.com/web/?problemID=34569458)


Best regards

Did this ever get resolved? I am running into the same issue. I thought the docs specified that res_getservers is supposed to return ipv4 and ipv6 DNS addresses. I also need this for SRV lookups and some custom DNS handling.

I’ll leave jehanm to respond with their current status but, looking at their bug report (r. 34569458), I don’t see any progress from our side.

I also want to reiterate what I told jehanm here: don’t implement you own DNS resolver. It’s simply not possible to correctly deal with all the edge cases that the system DNS resolver handlers.

I also need this for SRV lookups and some custom DNS handling.

With regards SRV lookups, you can do those many different ways, but the way I recommend is the DNS-SD API, as shown by the SRVResolver sample code.

I’m not sure what “custom DNS handling” means but if you care to elaborate I should be able to offer you some suggestions here.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"