This document covers technical details to ensure that calls sent from a customer's SIP infrastructure to Twilio Elastic SIP Trunking are properly processed. For a successful integration it is important to follow the following guidelines:
Your Elastic SIP trunk has a unique domain name, such as mytrunk.pstn.twilio.com
; this is referred to in your Twilio console as your Termination SIP URI. It is important that the request URI (specifically the host part) contains this domain name so that Twilio can identify your traffic. When targeting your traffic to a specific Twilio Edge Location there are two main approaches:
Your Twilio SIP domain comes in a localized version, mytrunk.pstn.[edge].twilio.com
, for example mytrunk.pstn.ashburn.twilio.com
. Using this domain is simple but may be less flexible since the same name is used for identifying your trunk as well as controlling where traffic is routed. Specifically there may be limitations on how your server is able to load balance traffic across Twilio IPs.
All Twilio customer SIP domains resolve to the same A DNS record, which means customers share the same Twilio SIP endpoints. These A records provide all IPs in random order, but it is up to your SIP server to load balance across all of them. This behavior will vary by vendor and In many cases only the first IP is used which would not produce the expected load balancing.
A more reliable approach for predictable load balancing is to configure your SIP server with both your personalized domain name and an "Outbound Proxy" or Route header set to one of Twilio's generic localized edge domain names. These domains offer NAPTR and SRV records (see RFC 3263). The DNS names for these records are pstn.[edge].twilio.com
, for example pstn.ashburn.twilio.com
.
These records resolve to the same IPs as the personal localized SIP Trunk domain name, but supported SIP servers can query the SRV record for additional load balancing information.
To be able to use this option, your SIP server still has to use your personal trunk domain name in the Request URI. You can do this by specifying the generic localized DNS as the "Outbound Proxy" in your configuration. The exact name might vary and might include configuring a Route header or similar. Consult your vendor's manual for details.
Example configuration:
mytrunk.pstn.twilio.com
pstn.ashburn.twilio.com
The following examples are DNS queries for the A record of the localized domain as well as the NAPTR and SRV of the proxy domain. Examples are from US East, Ashburn.
1dig +short mytrunk.pstn.ashburn.twilio.com254.172.60.0354.172.60.1454.172.60.3554.172.60.267dig +short SRV _sip._udp.pstn.ashburn.twilio.com810 10 5060 public-sip0.ashburn.twilio.com.910 10 5060 public-sip1.ashburn.twilio.com.1010 10 5060 public-sip2.ashburn.twilio.com.1110 10 5060 public-sip3.ashburn.twilio.com.1213dig +short NAPTR pstn.ashburn.twilio.com1410 10 "S" "SIP+D2U" "" _sip._udp.pstn.ashburn.twilio.com.1520 10 "S" "SIPS+D2T" "" _sips._tcp.pstn.ashburn.twilio.com.1620 10 "S" "SIP+D2T" "" _sip._tcp.pstn.ashburn.twilio.com.