Asterisk - Receiving calls from Twilio using PJSIP

I recently wanted to setup an asterisk server using Twilio as the phone provider. There wasn't much resource out there, but from what I did find it wasn't up to date or working.

I found something by Jordan Cook, however it wasn't for chan_pjsip, so I updated it and came up with the following:

[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  

This works for me, so if you spot anything wrong with that I've missed, I'd greatly appreciate a message so I can update it for everyone else. :)

comments powered by Disqus