[asterisk-dev] IPv4 and IPv6 preference
Olle E. Johansson
oej at edvina.net
Fri Jul 16 08:45:38 CDT 2010
16 jul 2010 kl. 15.33 skrev Simon Perreault:
> On 2010-07-16 09:23, Olle E. Johansson wrote:
>> I've been trying to understand some of the DNS support for IPv6 and can't find traces here. It seems a bit random.
>
> By default, on most OSes, getaddrinfo() will return IPv6 results first.
>
> We make no attempt to change the default order. However, we don't want
> to connect to IPv6 addresses if we are bound only to IPv4, and
> vice-versa. So we implemented the following heuristic:
>
> - If bindaddr is the IPv6 wildcard address (i.e. ::), we do not filter
> results.
> - If bindaddr is an IPv4 address, we only use IPv4 results.
> - Otherwise, we only use IPv6 results.
Hmm. I need to revisit the code, because I saw nothing doing this in dnsmgr or acl.c. Must have put my brain in weekend-mode early...
>
> Note also that throughout chan_sip, only the first DNS result is
> considered. A major rearchitecturing would be required to try multiple
> results in sequence.
Yes. At least the first ipv4 and the first IPv6 is needed now, if we can't get it right. Otherwise it will fail miserably in dual stack environments.
>
>> If I only use IPv6 on my Asterisk and call a domain that has both IPv4 and IPv6 SRV records, the call might fail randomly because the first one ending up is the ipv4 record. When calling srv record lookups, we need to tell the dns functions what we can handle and how we want to prioritize.
>>
>> I would like to be able to set a preference for a dual stack host to say "I prefer IPv6" or "I hate IPv6, use IPv4 if available".
>
> Note also that "prioritization" doesn't have the meaning it should have
> when taken in the context of chan_sip. Since more often than not only
> the first result is used and all others are simply discarded, "priority
> for X" ends up meaning "only use X unconditionally".
>
> Was that explanation of the current situation useful?
Yes, thanks you. It's still a bug that needs to be fixed.
>
> What can we do to improve it?
The ugly way is to get at least one each in the case of dual stack, then select according to user preference or try one at a time.
Considering me configuring my SRV set with the first record ONLY resolving to IPv6 and the second one ONLY resolving to IPv4 - with a lower priority. Will an IPv4 only asterisk find the IPv4 SRV record or fail since the first one with highest priority was only IPv6?
Btw, this is the recommendation we came up with at SIPit to control IPv6/ipv4 services and show my preference for RECEIVING calls to my domain. Even if it's the same host, add two host names with different resolution on different priorities.
/O
>
> Simon
> --
> NAT64/DNS64 open-source --> http://ecdysis.viagenie.ca
> STUN/TURN server --> http://numb.viagenie.ca
> vCard 4.0 --> http://www.vcarddav.org
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
---
* Olle E Johansson - oej at edvina.net
* Cell phone +46 70 593 68 51, Office +46 8 96 40 20, Sweden
More information about the asterisk-dev
mailing list