Trouble with Twillo elastic sip trunk and extensions

Hello,

This seems like a no brainer but I;m stuck. We have aa asterisk 13.14.1 with a Twilio elastic trunk. We have a couple of test phones using Zoiper registered successfully with the asterisk box. Having some difficulty getting the dial plan correct. I can either get calls out to work or by changing the dial plan get extension to extension working but not both. Calls into the system using the Twilio numbers get a 404 not found with either setup.

Any help appreciated.

sip show peers
415/415 192.168.52.219 D Auto (No) No 50741 Unmonitored
667/667 192.168.50.215 D Auto (No) No 5061 Unmonitored
707/707 192.168.52.15 D Auto (No) No 43201 Unmonitored
prospector 10.138.0.3 Auto (No) No 5060 Unmonitored
twilio0/trunkuser 54.244.51.2 Auto (No) No 5060 Unmonitored
twilio1 54.172.60.2 Auto (No) No 5060 Unmonitored
twilio2 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3 54.172.60.1 Auto (No) No 5060 Unmonitored
twilio4 54.172.60.3 Auto (No) No 5060 Unmonitored

sip.conf
[general]
udpenable=yes
localnet=x.x.x.x
externaddr=x.x.x.x
allowoverlap=no ; Disable overlap dialing support. (Default is yes)
udpbindaddr=0.0.0.0 ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
tcpenable=yes ; Enable server for incoming TCP connections (default is no)
udpenable=yes ; Enable server for incoming TCP connections (default is no)
tcpbindaddr=0.0.0.0 ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
transport=udp ; Set the default transports. The order determines the primary default transport.
srvlookup=yes ; Enable DNS SRV lookups on outbound calls
preferred_codec_only=yes ; Respond to a SIP invite with the single most preferred codec
disallow=all ; First disallow all codecs
allow=ulaw ; Allow codecs in order of preference
allow=gsm
sipdebug =yes ; Turn on SIP debugging by default, from

twilio-trunk
type=peer
context=from-twilio ;Which dialplan to use for incoming calls
dtmfmode=rfc2833
canreinivite=no
insecure=port,invite

twilio0
host=ih-prospector.pstn.us2.twilio.com
remotesecret=
defaultuser=trunkuser

twilio1
host=54.172.60.2

twilio2
host=54.172.60.0

twilio3
host=54.172.60.1

twilio4
host=54.172.60.3

office-phone
type=friend
context=from-phones
host=dynamic
secret=
dtmfmode=auto
disallow=all
allow=ulaw
allowguest=no

667

soft-phone
type=friend
context=from-phones
host=dynamic
secret=
;regexten=1003
dtmfmode=auto
disallow=all
allow=ulaw
allowguest=no

[415]
regexten=4159688518
type=friend
context=from-phones
host=dynamic
secret=
;regexten=1003
dtmfmode=auto
disallow=all
allow=ulaw
allowguest=no

;soft-phone-925
;regexten=925

916
regexten=916

[707]
regexten=7075023078
type=friend
context=from-phones
host=dynamic
secret=
;regexten=1003
dtmfmode=auto
disallow=all
allow=ulaw
allowguest=no

extensions.conf
[general]
static=yes
writeprotect=no
clearglobalvars=no

[from-twilio]
exten => _+1NXXNXXXXXX,1,NoOp(Dialing TWILIO from ${CALLERID(all)} to ${EXTEN} with DID ${DID})
exten => _+1NXXNXXXXXX,n,Dial(SIP/${EXTEN})
exten => _XXX,n,Dial(SIP/${EXTEN})
same => n,Hangup

[from-phones]
exten => _NXXNXXXXXX,1,NoOp(Dialing out from ${CALLERID(all)} to ${EXTEN} with DID ${DID})
exten => _NXXNXXXXXX,n,Dial(SIP/twilio0/+1${EXTEN})
; test
exten => _XXX,n,Dial(SIP/${EXTEN})

exten => 707,1,NoOp()
same => n,Dial(SIP/twilio0/+1${EXTEN})
same => n,Hangup

exten => 415,1,NoOp()
same => n,Dial(SIP/twilio0/+1${EXTEN})
same => n,Hangup

exten => 667,1,NoOp()
same => n,Dial(SIP/twilio0/+1${EXTEN})
same => n,Hangup

[from-phones-internal]
exten => _XXX,1,NoOp(Dialing out from ${CALLERID(all)} to ${EXTEN} with DID ${DID})
exten => _XXX,n,Dial(SIP/${EXTEN})

Thanks in advance for your time

I see this error in the from-phones context:

exten => 707,1,NoOp()
same => n,Dial(SIP/twilio0/+1${EXTEN})
same => n,Hangup

This would mean that any phone that calls to 707 would be routed to twilio and dials +1707, dont think that twilio will handle that call.

The from-phones-internal is not used by any of the phones, so you can ditch that one.

The configuration of the sip trunks is also not correct.

twilio-trunk
type=peer
context=from-twilio ;Which dialplan to use for incoming calls
dtmfmode=rfc2833
canreinivite=no
insecure=port,invite
remotesecret=
defaultuser=trunkuser

twilio0
host=ih-prospector.pstn.us2.twilio.com

twilio1
host=54.172.60.2

twilio2
host=54.172.60.0

twilio3
host=54.172.60.1

twilio4
host=54.172.60.3

So the twilio-trunk part is used by all the hosts.

The office phone and softphone are also missing the [ ] hooks.

If I were you I would get the book “Asterisk the Future of telephony” (https://ftp.fr.openbsd.org/pub/OpenBSD/distfiles/9780596510480.pdf) this is an older version, but the new one should be available as creative commons book.

And Im pretty sure I’ve missed some errors, but start with the info Ive given.

mmm, missing the [ ] hooks as well…

[twilio2]
host=54.172.60.0

Ah, you learn something every day…

[twilio-trunk]
type=peer
context=from-twilio ;Which dialplan to use for incoming calls
dtmfmode=rfc2833
canreinivite=no
insecure=port,invite
remotesecret=
defaultuser=trunkuser

[twilio0]
host=ih-prospector.pstn.us2.twilio.com

[twilio1]
host=54.172.60.2

[twilio2]
host=54.172.60.0

[twilio3]
host=54.172.60.1

[twilio4]
host=54.172.60.3

Awesome, I’ve been spoiled admin-ing freepbx with AGI/AMI and this is my
first config by hand. Appreciate your time.

For the Twilio trunk I was using the template notation of xxx as
suggested in the Twilio asterisk docs.

Thanks again,