Asterisk - Receiving calls from Twilio using PJSIP

Everywhere when looking for Twilio and Asterisk information they use configuration for chan_sip when the recommended one to use nowadays is chan_pjsip.

I am right now extremely new to Asterisk, so this lack of resource has forced me to work out how to do it myself. (Not that it isn't a bad thing, It's helped me quite alot, but reaching blocks like these are extremely annoying)

So to give you a configuration you can use with chan_pjsip converted from the excellent guide by Jordan Cook.

[twilio]
type=endpoint  
context=from-twilio  
from_user=twilio  
disallow=all  
allow=ulaw  
auth=twilio  
aors=twilio

[twilio]
type=auth  
auth_type=userpass  
password=password  
username=twilio

[twilio]
type=aor  
max_contacts=10

; north american gateways - currently the only ones in use
[twilio-1]
type = identify  
endpoint = twilio  
match = 107.21.222.153

[twilio-2]
type = identify  
endpoint = twilio  
match = 107.21.211.20

[twilio-3]
type = identify  
endpoint = twilio  
match = 107.21.231.147

[twilio-4]
type = identify  
endpoint = twilio  
match = 54.236.81.101

[twilio-5]
type = identify  
endpoint = twilio  
match = 54.236.96.128

[twilio-6]
type = identify  
endpoint = twilio  
match = 54.236.97.29

[twilio-7]
type = identify  
endpoint = twilio  
match = 54.236.97.135

; south american gateways - not currently used but added for future use
[twilio-8]
type = identify  
endpoint = twilio  
match = 54.232.85.81

[twilio-9]
type = identify  
endpoint = twilio  
match = 54.232.85.82

[twilio-10]
type = identify  
endpoint = twilio  
match = 54.232.85.84

[twilio-11]
type = identify  
endpoint = twilio  
match = 54.232.85.85

; european gateways - not currently used but added for future use
[twilio-12]
type = identify  
endpoint = twilio  
match = 54.228.219.168

[twilio-13]
type = identify  
endpoint = twilio  
match = 54.228.233.229

[twilio-14]
type = identify  
endpoint = twilio  
match = 176.34.236.224

[twilio-15]
type = identify  
endpoint = twilio  
match = 176.34.236.247

; asian gateways - not currently used but added for future use
[twilio-16]
type = identify  
endpoint = twilio  
match = 46.137.219.1

[twilio-17]
type = identify  
endpoint = twilio  
match = 46.137.219.3

[twilio-18]
type = identify  
endpoint = twilio  
match = 46.137.219.35

[twilio-19]
type = identify  
endpoint = twilio  
match = 46.137.219.135

[twilio-20]
type = identify  
endpoint = twilio  
match = 54.249.244.21

[twilio-21]
type = identify  
endpoint = twilio  
match = 54.249.244.24

[twilio-22]
type = identify  
endpoint = twilio  
match = 54.249.244.27

[twilio-23]
type = identify  
endpoint = twilio  
match = 54.249.244.28  

Granted this is the one working for me, if you spot anything wrong with that I've missed, I'd greatly appreciate a message and a nod in the right direction. :)

comments powered by Disqus