It does a DNS lookup on the hostname and depending on the result chooses appropriately based on the available configured transports. It follows this RFC[1] but with a slight tweak of favoring IPv6.
9.8.7.6.5.4.3.2.1.6.6.1.4.e164.ch. 10800 IN NAPTR 100 10 “u” “sip+E2U” “!^(.*)$!\1@woody.ch!” .
I would have expected this to result in +4166123456789@woody.ch for Transport E2U => udp
But when I check what asterisk did in my experiment… it tried TSL via IPv6?
So, why tls? is asterisk performing a second NAPTR lookup on the URI received from the ENUM lookup? There indeed, SIPS+D2T is the prefered method.
|woody.ch.||465|IN|NAPTR|10 100 s SIPS+D2T _sips._tcp.woody.ch.|
|woody.ch.||465|IN|NAPTR|40 100 s IAX+D2U _iax._udp.woody.ch.|
|woody.ch.||465|IN|NAPTR|30 100 s SIP+D2T _sip._tcp.woody.ch.|
|woody.ch.||465|IN|NAPTR|20 100 s SIP+D2U _sip._udp.woody.ch.|