Twilio Trunk not getting calls from a specific phone number

Debian Buster 10
Asterisk 16.2.1~dfsg-1+deb10u2
Twilio Trunk Provider

Hello Everyone,
Anyone who works with Twilio knows that when you build a trunk you build all the settings in that trunk with Elastic SIP Trunking. Then you add phone numbers and each number gets its settings from the trunk profile. Twilio is not being helpful with this whatsoever. All day support emails back and forth and they just dont get it. So I am here in the community asking for a bit of advise (other than dumping Twilio).

I have 1 phone number in my trunk that works perfect 100% of the time. I have a second number that was ported in and said port is status “COMPLETE” with that being said the second number will not work unless it is from another Twilio trunk. ex: Location1–>Asterisk–>Twilio Trunk–>PSTN then back again PSTN–>Twilio Trunk–Asterisk–>Location2 (THIS EXAMPLE WORKS!)

Twilio claims unable to communicate with my SIP infrastructure. However if they are both on the same trunk how is it one number can communicate and the other cannot?


exten => +13601111111,1,SipAddHeader(Alert-Info: <Bellcore-dr2>)
        same => n,dial(SIP/7302&SIP/7303&SIP/7308&SIP/7305,20,i)
        same => n,Dial(SIP/CORPOFFICE_VOIP/4570) ;WORKING LOCATION
        same => n,Hangup()

exten => +13602222222,1,SipAddHeader(Alert-Info: <Bellcore-dr2>)
        same => n,dial(SIP/7302&SIP/7303&SIP/7308&SIP/7305,25,i)
        same => n,Dial(SIP/CORPOFFICE_VOIP/4570) ;WORKING LOCATION
        same => n,Hangup()

This is my trunk setup:


       ;Our Termination URI

;       [twilio1](twilio-trunk)
;               host=

;       [twilio2](twilio-trunk)
;               host=

;       [twilio3](twilio-trunk)
;               host=

;       [twilio4](twilio-trunk)
;               host=

;       [twilio5](twilio-trunk)
;               host=

;       [twilio6](twilio-trunk)
;               host=

;       [twilio7](twilio-trunk)
;               host=

;       [twilio8](twilio-trunk)
;               host=dynamic ;THIS DOESNT SEEM TO WORK CAN SOMEONE CONFIRM?




Several of the Twilio lines are commented out but they are for regions that we do not have piped into the Asterisk box. I would be willing to just allow everything as in my little test example above and just use the firewall to manage the inbound traffic.

You need to run traces to see what is actually being sent and received between Twilio and your Asterisk server. Twilio should be able to provide traces from their end and you can run tshark to take traces on your end. The tshark trace taken from the Asterisk server would be the most useful one. Once you have the trace, you can look at the call flow and see where it is breaking down. It’s not really clear from your post what the problem is, but it sounds like the most likely scenarios are that 1) Twilio is misconfigured and is not sending anything down your trunk when the number is called, or 2) Twilio is sending the call to you and you’re not handling it properly. In any case, figuring out what exactly is wrong with the call flow is the first step before digging into any Asterisk configs.

OK so I ran the trace and I can see the inbound request coming from the working number…

89 14.841511744 →  SIP/SDP 1301 Request: INVITE sip:+13601111111@ |
   90 14.842010845 →  SIP 791 Status: 100 Trying |

However when I dial the number that does NOT work I get nothing from the Twilio network. Just as suspected I dont believe that Twilio is even attempting to reach my network.

I wonder if they are sending the call from a different set of IP’s? How would I allow that trunk to just accept a call from anywhere and not just the IP’s listed. This way I can have the firewall handle all the security and leave the Asterisk box out of the equation completely. By the way I have the firewall allowing every listed IP that Twilio has published so I do not believe that it is a fw issue.

You would enable allowguest in the general section.

Note, at the best of times, trunk is not a well defined term in SIP; it appears nowhere in the main specification document, but once you enable allowguest, you cannot really describe the incoming calls as coming from a trunk at all; they are just from the “cloud”.

All signs are pointing to a Twilio configuration issue, though it could be a firewall issue too. Go to them with these traces and ask why they are not sending the call to your IP when the number is dialed. If they say that they can’t communicate with your infrastructure, ask them to clearly define what they mean by that in technical terms.

You can also run a packet capture on your firewall while generating calls in order to rule that out as the cause of the problem.

Lastly, if you save your tshark trace as a file, you can open it in Wireshark and get a lot more detail on what is in the packets.

One more thing – you mentioned trying to get Asterisk to accept a call from anywhere, but your problem is different. You just verified with your packet capture that the call is never getting to your Asterisk server in the first place. You need to get the call to the Asterisk server first before Asterisk can even decide whether to accept it or not.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.