extensions.conf
;;;;;;;;;;;
[internal]
exten => _6XXX,1,Dial(PJSIP/${EXTEN})
same=>n,hangup()
exten => _*6XXX,1,Dial(${PJSIP_DIAL_CONTACTS(${EXTEN:1})})
same=>n,hangup()
exten => _x.,1,Dial(PJSIP/${EXTEN}@8001)
same=>n,hangup()
;exten => _9NXXNXXXXXX,1,Dial(PJSIP/mytrunk/sip:${EXTEN:1}@203.0.113.1:5060)
;same=>n,hangup()
[from-freepbx]
exten=>_x.,1,Dial(PJSIP/${EXTEN},45)
same=>n,hangup()
[from-gateway]
exten=>8001,1,NooP( incoming call from ${CALLERID(num)})
same=>n,Set(pseudodid=${PJSIP_HEADER(read,From)})
same=>n,Set(pseudodid=${CUT(pseudodid,@,1)})
same=>n,Set(__pseudodid=${CUT(pseudodid,<,1)})
same=>n,Set(__phone=${pseudodid})
same=>n,Set(CALLERID(num)=${phone})
same=>n,Dial(PJSIP/6000)
same=>n,hangup()
;;;;;;;;pjsip.conf;;;;;;;;;;;;;;;;;;;;
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
local_net=10.0.0.0/24
;;;;;;;;;;;;;
[6000]
type=endpoint
context=internal
disallow=all
allow=ulaw
allow=alaw
callerid=6000
direct_media=no
force_rport=yes
ice_support=yes
identify_by=username
mailboxes= 6000
moh_suggest=default
rewrite_contact=yes
rtp_symmetric=yes
send_diversion=yes
send_pai=yes ; Send the P Asserted Identity header (default: "no")
send_rpid=yes ; Send the Remote Party ID header (default: "no")
trust_id_inbound=no
trust_id_outbound=no
allow_transfer=yes
from_user=6000
mwi_from_user=6000
set_var=id=6001;name=ambiorix
auth=6000
aors=6000
direct_media=no
transport=transport-udp
[6000]
type=auth
auth_type=userpass
password=19111@@!
username=6000
[6000]
type=aor
max_contacts= 5
qualify_frequency=1 ; Interval at which to qualify an AoR (default: "0")
authenticate_qualify=no
remove_existing=yes
maximum_expiration=7200 ; Maximum time to keep an AoR (default: "7200")
minimum_expiration=6000 ; Minimum keep alive time for an AoR (default: "60")
default_expiration=3600
mailboxes=6000
authenticate_qualify=no
;;;;;;;;;;;;
[6001]
type=endpoint
context=internal
disallow=all
allow=ulaw
allow=alaw
callerid=6001
direct_media=no
force_rport=yes
ice_support=yes
identify_by=username
mailboxes= 6001
moh_suggest=default
rewrite_contact=yes
rtp_symmetric=yes
send_diversion=yes
send_pai=yes ; Send the P Asserted Identity header (default: "no")
send_rpid=yes ; Send the Remote Party ID header (default: "no")
trust_id_inbound=no
trust_id_outbound=no
allow_transfer=yes
from_user=6001
mwi_from_user=6001
set_var=id=6001;name=ambiorix
auth=6001
aors=6001
direct_media=no
transport=transport-udp
[6001]
type=auth
auth_type=userpass
password=19111@@!
username=6001
[6001]
type=aor
max_contacts= 5
qualify_frequency=1 ; Interval at which to qualify an AoR (default: "0")
authenticate_qualify=no
remove_existing=yes
maximum_expiration=7200 ; Maximum time to keep an AoR (default: "7200")
minimum_expiration=6000 ; Minimum keep alive time for an AoR (default: "60")
default_expiration=3600
mailboxes=6001
authenticate_qualify=no
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[6002]
type=endpoint
context=internal
disallow=all
allow=ulaw
allow=alaw
callerid=6002
direct_media=no
force_rport=yes
ice_support=yes
identify_by=username
mailboxes= 6002
moh_suggest=default
rewrite_contact=yes
rtp_symmetric=yes
send_diversion=yes
send_pai=yes ; Send the P Asserted Identity header (default: "no")
send_rpid=yes ; Send the Remote Party ID header (default: "no")
trust_id_inbound=no
trust_id_outbound=no
allow_transfer=yes
from_user=6002
mwi_from_user=6002
set_var=id=6001;name=ambiorix
auth=6002
aors=6002
direct_media=no
transport=transport-udp
[6002]
type=auth
auth_type=userpass
password=19111@@!
username=6002
[6002]
type=aor
max_contacts= 5
qualify_frequency=1 ; Interval at which to qualify an AoR (default: "0")
authenticate_qualify=no
remove_existing=yes
maximum_expiration=7200 ; Maximum time to keep an AoR (default: "7200")
minimum_expiration=6000 ; Minimum keep alive time for an AoR (default: "60")
default_expiration=3600
mailboxes=6000
authenticate_qualify=no
;;;;;;;;;;;;trunks ;;;;;;;;;;;;;;;;;;;;;;
[twilio]
type=aor
contact=sip:ambiorixg12.pstn.us1.twilio.com:5060
qualify_frequency=100
authenticate_qualify=no
remove_existing=yes
maximum_expiration=7200 ; Maximum time to keep an AoR (default: "7200")
minimum_expiration=6000 ; Minimum keep alive time for an AoR (default: "60")
default_expiration=3600
authenticate_qualify=no
[twilio]
type=endpoint
context=from-trunk
disallow=all
allow=ulaw
allow=alaw
direct_media=no
force_rport=yes
ice_support=yes
moh_suggest=default
rewrite_contact=yes
rtp_symmetric=yes
send_diversion=yes
send_pai=yes ; Send the P Asserted Identity header (default: "no")
send_rpid=yes ; Send the Remote Party ID header (default: "no")
trust_id_inbound=yes
trust_id_outbound=yes
allow_transfer=yes
from_user=twilio
set_var=id=twilio;name=twilio_trunk
aors=twilio
direct_media=no
transport=transport-udp
[twilio]
type=identify
endpoint=twilio
match=54.172.60.0/8
match=68.183.142.204
[8001]
type=endpoint
context=from-gateway
disallow=all
allow=ulaw
allow=alaw
direct_media=no
force_rport=yes
ice_support=yes
identify_by=username
moh_suggest=default
rewrite_contact=yes
rtp_symmetric=yes
send_diversion=yes
send_pai=yes ; Send the P Asserted Identity header (default: "no")
send_rpid=yes ; Send the Remote Party ID header (default: "no")
trust_id_inbound=yes
trust_id_outbound=yes
allow_transfer=yes
auth=8001
aors=8001
direct_media=no
transport=transport-udp
[8001]
type=auth
auth_type=userpass
password=19111139z733
username=8001
[8001]
type=aor
max_contacts= 5
qualify_frequency=1 ; Interval at which to qualify an AoR (default: "0")
authenticate_qualify=no
remove_existing=yes
maximum_expiration=7200 ; Maximum time to keep an AoR (default: "7200")
minimum_expiration=6000 ; Minimum keep alive time for an AoR (default: "60")
default_expiration=3600
mailboxes=8001
authenticate_qualify=no
;;;;;;;;;;registration;;;;;;;;;;;;
[FreePBX]
type=auth
auth_type=userpass
password=rz#6c2a6aa9e3f52e
username=311
[FreePBX]
type = registration
server_uri = sip:155.138.223.92:28641;udp
client_uri = sip:311@155.138.223.92:28641;udp
outbound_auth=FreePBX
contact_user=6002 ;send incoming calls to this extension
expiration=120
line=yes
endpoint=FreePBX
max_retries=10
[FreePBX]
type=endpoint
context=from-freepbx ; context for incomings
disallow=all
allow=ulaw
allow=alaw
direct_media=no
force_rport=yes
ice_support=ye
identify_by=ip ; this will aut incoming callsh base on the ip on the identify section
moh_suggest=default
rewrite_contact=yes
rtp_symmetric=yes
send_diversion=yes
send_pai=yes ; Send the P Asserted Identity header (default: "no")
send_rpid=yes ; Send the Remote Party ID header (default: "no")
trust_id_inbound=yes
trust_id_outbound=yes
allow_transfer=yes
direct_media=no
transport=transport-udp
[FreePBX]
type=identify
endpoint=FreePBX
match=155.138.223.92 ;carrier source ip
https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Configuration_res_pjsip_outbound_registration#Asterisk20Configuration_res_pjsip_outbound_registration-registration_max_retries
https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Configuration_res_pjsip
https://wiki.asterisk.org/wiki/display/AST/res_pjsip+Configuration+Examples